ZStack Cloud Platform
Single Server, Free Trial for One Year
POST zstack/v1/scriptsAuthorization: OAuth the-session-uuid{ "params": { "name": "script1", "description": "this is a script", "scriptContent": "ZWNobyBoZWxsb3dvcmxkCg\u003d\u003d", "renderParams": "[{\"key\":\"key\",\"value\":\"value\",\"description\":\"description\"}]", "platform": "Linux", "scriptType": "Shell", "scriptTimeout": 30 }, "systemTags": [], "userTags": [] }
Note: In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X POST -d '{"params":{"name":"script1","description":"this is a script","scriptContent":"ZWNobyBoZWxsb3dvcmxkCg==","renderParams":"[{\"key\":\"key\",\"value\":\"value\",\"description\":\"description\"}]","platform":"Linux","scriptType":"Shell","scriptTimeout":30}}' http://localhost:8080/zstack/v1/scripts | Name | Type | Location | Description | Valid Values | Starting Version |
|---|---|---|---|---|---|
| name | String | body (contained in the params structure) | The resource name. | 5.2.0 | |
| description | String | body (contained in the params structure) | Optional. The detailed description of the resource. | 5.2.0 | |
| scriptContent | String | body (contained in the params structure) | The script content. | 5.2.0 | |
| renderParams | String | body (contained in the params structure) | Optional. The custom parameters. | 5.2.0 | |
| platform | String | body (contained in the params structure) | The platform. |
| 5.2.0 |
| scriptType | String | body (contained in the params structure) | The script type. |
| 5.2.0 |
| scriptTimeout | int | body (contained in the params structure) | Optional. The timeout period. | 5.2.0 | |
| resourceUuid | String | body (contained in the params structure) | Optional. The resource UUID. | 5.2.0 | |
| tagUuids | List | body (contained in the params structure) | Optional. The tag UUID list. | 5.2.0 | |
| systemTags | List | body | Optional. The system tags. | 5.2.0 | |
| userTags | List | body | Optional. The user tags. | 5.2.0 |
{ "inventory": { "uuid": "a90f02b86916371a87bb5f2716dbfc0c", "name": "script1", "description": "this is a script", "scriptContent": "echo helloworld", "renderParams": "[{\"key\":\"key\",\"value\":\"value\",\"description\":\"description\"}]", "platform": "Linux", "scriptType": "Shell", "scriptTimeout": 30, "createDate": "Sep 23, 2024 11:53:59 AM", "lastOpDate": "Sep 23, 2024 11:53:59 AM" } }| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | 5.2.0 | |
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error | 5.2.0 |
| inventory | GuestVmScriptInventory | See inventory | 5.2.0 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 5.2.0 |
| description | String | The brief description of the error. | 5.2.0 |
| details | String | The details about the error. | 5.2.0 |
| elaboration | String | The reserved field. Default value: null. | 5.2.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 5.2.0 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 5.2.0 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 5.2.0 |
| name | String | The resource name. | 5.2.0 |
| description | String | The detailed description of the resource. | 5.2.0 |
| scriptContent | String | The script content. | 5.2.0 |
| renderParams | String | The custom parameters. | 5.2.0 |
| platform | String | The platform | 5.2.0 |
| scriptType | String | The script type. | 5.2.0 |
| scriptTimeout | Integer | The timeout period. | 5.2.0 |
| createDate | Timestamp | The creation time. | 5.2.0 |
| lastOpDate | Timestamp | The last operation time. | 5.2.0 |
CreateGuestVmScriptAction action = new CreateGuestVmScriptAction(); action.name = "script1"; action.description = "this is a script"; action.scriptContent = "ZWNobyBoZWxsb3dvcmxkCg=="; action.renderParams = "[{"key":"key","value":"value","description":"description"}]"; action.platform = "Linux"; action.scriptType = "Shell"; action.scriptTimeout = 30; action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"; CreateGuestVmScriptAction.Result res = action.call();CreateGuestVmScriptAction action = CreateGuestVmScriptAction() action.name = "script1" action.description = "this is a script" action.scriptContent = "ZWNobyBoZWxsb3dvcmxkCg==" action.renderParams = "[{"key":"key","value":"value","description":"description"}]" action.platform = "Linux" action.scriptType = "Shell" action.scriptTimeout = 30 action.sessionId = "b86c9016b4f24953a9edefb53ca0678c" CreateGuestVmScriptAction.Result res = action.call()DELETE zstack/v1/scripts/{uuid}Authorization: OAuth the-session-uuidCurl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X DELETE http://localhost:8080/zstack/v1/scripts/ed1ef717239e37c29163dcad7576b8d4 | Name | Type | Location | Description | Valid Values | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 5.2.0 | |
| deleteMode | String | body | The deletion mode. |
| 5.2.0 |
| systemTags | List | body | Optional. The system tags. | 5.2.0 | |
| userTags | List | body | Optional. The user tags. | 5.2.0 |
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }DeleteGuestVmScriptAction action = new DeleteGuestVmScriptAction(); action.uuid = "ed1ef717239e37c29163dcad7576b8d4"; action.deleteMode = "Permissive"; action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"; DeleteGuestVmScriptAction.Result res = action.call();DeleteGuestVmScriptAction action = DeleteGuestVmScriptAction() action.uuid = "ed1ef717239e37c29163dcad7576b8d4" action.deleteMode = "Permissive" action.sessionId = "b86c9016b4f24953a9edefb53ca0678c" DeleteGuestVmScriptAction.Result res = action.call()