system.config.copy
This function is used in Python Scripting.
Description​
Copies a resource to a new name and/or collection. When using this function, either the newName or newCollection parameter must be defined.
Client Permission Restrictions​
This scripting function has no Client Permission restrictions.
Syntax​
system.config.copy(*moduleId, typeId, [name], [collection], [newName], [newCollection], signature, [actor])
An asterisk indicates that all parameters following it are expecting keywords when the function is being called in your script. This means that, when using an asterisk-marked parameter, both the parameter and argument must be specified. For example, moduleId="ignition".
Parameters​
| Type | Parameter | Description |
|---|---|---|
| String | *moduleId | The module ID portion of the resource type identifier. |
| String | *typeId | The type ID portion of the resource type identifier. |
| String | *name | The name of the resource. Required for named resources, but must be omitted for singleton resources. [Optional] |
| String | *collection | The collection containing the resource. If omitted, uses the active definition. [Optional] |
| String | *newName | The new name for the copied resource. Required if not changing collection for named resource types. [Optional] |
| String | *newCollection | The new collection for the copied resource. Required if not changing name for singleton resource types. [Optional] |
| String | *signature | The hex-encoded signature of the resource. |
| String | *actor | A string identifying the actor performing the operation. If not specified, an identifier will be automatically generated. [Optional] |
Returns​
PyResource - A PyResource containing the specified parameter attributes of an existing Gateway resource, which can also be read as plain Python properties.
Scope​
Gateway
Code Examples​
# This example takes a database connection from the core collection and
# copies it into a collection called "dev".
# Get the required signature argument from your resource using system.config.getResource()
moduleId = "ignition"
typeId = "database-connection"
name = "MySQL"
# Use the getResource() function
myResource = system.config.getResource(moduleId=moduleId, typeId=typeId, name=name)
# Declare the new collection location variable and the resource signature
newCollection = "dev"
signature = myResource.signature
# Use the copy() function
system.config.copy(moduleId=moduleId, typeId=typeId, name=name, newCollection=newCollection, signature=signature)