Skip to main content

"describeCodePackages"

JSON ADMIN "describeCodePackages" action returns all the current information about specified code packages

The "describeCodePackages" action returns all the current information about the specified code package names including source code and package properties. 

Use "describeCodePackageHistory" to retrieve information about previous versions of a code package.

Request examples

{ 
  "api": "admin",
  "action": "describeCodePackages",
  "params": {
    "databaseName": "faircom",
    "ownerName": "admin",
    "codeNames": [ "convertTemperature" ],
    "codeFormat": "utf8 | base64 | hex | byteArray | json"
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}
{ 
  "api": "admin",
  "action": "describeCodePackages",
  "params": {
      "codeNames": ["convertTemperature"]
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}
{
  "authToken": "replaceWithValidAuthToken",
  "result": {
    "data": [
      {
        "codeId": 4,
        "databaseName": "faircom",
        "ownerName": "admin",
        "codeName": "convertTemperature",
        "codeVersion": 2,
        "clonedCodeId": 0,
        "codeStatus": "deleted",
        "codeLanguage": "javascript",
        "codeType": "transform",
        "description": "New description replaces old description.\nAnother description line.",
        "metadata": {
          "keyword": "temperature",
          "favorites": true
        },
        "createdBy": "ADMIN",
        "createdOn": "2024-10-15T19:29:34.216",
        "updatedBy": "ADMIN",
        "updatedOn": "2024-10-15T19:56:49.879",
        "comment": "Modified the code and changed the name back",
        "codeFormat": "utf8",
        "code": "// The server runs this JavaScript code, which is registered in the server as a transform method.\nrecord.temperature_fahrenheit = record.source_payload.temperature\nrecord.temperature_celsius = getCelsiusFromFahrenheit(record.temperature_fahrenheit)\nrecord.temperature_status = calculateTemperatureStatus(record.temperature_fahrenheit)\n\nfunction getCelsiusFromFahrenheit(temperature_fahrenheit){\n    return (temperature_fahrenheit - 32) / 1.8;\n}\n\nfunction calculateTemperatureStatus(temperature_fahrenheit){\n    switch (true) {\n        case (temperature_fahrenheit < 0):\n            return \"alert: too cold\";\n        case (temperature_fahrenheit < 32):\n            return \"cold\";\n        case (temperature_fahrenheit > 80):\n            return \"hot\";\n        case (temperature_fahrenheit > 140):\n            return \"alert: too hot\";\n        default:\n            return \"normal\";\n    }\n}"
      }
    ]
  },
  "debugInfo": {
    "request": {
      "authToken": "replaceWithAuthTokenFromCreateSession",
      "api": "admin",
      "action": "describeCodePackages",
      "params": {
        "databaseName": "faircom",
        "ownerName": "admin",
        "codeNames": [
          "convertTemperature"
        ],
        "codeFormat": "utf8 | base64 | hex | byteArray | json"
      },
      "debug": "max"
    }
  },
  "errorCode": 0,
  "errorMessage": ""
}
{
  "authToken": "replaceWithValidAuthToken",
  "result": {
    "data": [
      {
        "codeId": 4,
        "databaseName": "faircom",
        "ownerName": "admin",
        "codeName": "convertTemperature",
        "codeVersion": 2,
        "clonedCodeId": 0,
        "codeStatus": "deleted",
        "codeLanguage": "javascript",
        "codeType": "transform",
        "description": "New description replaces old description.\nAnother description line.",
        "metadata": {
          "keyword": "temperature",
          "favorites": true
        },
        "createdBy": "ADMIN",
        "createdOn": "2024-10-15T19:29:34.216",
        "updatedBy": "ADMIN",
        "updatedOn": "2024-10-15T19:56:49.879",
        "comment": "Modified the code and changed the name back",
        "codeFormat": "utf8",
        "code": "// The server runs this JavaScript code, which is registered in the server as a transform method.\nrecord.temperature_fahrenheit = record.source_payload.temperature\nrecord.temperature_celsius = getCelsiusFromFahrenheit(record.temperature_fahrenheit)\nrecord.temperature_status = calculateTemperatureStatus(record.temperature_fahrenheit)\n\nfunction getCelsiusFromFahrenheit(temperature_fahrenheit){\n    return (temperature_fahrenheit - 32) / 1.8;\n}\n\nfunction calculateTemperatureStatus(temperature_fahrenheit){\n    switch (true) {\n        case (temperature_fahrenheit < 0):\n            return \"alert: too cold\";\n        case (temperature_fahrenheit < 32):\n            return \"cold\";\n        case (temperature_fahrenheit > 80):\n            return \"hot\";\n        case (temperature_fahrenheit > 140):\n            return \"alert: too hot\";\n        default:\n            return \"normal\";\n    }\n}"
      }
    ]
  },
  "debugInfo": {
    "request": {
      "authToken": "replaceWithAuthTokenFromCreateSession",
      "api": "admin",
      "action": "describeCodePackages",
      "params": {
        "codeNames": [
          "convertTemperature"
        ]
      },
      "debug": "max"
    }
  },
  "errorCode": 0,
  "errorMessage": ""
}

Use the describeCodePackages API action to return all the current information about the specified code packages

API actionJSON ADMIN APIjsonActiondescribeCodePackagedescribeCodePackagesdescribesCodePackagedescribesCodePacakgesdescribe code packagecodepackage
Table 1. Params property summaries

Property

Description

Default

Type

Limits (inclusive)

databaseName

specifies the name of the database

Defaults to the session's "defaultDatabaseName" property

string

ownerName

specifies the name of the owner

Defaults to the session's "defaultOwnerName" property

string

codeName

specifies the name of the code package

Required - No default value

string

codeFormat

specifies the encoding of the code in the code property

"utf8"

string

"utf8"



"databaseName" is an optional string specifying the database name of the code package. It defaults to the session's "defaultDatabaseName" property when omitted or set to null. The package's unique identifier is the combination of "databaseName", "ownerName", and "codeName".

"ownerName" is an optional string specifying the account name that owns the code package. It defaults to the session's "defaultOwnerName" property when omitted or set to null. The package's unique identifier is the combination of "databaseName", "ownerName", and "codeName".

"codeName" is a required string containing the user-defined name for the code package. The package's unique identifier is the combination of "databaseName", "ownerName", and "codeName".

"codeFormat" is an optional string that specifies the encoding of code in the code property. You must encode you code to embed it in a JSON string. "codeFormat" currently only supports the "utf8" encoding, requiring you to use JSON rules to escape problem characters in your code with the \ backslash character, such as \n.