文档目录

AccessKey相关接口

创建AccessKey(CreateAccessKey)

API请求

URLs
POST zstack/v1/accesskeys
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "accountUuid": "db517023502d34ef9309e49674af88d0",
    "userUuid": "019f0d7b414b31d98a8de6cab4a8b999"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"accountUuid":"db517023502d34ef9309e49674af88d0","userUuid":"019f0d7b414b31d98a8de6cab4a8b999"}}' http://localhost:8080/zstack/v1/accesskeys
参数列表
名字 类型 位置 描述 可选值 起始版本
accountUuid String body(包含在params结构中) 账户UUID 3.2.0
userUuid String body(包含在params结构中) 用户UUID 3.2.0
description (可选) String body(包含在params结构中) 资源的详细描述 3.2.0
AccessKeyID (可选) String body(包含在params结构中) 生成的AccessKeyID 3.7.0
AccessKeySecret (可选) String body(包含在params结构中) 生成的AccessKeySecret 3.7.0
resourceUuid (可选) String body(包含在params结构中) 3.2.0
systemTags (可选) List body 3.2.0
userTags (可选) List body 3.2.0

API返回

返回示例
{
  "inventory": {
    "uuid": "01f82a92a3f83136b3a5fa13b0f1dde6",
    "accountUuid": "bc81e5aad7363ebaa904ee81edbfdd1f",
    "userUuid": "20e90349268736d7950284d122f64213",
    "AccessKeyID": "1234567890abcdedfhij",
    "AccessKeySecret": "1234567890abcdedfhij1234567890abcdedfhij",
    "state": "Enabled"
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.2.0
inventory AccessKeyInventory 详情参考inventory 3.2.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.2.0
description String 错误的概要描述 3.2.0
details String 错误的详细信息 3.2.0
elaboration String 保留字段,默认为null 3.2.0
opaque LinkedHashMap 保留字段,默认为null 3.2.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.2.0
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.2.0
description String 资源的详细描述 3.2.0
accountUuid String 账户UUID 3.2.0
userUuid String 用户UUID 3.2.0
AccessKeyID String 3.2.0
AccessKeySecret String 3.2.0
createDate Timestamp 创建时间 3.2.0
lastOpDate Timestamp 最后一次修改时间 3.2.0
state AccessKeyState 详情参考state 3.2.0
#state
名字 类型 描述 起始版本
name String 资源名称 3.2.0
ordinal int 3.2.0

SDK示例

Java SDK
CreateAccessKeyAction action = new CreateAccessKeyAction();
action.accountUuid = "db517023502d34ef9309e49674af88d0";
action.userUuid = "019f0d7b414b31d98a8de6cab4a8b999";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateAccessKeyAction.Result res = action.call();
Python SDK
CreateAccessKeyAction action = CreateAccessKeyAction()
action.accountUuid = "db517023502d34ef9309e49674af88d0"
action.userUuid = "019f0d7b414b31d98a8de6cab4a8b999"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateAccessKeyAction.Result res = action.call()

删除AccessKey(DeleteAccessKey)

API请求

URLs
DELETE zstack/v1/accesskeys/{uuid}?deleteMode={deleteMode}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/accesskeys/7fcbb0096e3d3e2a8dd4f83610d3dac9?deleteMode=Permissive
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url AccessKey UUID,唯一标示该资源 3.2.0
deleteMode (可选) String url 3.2.0
systemTags (可选) List body 3.2.0
userTags (可选) List body 3.2.0

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK示例

Java SDK
DeleteAccessKeyAction action = new DeleteAccessKeyAction();
action.uuid = "7fcbb0096e3d3e2a8dd4f83610d3dac9";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteAccessKeyAction.Result res = action.call();
Python SDK
DeleteAccessKeyAction action = DeleteAccessKeyAction()
action.uuid = "7fcbb0096e3d3e2a8dd4f83610d3dac9"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteAccessKeyAction.Result res = action.call()

查询AccessKey(QueryAccessKey)

API请求

URLs
GET zstack/v1/accesskeys
GET zstack/v1/accesskeys/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/accesskeys?q=uuid=fc008e53779632989bf9393ecf074e25
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/accesskeys/f99c1aea4a6e35e4a88c6abfe11cce8d

可查询字段

运行CLI命令行工具,输入QueryAccessKey并按Tab键查看所有可查询字段以及可跨表查询的资源名。

API返回

返回示例
{
  "inventories": [
    {
      "uuid": "12be3dd32afa3cf2afa4c06037f218b7",
      "accountUuid": "324ecf74dd5c3b9a9f2b75edfdbd858f",
      "userUuid": "49c0bc4cfa6d3a67930fe4a4cc32248c",
      "AccessKeyID": "1234567890abcdedfhij",
      "AccessKeySecret": "1234567890abcdedfhij1234567890abcdedfhij",
      "state": "Enabled"
    }
  ]
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.2.0
inventories List 详情参考inventories 3.2.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.2.0
description String 错误的概要描述 3.2.0
details String 错误的详细信息 3.2.0
elaboration String 保留字段,默认为null 3.2.0
opaque LinkedHashMap 保留字段,默认为null 3.2.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.2.0
#inventories
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.2.0
description String 资源的详细描述 3.2.0
accountUuid String 账户UUID 3.2.0
userUuid String 用户UUID 3.2.0
AccessKeyID String 3.2.0
AccessKeySecret String 3.2.0
createDate Timestamp 创建时间 3.2.0
lastOpDate Timestamp 最后一次修改时间 3.2.0
state AccessKeyState 详情参考state 3.2.0
#state
名字 类型 描述 起始版本
name String 资源名称 3.2.0
ordinal int 3.2.0

SDK示例

Java SDK
QueryAccessKeyAction action = new QueryAccessKeyAction();
action.conditions = asList("uuid=f0c530f17978349faa8c4736accd0375");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryAccessKeyAction.Result res = action.call();
Python SDK
QueryAccessKeyAction action = QueryAccessKeyAction()
action.conditions = ["uuid=ee3c98b8528e3fe2aa9d817cd48b1358"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryAccessKeyAction.Result res = action.call()

开启或关闭AccessKey(ChangeAccessKeyState)

API请求

URLs
PUT zstack/v1/accesskeys/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "changeAccessKeyState": {
    "stateEvent": "disable"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"changeAccessKeyState":{"stateEvent":"disable"}}' http://localhost:8080/zstack/v1/accesskeys/2c9c06fee2513d4b81f1af281ab6bb7b/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url AccessKey UUID,唯一标示该资源 3.2.0
stateEvent String body(包含在changeAccessKeyState结构中) 开启或关闭
  • enable
  • disable
3.2.0
systemTags (可选) List body 3.2.0
userTags (可选) List body 3.2.0

API返回

返回示例
{
  "inventory": {
    "uuid": "defe79b1a43f35818dc6d3959b571773",
    "accountUuid": "d0c06c8d19f439b1b8f481dbdf3e3a3c",
    "userUuid": "b622d5d01ef63237878023e93ade5003",
    "AccessKeyID": "1234567890abcdedfhij",
    "AccessKeySecret": "1234567890abcdedfhij1234567890abcdedfhij",
    "state": "Enabled"
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.2.0
inventory AccessKeyInventory 详情参考inventory 3.2.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.2.0
description String 错误的概要描述 3.2.0
details String 错误的详细信息 3.2.0
elaboration String 保留字段,默认为null 3.2.0
opaque LinkedHashMap 保留字段,默认为null 3.2.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.2.0
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.2.0
description String 资源的详细描述 3.2.0
accountUuid String 账户UUID 3.2.0
userUuid String 用户UUID 3.2.0
AccessKeyID String 3.2.0
AccessKeySecret String 3.2.0
createDate Timestamp 创建时间 3.2.0
lastOpDate Timestamp 最后一次修改时间 3.2.0
state AccessKeyState 详情参考state 3.2.0
#state
名字 类型 描述 起始版本
name String 资源名称 3.2.0
ordinal int 3.2.0

SDK示例

Java SDK
ChangeAccessKeyStateAction action = new ChangeAccessKeyStateAction();
action.uuid = "2c9c06fee2513d4b81f1af281ab6bb7b";
action.stateEvent = "disable";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangeAccessKeyStateAction.Result res = action.call();
Python SDK
ChangeAccessKeyStateAction action = ChangeAccessKeyStateAction()
action.uuid = "2c9c06fee2513d4b81f1af281ab6bb7b"
action.stateEvent = "disable"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ChangeAccessKeyStateAction.Result res = action.call()
开发手册 | 5.4.12 | ZStack Cloud · ZCF | ZStack 资源中心