Skip to main content

"cloneCodePackage" (jsonAction)

JSON ADMIN "cloneCodePackage" action creates a new code package with a new name and copies an existing code package into it

The "cloneCodePackage" action creates a new code package with a new name and copies an existing code package into it. You can optionally modify the new code package's status and properties.

Request examples

Typical

{ 
  "api": "admin",
  "action": "cloneCodePackage",
  "params": {
    "databaseName": "faircom",
    "ownerName": "admin",
    "codeName": "convertTemperature",
    "newDatabaseName": "faircom",
    "newOwnerName": "admin",
    "newCodeName": "convertTemperature V2",
    "codeStatus": "developing",
    "comment": "optional change comment",
    "description": "optional new description",
    "metadata": {}
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}
{ 
  "api": "admin",
  "action": "cloneCodePackage",
  "params": {
    "codeName": "convertTemperature",
    "newCodeName": "convertAndCategorizeTemperature",
    "comment": "Cloned from convertTemperature"
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}
{
  "debugInfo": {
    "request": {
      "api": "admin",
      "action": "cloneCodePackage",
      "params": {
        "databaseName": "faircom",
        "ownerName": "admin",
        "codeName": "convertTemperature",
        "newDatabaseName": "faircom",
        "newOwnerName": "admin",
        "newCodeName": "convertTemperature V2",
        "codeStatus": "developing",
        "comment": "optional change comment",
        "description": "optional new description",
        "metadata": {}
      },
      "debug": "max",
      "authToken": "replaceWithAuthTokenFromCreateSession"
    }
  },
  "errorCode": 0,
  "errorMessage": "",
  "authToken": "replaceWithAuthTokenFromCreateSession"
}
{
  "debugInfo": {
    "request": {
      "api": "admin",
      "action": "cloneCodePackage",
      "params": {
        "codeName": "convertTemperature",
        "newCodeName": "convertAndCategorizeTemperature",
        "comment": "Cloned from convertTemperature"
      },
      "debug": "max",
      "authToken": "replaceWithAuthTokenFromCreateSession"
    }
  },
  "errorCode": 0,
  "errorMessage": "",
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

Use the cloneCodePackage API action to create a new code package with a new name and copies an existing code package into it

API actionJSON ADMIN APIjsonActioncloneCodePackagecloneCodePackagesclonesCodePackageclonesCodePackagesclone code packagecodepackage
Table 1. "params" property summaries

Property

Description

Default

Type

Limits (inclusive)

code

(optional) contains the source code stored in the server

""

string

codeFormat

(optional) specifies the encoding of the code in the code property

"utf8"

string

"utf8"

codeLanguage

specifies the programming language of the code in the "code" property

Required - No default value

string

"javascript"
"json"

codeName

specifies the name of the code package

Required - No default value

string

codeStatus

(optional) specifies the status of the code. The server only runs code with a status of "deprecated", "testing", or "active"

"developing"

string

"developing"
"deleted"
"inactive"
"deprecated"
"testing"
"active"

codeType

specifies how and where a FairCom server can run the JavaScript code

Required - No default value

string

"integrationTableTransform"
"getRecordsTransform"

comment

(optional) describes the latest change to the code

""

string

databaseName

(optional) specifies the name of the database

Defaults to the session's "defaultDatabaseName" property

string

description

(optional) describes the code package

""

string

metadata

(optional) contains user-defined properties that add keywords and tags about the code package

""

string

newCodeName

(optional) when specified, the server renames the code package to the new name

null

string

newDatabaseName

(optional) when specified, the server clones the code package into another database

null

string

newOwnerName

(optional) when specified, the server assigns the cloned code package to the new owner name

null

string

ownerName

(optional) specifies the name of the owner

Defaults to the session's "defaultOwnerName" property

string



"code" contains the source code. Before embedding it in a JSON string, encode the source code using the format specified in the "codeFormat" property.

"codeFormat" is an optional string that specifies the encoding of code in the code property. You must encode your 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.

"codeLanguage" is a required string. It is the programming language's name. Any string value is accepted. Currently, "javascript" and "json" are the only types of code the FairCom server can use.

"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".

"codeStatus" is optional and specifies a new status for the code. When you create a code package, it defaults to "developing". When you alter a code package, it defaults to the current state. You may set it to one of the following states: "developing", "deleted", "inactive", "deprecated", "testing", or "active". You can use "alterCodePackage" to transition from any state to any other. See "Use "codeStatus" to make a package runnable".

The "codeType" property defines how and where a FairCom server can run the JavaScript code. See Code Package Types for how to use each type of Code Package. The following enumerated values are supported:

"comment" is an optional string explaining the code change.

"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".

"description" is an optional string that describes the code package. The server indexes this field with a full-text index so that you can search for any word or phrase.

"metadata" contains user-defined properties that add keywords and tags about the code package. The server indexes this field with a full-text index so you can search for any word or phrase to find code packages.

"newCodeName" is an optional string. When present, the server renames the code package from the current "codeName" to the "newCodeName". The server does not change the "codeName" when null or omitted.

"newDatabaseName" is an optional string. When present, the server uses the new database as the target for the action. When null or omitted, the server runs the action in the current database.

"newOwnerName" is an optional string. When present, the server uses the new owner name as the target for the action. When null or omitted, the server runs the action using the current owner name.

"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".

Would you like to provide feedback?