SSH Key Operations
GenerateSshKeyPair
API Request
URLs
POST zstack/v1/ssh-key-pair/generateHeaders
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"params": {
"name": "ssh-key-pair",
"description": "description"
},
"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":"ssh-key-pair","description":"description"}}'
http://localhost:8080/zstack/v1/ssh-key-pair/generateRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| name | String | body (contained in the params structure) | The resource name. | 4.7.21 | |
| description | String | body (contained in the params structure) | Optional. Optional. The detailed description of the resource. | 4.7.21 | |
| systemTags | List | body | Optional. The system tags. | 4.7.21 | |
| userTags | List | body | Optional. The user tags. | 4.7.21 |
API Response
Sample
Response
{
"inventory": {
"uuid": "25d8c1517825305f9dbcfd5413197faf",
"name": "ssh-key-pair",
"publicKey": "ssh-public-key",
"privateKey": "ssh-private-key"
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | 4.7.21 | |
| inventory | SshPrivateKeyPairInventory | See inventory. | 4.7.21 |
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 4.7.21 |
#error
| 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. | 4.7.21 |
| description | String | The brief description of the error. | 4.7.21 |
| details | String | The details about the error. | 4.7.21 |
| elaboration | String | The reserved field. Default value: null. | 4.7.21 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 4.7.21 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 4.7.21 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 4.7.21 |
| name | String | The resource name. | 4.7.21 |
| description | String | Optional. The detailed description of the resource. | 4.7.21 |
| publicKey | String | 4.7.21 | |
| createDate | Timestamp | The creation date. | 4.7.21 |
| lastOpDate | Timestamp | The last operation date. | 4.7.21 |
| privateKey | String | 4.7.21 |
SDK Sample
Java
SDK
GenerateSshKeyPairAction action = new GenerateSshKeyPairAction();
action.name = "ssh-key-pair";
action.description = "description";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GenerateSshKeyPairAction.Result res = action.call();Python
SDK
GenerateSshKeyPairAction action = GenerateSshKeyPairAction()
action.name = "ssh-key-pair"
action.description = "description"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GenerateSshKeyPairAction.Result res = action.call()CreateSshKeyPair
API Request
URLs
POST zstack/v1/ssh-key-pairHeaders
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"params": {
"name": "ssh-key-pair",
"description": "description",
"publicKey": ""
},
"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":"ssh-key-pair","description":"description","publicKey":""}}'
http://localhost:8080/zstack/v1/ssh-key-pairRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| name | String | body (contained in the params structure) | The resource name. | 4.7.21 | |
| description | String | body (contained in the params structure) | Optional. Optional. The detailed description of the resource. | 4.7.21 | |
| publicKey | String | body (contained in the params structure) | 4.7.21 | ||
| resourceUuid | String | body (contained in the params structure) | Optional.The resource UUID. | 4.7.21 | |
| tagUuids | List | body (contained in the params structure) | Optional. The tag UUID list. | 4.7.21 | |
| systemTags | List | body | Optional. The system tags. | 4.7.21 | |
| userTags | List | body | Optional. The user tags. | 4.7.21 |
API Response
Sample
Response
{
"inventory": {
"uuid": "87460bc213b534ecaceda5a510a13771",
"name": "ssh-key-pair",
"publicKey": ""
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | 4.7.21 | |
| inventory | SshKeyPairInventory | See inventory. | 4.7.21 |
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 4.7.21 |
#error
| 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. | 4.7.21 |
| description | String | The brief description of the error. | 4.7.21 |
| details | String | The details about the error. | 4.7.21 |
| elaboration | String | The reserved field. Default value: null. | 4.7.21 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 4.7.21 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 4.7.21 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 4.7.21 |
| name | String | The resource name. | 4.7.21 |
| description | String | Optional. The detailed description of the resource. | 4.7.21 |
| publicKey | String | 4.7.21 | |
| createDate | Timestamp | The creation date. | 4.7.21 |
| lastOpDate | Timestamp | The last operation date. | 4.7.21 |
SDK Sample
Java
SDK
CreateSshKeyPairAction action = new CreateSshKeyPairAction();
action.name = "ssh-key-pair";
action.description = "description";
action.publicKey = "";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateSshKeyPairAction.Result res = action.call();Python
SDK
CreateSshKeyPairAction action = CreateSshKeyPairAction()
action.name = "ssh-key-pair"
action.description = "description"
action.publicKey = ""
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateSshKeyPairAction.Result res = action.call()DeleteSshKeyPair
API Request
URLs
DELETE zstack/v1/ssh-key-pair/{uuid}Headers
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/ssh-key-pair/67560ca0fb1d35b7bd520d43e2cbacee?
http://localhost:8080/zstack/v1/ssh-key-pair/67560ca0fb1d35b7bd520d43e2cbacee?Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 4.7.21 | |
| systemTags | List | body | Optional. The system tags. | 4.7.21 | |
| userTags | List | body | Optional. The user tags. | 4.7.21 |
API Response
When the API succeeded, an empty JSON structure {} is returned. When the API
failed, the returned JSON structure includes an error field. For
example,
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Sample
Java
SDK
DeleteSshKeyPairAction action = new DeleteSshKeyPairAction();
action.uuid = "67560ca0fb1d35b7bd520d43e2cbacee";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteSshKeyPairAction.Result res = action.call();Python
SDK
DeleteSshKeyPairAction action = DeleteSshKeyPairAction()
action.uuid = "67560ca0fb1d35b7bd520d43e2cbacee"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteSshKeyPairAction.Result res = action.call()QuerySshKeyPair
API Request
URLs
GET zstack/v1/ssh-key-pair
GET zstack/v1/ssh-key-pair/{uuid}Headers
Authorization: OAuth the-session-uuidCurl
Sample
curl -H "Content-Type: application/json;charset=UTF-8"
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c"
-X GET http://localhost:8080/zstack/v1/ssh-key-pair?q=uuid=1d1c2b759ab23353946035b266bd2ac1
curl -H "Content-Type: application/json;charset=UTF-8"
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c"
-X GET http://localhost:8080/zstack/v1/ssh-key-pair/085e223844b03474a590f5877b53e0c8
Queryable Fields
You can check all queryable fields and resource names that can be queried across tables by using zstack-cli, entering QuerySshKeyPair, and pressing the Tab key.
API Response
Sample
Response
{
"inventories": [
{
"uuid": "f289105c96f230e9a8add069c3a1bd69",
"name": "ssh-key-pair",
"publicKey": ""
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | 4.7.21 | |
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, See error. | 4.7.21 |
| inventories | List | See inventory. | 4.7.21 |
#error
| 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. | 4.7.21 |
| description | String | The brief description of the error. | 4.7.21 |
| details | String | The details about the error. | 4.7.21 |
| elaboration | String | The reserved field. Default value: null. | 4.7.21 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 4.7.21 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 4.7.21 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 4.7.21 |
| name | String | The resource name. | 4.7.21 |
| description | String | Optional. The detailed description of the resource. | 4.7.21 |
| publicKey | String | 4.7.21 | |
| createDate | Timestamp | The creation date. | 4.7.21 |
| lastOpDate | Timestamp | The last operation date. | 4.7.21 |
SDK Sample
Java
SDK
QuerySshKeyPairAction action = new QuerySshKeyPairAction();
action.conditions = asList("uuid=a37de2994dcb3f21bc084b67f3608849");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QuerySshKeyPairAction.Result res = action.call();Python
SDK
QuerySshKeyPairAction action = QuerySshKeyPairAction()
action.conditions = ["uuid=de52ff419e82330f8c0d7415ed53469a"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QuerySshKeyPairAction.Result res = action.call()UpdateSshKeyPair
API Request
URLs
PUT zstack/v1/ssh-key-pair/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"updateSshKeyPair": {
"name": "ssh-key-pair",
"description": "description"
},
"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 PUT -d '{"updateSshKeyPair":{"name":"ssh-key-pair","description":"description"}}'
http://localhost:8080/zstack/v1/ssh-key-pair/ec2724093b1a3da8bf040dff4c9c1adb/actionsRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 4.7.21 | |
| name | String | body (contained in the updateSshKeyPair structure) | Optional. The resource name. | 4.7.21 | |
| description | String | body (contained in the updateSshKeyPair structure) | Optional. Optional. The detailed description of the resource. | 4.7.21 | |
| systemTags | List | body | Optional. The system tags. | 4.7.21 | |
| userTags | List | body | Optional. The user tags. | 4.7.21 |
API Response
Sample
Response
{
"inventory": {
"uuid": "15565277de143faea29e6fcc571c4d1d",
"name": "ssh-key-pair",
"publicKey": ""
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | 4.7.21 | |
| inventory | SshKeyPairInventory | See inventory | 4.7.21 |
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error | 4.7.21 |
#error
| 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. | 4.7.21 |
| description | String | The brief description of the error. | 4.7.21 |
| details | String | The details about the error. | 4.7.21 |
| elaboration | String | The reserved field. Default value: null. | 4.7.21 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 4.7.21 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 4.7.21 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 4.7.21 |
| name | String | The resource name. | 4.7.21 |
| description | String | Optional. The detailed description of the resource. | 4.7.21 |
| publicKey | String | 4.7.21 | |
| createDate | Timestamp | The creation date. | 4.7.21 |
| lastOpDate | Timestamp | The last operation date. | 4.7.21 |
SDK Sample
Java
SDK
UpdateSshKeyPairAction action = new UpdateSshKeyPairAction();
action.uuid = "ec2724093b1a3da8bf040dff4c9c1adb";
action.name = "ssh-key-pair";
action.description = "description";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateSshKeyPairAction.Result res = action.call();Python
SDK
UpdateSshKeyPairAction action = UpdateSshKeyPairAction()
action.uuid = "ec2724093b1a3da8bf040dff4c9c1adb"
action.name = "ssh-key-pair"
action.description = "description"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateSshKeyPairAction.Result res = action.call()AttachSshKeyPairToVmInstance
API Request
URLs
POST zstack/ssh-key-pair/{sshKeyPairUuid}/vm-instance/{vmInstanceUuid}Headers
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"params": {},
"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":{}}'
http://localhost:8080/zstack/v1/ssh-key-pair/9d4fe97b6e0a3d65bca85b093e74d6c9/vm-instance/e76f9792afac3bca8aec7a5d4e768197Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| vmInstanceUuid | String | url | The VM instance UUID. | 4.7.21 | |
| sshKeyPairUuid | String | url | 4.7.21 | ||
| systemTags | List | body | Optional. The system tags. | 4.7.21 | |
| userTags | List | body | Optional. The user tags. | 4.7.21 |
API Response
Sample
Response
{
"inventory": {
"uuid": "03da892de78c34d8b13e210d068caa8a",
"name": "ssh-key-pair",
"publicKey": ""
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | 4.7.21 | |
| inventory | SshKeyPairInventory | See inventory. | 4.7.21 |
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 4.7.21 |
#error
| 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. | 4.7.21 |
| description | String | The brief description of the error. | 4.7.21 |
| details | String | The details about the error. | 4.7.21 |
| elaboration | String | The reserved field. Default value: null. | 4.7.21 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 4.7.21 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 4.7.21 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 4.7.21 |
| name | String | The resource name. | 4.7.21 |
| description | String | Optional. The detailed description of the resource. | 4.7.21 |
| publicKey | String | 4.7.21 | |
| createDate | Timestamp | The creation date. | 4.7.21 |
| lastOpDate | Timestamp | The last operation date. | 4.7.21 |
SDK Sample
Java
SDK
AttachSshKeyPairToVmInstanceAction action = new AttachSshKeyPairToVmInstanceAction();
action.vmInstanceUuid = "e76f9792afac3bca8aec7a5d4e768197";
action.sshKeyPairUuid = "9d4fe97b6e0a3d65bca85b093e74d6c9";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AttachSshKeyPairToVmInstanceAction.Result res = action.call();Python
SDK
AttachSshKeyPairToVmInstanceAction action = AttachSshKeyPairToVmInstanceAction()
action.vmInstanceUuid = "e76f9792afac3bca8aec7a5d4e768197"
action.sshKeyPairUuid = "9d4fe97b6e0a3d65bca85b093e74d6c9"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AttachSshKeyPairToVmInstanceAction.Result res = action.call()DetachSshKeyPairFromVmInstance
API Request
URLs
DELETE zstack/v1/ssh-key-pair/{sshKeyPairUuid}/vm-instance/{vmInstanceUuid}Headers
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"params": {},
"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 DELETE
http://localhost:8080/zstack/v1/ssh-key-pair/9be9cb6b56b13746a99660a0d07a0770/vm-instance/dd734d0cd5c53bcca48cec9d2b4aa6d6?Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| vmInstanceUuid | String | url | The VM instance UUID. | 4.7.21 | |
| sshKeyPairUuid | String | url | 4.7.21 | ||
| systemTags | List | body | Optional. The system tags. | 4.7.21 | |
| userTags | List | body | Optional. The user tags. | 4.7.21 |
API Response
When the API succeeded, an empty JSON structure {} is returned. When the API
failed, the returned JSON structure includes an error field. For
example,
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Sample
Java
SDK
DetachSshKeyPairFromVmInstanceAction action = new DetachSshKeyPairFromVmInstanceAction();
action.vmInstanceUuid = "dd734d0cd5c53bcca48cec9d2b4aa6d6";
action.sshKeyPairUuid = "9be9cb6b56b13746a99660a0d07a0770";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DetachSshKeyPairFromVmInstanceAction.Result res = action.call();Python
SDK
DetachSshKeyPairFromVmInstanceAction action = DetachSshKeyPairFromVmInstanceAction()
action.vmInstanceUuid = "dd734d0cd5c53bcca48cec9d2b4aa6d6"
action.sshKeyPairUuid = "9be9cb6b56b13746a99660a0d07a0770"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DetachSshKeyPairFromVmInstanceAction.Result res = action.call()