用户配置相关接口
创建账户(CreateAccount)
创建账户
API请求
URLs
POST zstack/v1/accountsHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "test",
"password": "password",
"state": "Enabled"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X POST -d '{"params":{"name":"test","password":"password","state":"Enabled"}}' http://localhost:8080/zstack/v1/accounts参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在params结构中) |
资源名称 | 0.6 | |
| password | String | body(包含在params结构中) |
密码 | 0.6 | |
| type (可选) | String | body(包含在params结构中) |
账户类型 |
|
0.6 |
| description (可选) | String | body(包含在params结构中) |
资源的详细描述 | 0.6 | |
| resourceUuid (可选) | String | body(包含在params结构中) |
资源UUID | 0.6 | |
| systemTags (可选) | List | body | 系统标签 | 0.6 | |
| userTags (可选) | List | body | 用户标签 | 0.6 | |
| tagUuids (可选) | List | body(包含在params结构中) |
标签UUID列表 | 3.4.0 | |
| state (可选) | String | body(包含在params结构中) |
账户状态 |
|
4.3.0 |
API返回
返回示例
{
"inventory": {
"uuid": "77dc15220f71377ea48fa520d40d9169",
"name": "test",
"type": "Normal"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventory | AccountInventory | 详情参考inventory | 0.6 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 账户的UUID,唯一标示该资源 | 4.0.0 |
| name | String | 账户名称 | 4.0.0 |
| description | String | 账户的详细描述 | 4.0.0 |
| type | String | 账户类型 | 4.0.0 |
| source | String | 账户来源,创建时确定且不可修改 | 5.1.0 |
| state | String | 账户状态 | 4.0.0 |
| createDate | Timestamp | 创建时间 | 4.0.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.0.0 |
SDK示例
Java SDK
CreateAccountAction action = new CreateAccountAction();
action.name = "test";
action.password = "password";
action.state = "Enabled";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateAccountAction.Result res = action.call();Python SDK
action = CreateAccountAction()
action.name = "test"
action.password = "password"
action.state = "Enabled"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()删除账户(DeleteAccount)
API请求
URLs
DELETE zstack/v1/accounts/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/accounts/0f4d2956d5ef35fc9c51ca45b09ba2bb参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 0.6 | |
| deleteMode (可选) | String | body | 删除模式 | 0.6 | |
| systemTags (可选) | List | body | 系统标签 | 0.6 | |
| userTags (可选) | List | body | 用户标签 | 0.6 |
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
DeleteAccountAction action = new DeleteAccountAction();
action.uuid = "0f4d2956d5ef35fc9c51ca45b09ba2bb";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteAccountAction.Result res = action.call();Python
SDK
DeleteAccountAction action = DeleteAccountAction()
action.uuid = "0f4d2956d5ef35fc9c51ca45b09ba2bb"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteAccountAction.Result res = action.call()更新账户(UpdateAccount)
更新账户
API请求
URLs
PUT zstack/v1/accounts/{uuid}Headers
Authorization: OAuth the-session-uuidBody
{
"updateAccount": {
"password": "updatepassword",
"name": "updatename"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X PUT -d '{"updateAccount":{"password":"updatepassword","name":"updatename"}}' http://localhost:8080/zstack/v1/accounts/99fcb2ad540c36f09e87c820ac6cb4cb参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 0.6 | |
| password (可选) | String | body(包含在updateAccount结构中) |
密码 | 0.6 | |
| name (可选) | String | body(包含在updateAccount结构中) |
账户名称 | 0.6 | |
| description (可选) | String | body(包含在updateAccount结构中) |
资源的详细描述 | 0.6 | |
| systemTags (可选) | List | body | 系统标签 | 0.6 | |
| userTags (可选) | List | body | 用户标签 | 0.6 | |
| oldPassword (可选) | String | body(包含在updateAccount结构中) |
原来使用的密码 | 3.6.0 | |
| state (可选) | String | body(包含在updateAccount结构中) |
账户状态 |
|
4.3.0 |
API返回
返回示例
{
"inventory": {
"uuid": "ffbf2fac53b83b838d4551edcaff1d39",
"name": "test",
"type": "Normal"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventory | AccountInventory | 详情参考inventory | 0.6 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 账户的UUID,唯一标示该资源 | 4.0.0 |
| name | String | 账户名称 | 4.0.0 |
| description | String | 账户的详细描述 | 4.0.0 |
| type | String | 账户类型 | 4.0.0 |
| source | String | 账户来源,创建时确定且不可修改 | 5.1.0 |
| state | String | 账户状态 | 4.0.0 |
| createDate | Timestamp | 创建时间 | 4.0.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.0.0 |
SDK示例
Java SDK
UpdateAccountAction action = new UpdateAccountAction();
action.uuid = "99fcb2ad540c36f09e87c820ac6cb4cb";
action.password = "updatepassword";
action.name = "updatename";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateAccountAction.Result res = action.call();Python SDK
action = UpdateAccountAction()
action.uuid = "99fcb2ad540c36f09e87c820ac6cb4cb"
action.password = "updatepassword"
action.name = "updatename"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()查询账户(QueryAccount)
查询账户
API请求
URLs
GET zstack/v1/accounts
GET zstack/v1/accounts/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X GET http://localhost:8080/zstack/v1/accounts?q=name=testcurl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X GET http://localhost:8080/zstack/v1/accounts/fa37d4ea030937b797cb97b2ea09840b可查询字段
运行CLI命令行工具,输入QueryAccount并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"uuid": "5c4b1e96b2833c2db31c5d7f175c817d",
"name": "test",
"type": "Normal"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventories | List | 详情参考inventories | 0.6 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 账户的UUID,唯一标示该资源 | 4.0.0 |
| name | String | 账户名称 | 4.0.0 |
| description | String | 账户的详细描述 | 4.0.0 |
| type | String | 账户类型 | 4.0.0 |
| source | String | 账户来源,创建时确定且不可修改 | 5.1.0 |
| state | String | 账户状态 | 4.0.0 |
| createDate | Timestamp | 创建时间 | 4.0.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.0.0 |
SDK示例
Java SDK
QueryAccountAction action = new QueryAccountAction();
action.conditions = asList("name=test");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryAccountAction.Result res = action.call();Python SDK
action = QueryAccountAction()
action.conditions = ["name=test"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()使用账户身份登录(LogInByAccount)
API请求
URLs
PUT zstack/v1/accounts/loginBody
{
"logInByAccount": {
"accountName": "test",
"password": "password",
"captchaUuid": "39bd748906ad301793c64f688dc197a9",
"verifyCode": "test"
},
"systemTags": [],
"userTags": []
}
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-X PUT -d '{"logInByAccount":{"accountName":"test","password":"password","captchaUuid":"39bd748906ad301793c64f688dc197a9","verifyCode":"test"}}' \
http://localhost:8080/zstack/v1/accounts/login参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| accountName | String | body(包含在logInByAccount结构中) | 账户名称 | 0.6 | |
| password | String | body(包含在logInByAccount结构中) | 密码 | 0.6 | |
| captchaUuid (可选) | String | body(包含在logInByAccount结构中) | 验证码UUID | 2.6.0 | |
| verifyCode (可选) | String | body(包含在logInByAccount结构中) | 验证码 | 2.6.0 | |
| clientInfo (可选) | Map | body(包含在logInByAccount结构中) | 客户端信息 | 3.5.0 | |
| systemTags (可选) | List | body | 系统标签 | 0.6 | |
| userTags (可选) | List | body | 用户标签 | 0.6 | |
| accountType (可选) | String | body(包含在logInByAccount结构中) |
3.4.0 |
API返回
返回示例
{
"inventory": {
"uuid": "5d77893e242d39ec8b9856a7b8762eab",
"accountUuid": "7ab57f322e4a396b8124ed4fda810966",
"expiredDate": "Nov 14, 2017 2:20:57 PM",
"noSessionEvaluation": false
}
}#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 0.6 |
| accountUuid | String | 账户UUID | 0.6 |
| userUuid | String | 用户UUID | 0.6 |
| expiredDate | Timestamp | 会话过期日期 | 0.6 |
| createDate | Timestamp | 创建时间 | 0.6 |
SDK示例
Java
SDK
LogInByAccountAction action = new LogInByAccountAction();
action.accountName = "test";
action.password = "password";
action.captchaUuid = "39bd748906ad301793c64f688dc197a9";
action.verifyCode = "test";
LogInByAccountAction.Result res = action.call();
Python
SDK
LogInByAccountAction action = LogInByAccountAction()
action.accountName = "test"
action.password = "password"
action.captchaUuid = "39bd748906ad301793c64f688dc197a9"
action.verifyCode = "test"
LogInByAccountAction.Result res = action.call()
为ZCenter账户创建会话(CreateSessionForZCenterAccount)
为 ZCenter 账户创建会话
API请求
URLs
POST zstack/v1/zcenter/accounts/sessionsHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"accountName": "test1",
"source": "Local"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X POST -d '{"params":{"accountName":"test1","source":"Local"}}' http://localhost:8080/zstack/v1/zcenter/accounts/sessions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| accountUuid (可选) | String | body(包含在params结构中) |
账户UUID | 5.1.0 | |
| accountName (可选) | String | body(包含在params结构中) |
账户名称 | 5.1.0 | |
| source (可选) | String | body(包含在params结构中) |
账户来源 |
|
5.1.0 |
| systemTags (可选) | List | body | 系统标签 | 5.1.0 | |
| userTags (可选) | List | body | 用户标签 | 5.1.0 |
API返回
返回示例
{
"inventory": {
"uuid": "ff06305f62fd3b17a7e2c67628a08700",
"accountUuid": "ff0b33166633399aae77ea258d2f7900",
"expiredDate": "Nov 15, 2017 2:20:57 PM",
"createDate": "Nov 14, 2017 2:20:57 PM",
"noSessionEvaluation": false
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 创建是否成功 | 5.1.0 |
| inventory | SessionInventory | 详情参考inventory | 5.1.0 |
| error | ErrorCode | 详情参考error | 5.1.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 0.6 |
| accountUuid | String | 账户UUID | 0.6 |
| userUuid | String | 用户UUID | 0.6 |
| expiredDate | Timestamp | 0.6 | |
| createDate | Timestamp | 创建时间 | 0.6 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
SDK示例
Java SDK
CreateSessionForZCenterAccountAction action = new CreateSessionForZCenterAccountAction();
action.accountName = "test1";
action.source = "Local";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateSessionForZCenterAccountAction.Result res = action.call();Python SDK
action = CreateSessionForZCenterAccountAction()
action.accountName = "test1"
action.source = "Local"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()获取登录验证码(GetLoginCaptcha)
API请求
URLs
GET zstack/v1/login/control/captchaCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/zstack/v1/login/control/captcha?resourceName=admin&loginType=Test参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| resourceName | String | query | 资源名称 | 2.6.0 | |
| loginType | String | query | 登录类型 | 2.6.0 | |
| systemTags (可选) | List | query | 系统标签 | 2.6.0 | |
| userTags (可选) | List | query | 用户标签 | 2.6.0 | |
| captchaUuid (可选) | String | query | 0.6 |
API返回
返回示例
{
"captchaUuid": "ff0c9fd9ea99333aa9f47cf61b5f0900",
"captcha": "test"
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| captchaUuid | String | 验证码的唯一标识符 | 2.6.0 |
| captcha | String | 验证码图片的base64形式 | 2.6.0 |
| success | boolean | 2.6.0 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 2.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 2.6.0 |
| description | String | 错误的概要描述 | 2.6.0 |
| details | String | 错误的详细信息 | 2.6.0 |
| elaboration | String | 保留字段,默认为null | 2.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 2.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 2.6.0 |
SDK示例
Java SDK
GetLoginCaptchaAction action = new GetLoginCaptchaAction();
action.resourceName = "admin";
action.loginType = "Test";
GetLoginCaptchaAction.Result res = action.call();Python SDK
action = GetLoginCaptchaAction()
action.resourceName = "admin"
action.loginType = "Test"
res = action.call()刷新验证码(RefreshCaptcha)
API请求
URLs
GET zstack/v1/captcha/refreshCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/zstack/v1/captcha/refresh参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | query | 资源的UUID,唯一标示该资源 | 2.6.0 | |
| systemTags (可选) | List | query | 2.6.0 | ||
| userTags (可选) | List | query | 2.6.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
RefreshCaptchaAction action = new RefreshCaptchaAction();
RefreshCaptchaAction.Result res = action.call();Python
SDK
RefreshCaptchaAction action = RefreshCaptchaAction()
RefreshCaptchaAction.Result res = action.call()获取双因子认证密钥(GetTwoFactorAuthenticationSecret)
API请求
URLs
GET zstack/v1/twofactorauthentication/secretCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-X GET http://localhost:8080/zstack/v1/twofactorauthentication/secret?name=user1&password=password&type=account参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | query | 资源名称 | 4.10.0 | |
| password | String | query | 4.10.0 | ||
| captchaUuid (可选) | String | query | 4.10.0 | ||
| verifyCode (可选) | String | query | 4.10.0 | ||
| systemTags (可选) | List | query | 4.10.0 | ||
| userTags (可选) | List | query | 4.10.0 | ||
| type | String | query |
|
5.0.0 |
API返回
返回示例
{
"inventory": {
"uuid": "7870dee14bdb328c9eb6635f4f494fdd",
"secret": "ABCDEFGH12345678",
"status": "NewCreated",
"userType": "AccountVO"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 2.6.0 |
| inventory | TwoFactorAuthenticationSecretInventory | 详情参考inventory | 2.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 2.6.0 |
| description | String | 错误的概要描述 | 2.6.0 |
| details | String | 错误的详细信息 | 2.6.0 |
| elaboration | String | 保留字段,默认为null | 2.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 2.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 2.6.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 2.6.0 |
| secret | String | 双因子认证密钥 | 2.6.0 |
| createDate | Timestamp | 创建时间 | 3.4.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.4.0 |
| userUuid | String | 用户UUID | 3.4.0 |
| userType | String | 3.4.0 | |
| status | TwoFactorAuthenticationSecretStatus | 详情参考status | 3.4.0 |
#status
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 3.4.0 |
| ordinal | int | 3.4.0 |
SDK示例
Java SDK
GetTwoFactorAuthenticationSecretAction action = new GetTwoFactorAuthenticationSecretAction();
action.name = "user1";
action.password = "password";
action.type = "ldap";
GetTwoFactorAuthenticationSecretAction.Result res = action.call();Python SDK
action = GetTwoFactorAuthenticationSecretAction()
action.name = "user1"
action.password = "password"
action.type = "ldap"
res = action.call()查询双因子认证密钥(QueryTwoFactorAuthentication)
API请求
URLs
GET zstack/v1/twofactorauthentication/secretsGET zstack/v1/twofactorauthentication/secrets/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/twofactorauthentication/secrets?q=uuid=d65b4896eee23175b19e1267ee39ec60curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/twofactorauthentication/secrets/83358cec65073cbc876ddefe3d9b69fe可查询字段
运行CLI命令行工具,输入并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"uuid": "16620c01d20b390891ae1a1bc072ac0b",
"secret": "ABCDEFGH12345678",
"userUuid": "264d446f00e43793a2b0dcd21c367aaf",
"userType": "AccountVO",
"status": "NewCreated"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.4.0 |
| inventories | List | 详情参考inventories | 3.4.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.4.0 |
| description | String | 错误的概要描述 | 3.4.0 |
| details | String | 错误的详细信息 | 3.4.0 |
| elaboration | String | 保留字段,默认为null | 3.4.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.4.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.4.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.4.0 |
| secret | String | 双因子认证密钥 | 3.4.0 |
| userUuid | String | 用户UUID | 3.4.0 |
| userType | String | 3.4.0 | |
| createDate | Timestamp | 创建时间 | 3.4.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.4.0 |
| status | TwoFactorAuthenticationSecretStatus | 详情参考status | 3.4.0 |
#status
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 3.4.0 |
| ordinal | int | 3.4.0 |
SDK示例
Java
SDK
QueryTwoFactorAuthenticationAction action = new QueryTwoFactorAuthenticationAction();
action.conditions = asList("uuid=4875201ba7443dddb51e336f9a23a20e");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryTwoFactorAuthenticationAction.Result res = action.call();Python
SDK
QueryTwoFactorAuthenticationAction action = QueryTwoFactorAuthenticationAction()
action.conditions = ["uuid=ccf0f6cdf5a73bf7b961869f9bd8ca25"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryTwoFactorAuthenticationAction.Result res = action.call()获取双因子认证状态(GetTwoFactorAuthenticationState)
API请求
URLs
GET zstack/v1/twofactorauthentication/stateCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/zstack/v1/twofactorauthentication/state参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| systemTags (可选) | List | query | 2.6.0 | ||
| userTags (可选) | List | query | 2.6.0 |
API返回
返回示例
{
"state": "Disable"
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| state | String | 2.6.0 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 2.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 2.6.0 |
| description | String | 错误的概要描述 | 2.6.0 |
| details | String | 错误的详细信息 | 2.6.0 |
| elaboration | String | 保留字段,默认为null | 2.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 2.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 2.6.0 |
SDK示例
Java
SDK
GetTwoFactorAuthenticationStateAction action = new GetTwoFactorAuthenticationStateAction();
GetTwoFactorAuthenticationStateAction.Result res = action.call();Python
SDK
GetTwoFactorAuthenticationStateAction action = GetTwoFactorAuthenticationStateAction()
GetTwoFactorAuthenticationStateAction.Result res = action.call()重置双因子认证密匙(ResetTwoFactorAuthenticationSecret)
API 请求
URLs
PUT zstack/v1/twofactorauthentication/secretsHeaders
Authorization: OAuth the-session-uuidBody
{
"resetTwoFactorAuthenticationSecret": {
"name": "user1",
"password": "password",
"type": "ldap"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"resetTwoFactorAuthenticationSecret":{"name":"user1","password":"password","type":"ldap"}}' \
http://localhost:8080/zstack/v1/twofactorauthentication/secrets参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在resetTwoFactorAuthenticationSecret结构中) |
资源名称 | 4.10.0 | |
| password | String | body(包含在resetTwoFactorAuthenticationSecret结构中) |
4.10.0 | ||
| captchaUuid (可选) | String | body(包含在resetTwoFactorAuthenticationSecret结构中) |
4.10.0 | ||
| verifyCode (可选) | String | body(包含在resetTwoFactorAuthenticationSecret结构中) |
4.10.0 | ||
| system Tags (可选) | List | body | 系统标签 | 4.10.0 | |
| userTags (可选) | List | body | 用户标签 | 4.10.0 | |
| type | String | body(包含在resetTwoFactorAuthenticationSecret结构中) |
|
5.0.0 |
SDK示例
Java SDK
ResetTwoFactorAuthenticationSecretAction action = new ResetTwoFactorAuthenticationSecretAction();
action.name = "user1";
action.password = "password";
action.type = "ldap";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ResetTwoFactorAuthenticationSecretAction.Result res = action.call();Python SDK
action = ResetTwoFactorAuthenticationSecretAction()
action.name = "user1"
action.password = "password"
action.type = "ldap"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()查询账户资源引用(QueryAccountResourceRef)
API请求
URLs
GET zstack/v1/accounts/resources/refsHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/accounts/resources/refs?q=acountUuid=279c136f406e35a6a6874e39b231a2d3可查询字段
运行CLI命令行工具,输入QueryAccountResourceRef并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"id": 1,
"accountUuid": "ef9a9b4c5bd338768f18148dbfe42f1c",
"resourceUuid": "6e06fe5d204f30ac80ffc4c2d6372e46",
"resourceType": "ImageVO",
"type": "Own"
}
]
}
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventories | List | 详情参考inventories | 0.6 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| accountUuid | String | 账户UUID | 0.6 |
| resourceUuid | String | 资源UUID | 0.6 |
| resourceType | String | 资源类型 | 0.6 |
| createDate | Timestamp | 创建时间 | 0.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 0.6 |
SDK示例
Java
SDK
QueryAccountResourceRefAction action = new QueryAccountResourceRefAction();
action.conditions = asList("acountUuid=dec9472c2f9b3f6abaa84ed78094171c");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryAccountResourceRefAction.Result res = action.call();
Python
SDK
QueryAccountResourceRefAction action = QueryAccountResourceRefAction()
action.conditions = ["acountUuid=05e51ebc332935769868ecde43b8f8e6"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryAccountResourceRefAction.Result res = action.call()
创建账户组 (CreateAccountGroup)
API请求
URLs
POST zstack/v1/account-groupsHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "my-group"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"my-group"}}' \
http://localhost:8080/zstack/v1/account-groups参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在params结构中) |
账户组名称 | 4.10.0 | |
| description (可选) | String | body(包含在params结构中) |
账户组的详细描述 | 4.10.0 | |
| parentUuid (可选) | String | body(包含在params结构中) |
上层账户组 UUID | 4.10.0 | |
| resourceUuid (可选) | String | body(包含在params结构中) |
预定义的账户组 UUID | 4.10.0 | |
| tagUuids (可选) | List | body(包含在params结构中) |
标签UUID列表 | 4.10.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.0 | |
| userTags (可选) | List | body | 用户标签 | 4.10.0 |
API返回
返回示例
{
"inventory": {
"uuid": "98cab5e804424603892af30a1f7a4a58",
"name": "my-group",
"description": "my-group-description",
"rootGroupUuid": "98cab5e804424603892af30a1f7a4a58",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 请求是否成功 | 4.10.0 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.10.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
SDK示例
Java
SDK
CreateAccountGroupAction action = new CreateAccountGroupAction();
action.name = "my-group";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateAccountGroupAction.Result res = action.call();
Python
SDK
CreateAccountGroupAction action = CreateAccountGroupAction()
action.name = "my-group"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateAccountGroupAction.Result res = action.call()
删除账户组 (DeleteAccountGroup)
API请求
URLs
DELETE zstack/v1/account-groups/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/account-groups/8dac6a80b68b3f7fbe44233dfe42a1d8参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 账户组 UUID | 4.10.0 | |
| deleteMode (可选) | String | body | 删除模式(Permissive / Enforcing,Permissive) | 4.10.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.0 | |
| userTags (可选) | List | body | 用户标签 | 4.10.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
DeleteAccountGroupAction action = new DeleteAccountGroupAction();
action.uuid = "8dac6a80b68b3f7fbe44233dfe42a1d8";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteAccountGroupAction.Result res = action.call();
Python
SDK
DeleteAccountGroupAction action = DeleteAccountGroupAction()
action.uuid = "8dac6a80b68b3f7fbe44233dfe42a1d8"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteAccountGroupAction.Result res = action.call()
更新账户组 (UpdateAccountGroup)
API请求
URLs
PUT zstack/v1/account-groups/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"updateAccountGroup": {
"name": "my-group"
},
"systemTags": [],
"userTags": []
}
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateAccountGroup":{"name":"my-group"}}' \
http://localhost:8080/zstack/v1/account-groups/0e830b9be4e33dd7b772eb9316ee6fb1/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 账户组 UUID | 4.10.0 | |
| name (可选) | String | body(包含在updateAccountGroup结构中) |
账户组名称 | 4.10.0 | |
| description (可选) | String | body(包含在updateAccountGroup结构中) |
账户组的详细描述 | 4.10.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.0 | |
| userTags (可选) | List | body | 用户标签 | 4.10.0 |
API返回
返回示例
{
"inventory": {
"uuid": "14295ba5c00d4fc596541e3fb5652924",
"name": "my-group",
"description": "my-group-description",
"rootGroupUuid": "14295ba5c00d4fc596541e3fb5652924",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
}
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 请求是否成功 | 4.10.0 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.10.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
SDK示例
Java
SDK
UpdateAccountGroupAction action = new UpdateAccountGroupAction();
action.uuid = "0e830b9be4e33dd7b772eb9316ee6fb1";
action.name = "my-group";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateAccountGroupAction.Result res = action.call();
Python
SDK
UpdateAccountGroupAction action = UpdateAccountGroupAction()
action.uuid = "0e830b9be4e33dd7b772eb9316ee6fb1"
action.name = "my-group"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateAccountGroupAction.Result res = action.call()
移动账户组 (MoveAccountGroup)
API请求
URLs
PUT zstack/v1/account-groups/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"moveAccountGroup": {
"parentUuid": "996c8a1d6f273903b750254a69ec5a7b"
},
"systemTags": [],
"userTags": []
}
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"moveAccountGroup":{"parentUuid":"996c8a1d6f273903b750254a69ec5a7b"}}' \
http://localhost:8080/zstack/v1/account-groups/efdbcd5b10ee3b9aa6b61f2ec4a0efcb/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 账户组 UUID | 4.10.0 | |
| parentUuid (可选) | String | body(包含在moveAccountGroup结构中) |
父账户组 UUID | 4.10.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.0 | |
| userTags (可选) | List | body | 用户标签 | 4.10.0 |
API返回
返回示例
{
"inventory": {
"uuid": "c4f2348db99a4d64ac5319abecff4427",
"name": "my-group",
"description": "my-group-description",
"rootGroupUuid": "c4f2348db99a4d64ac5319abecff4427",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
}
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 请求是否成功 | 4.10.0 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.10.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
SDK示例
Java
SDK
MoveAccountGroupAction action = new MoveAccountGroupAction();
action.uuid = "efdbcd5b10ee3b9aa6b61f2ec4a0efcb";
action.parentUuid = "996c8a1d6f273903b750254a69ec5a7b";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
MoveAccountGroupAction.Result res = action.call();
Python
SDK
MoveAccountGroupAction action = MoveAccountGroupAction()
action.uuid = "efdbcd5b10ee3b9aa6b61f2ec4a0efcb"
action.parentUuid = "996c8a1d6f273903b750254a69ec5a7b"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
MoveAccountGroupAction.Result res = action.call()
查询账户组 (QueryAccountGroup)
API请求
URLs
GET zstack/v1/account-groups
GET zstack/v1/account-groups/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/account-groups?q=name=my-groupcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/account-groups/64fb6148cb6438a088febdd75b819245可查询字段
运行CLI命令行工具,输入QueryAccountGroup并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"uuid": "c7e4d70aa27b49839516c7ed9d3651a8",
"name": "my-group",
"description": "my-group-description",
"rootGroupUuid": "c7e4d70aa27b49839516c7ed9d3651a8",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
]
}
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 请求是否成功 | 4.10.0 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.10.0 |
| inventories | List | 详情参考inventories | 4.10.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 账户组的UUID,唯一标示该资源 | 4.10.0 |
| name | String | 账户组名称 | 4.10.0 |
| description | String | 账户组的详细描述 | 4.10.0 |
| parentUuid | String | 父账户组 UUID, null 表示无父账户组, 自己是最上层 | 4.10.0 |
| rootGroupUuid | String | 最上层账户组的 UUID; 如果自己就是最上层, 则 rootGroupUuid 指向自己 | 4.10.0 |
| createDate | Timestamp | 创建时间 | 4.10.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.10.0 |
SDK示例
Java
SDK
QueryAccountGroupAction action = new QueryAccountGroupAction();
action.conditions = asList("name=my-group");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryAccountGroupAction.Result res = action.call();
Python
SDK
QueryAccountGroupAction action = QueryAccountGroupAction()
action.conditions = ["name=my-group"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryAccountGroupAction.Result res = action.call()
账户加入账户组 (AddAccountToGroup)
API请求
URLs
POST zstack/v1/account-groups/{groupUuid}/accountsHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"accountUuids": [
"ac243dc036043ad7a1ea649248e3e863"
]
},
"systemTags": [],
"userTags": []
}
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"accountUuids":["ac243dc036043ad7a1ea649248e3e863"]}}'
http://localhost:8080/zstack/v1/account-groups/ab8c60e7c3bb3f05906adfc8f991c90b/accounts参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| groupUuid | String | url | 账户组 UUID | 4.10.0 | |
| accountUuids | List | body (包含在params结构中) | 账户 UUID 列表 | 4.10.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.0 | |
| userTags (可选) | List | body | 用户标签 | 4.10.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
AddAccountToGroupAction action = new AddAccountToGroupAction();
action.groupUuid = "ab8c60e7c3bb3f05906adfc8f991c90b";
action.accountUuids = asList("ac243dc036043ad7a1ea649248e3e863");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddAccountToGroupAction.Result res = action.call();Python
SDK
AddAccountToGroupAction action = AddAccountToGroupAction()
action.groupUuid = "ab8c60e7c3bb3f05906adfc8f991c90b"
action.accountUuids = [ac243dc036043ad7a1ea649248e3e863]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AddAccountToGroupAction.Result res = action.call()账户组移除账户 (RemoveAccountFromGroup)
API 请求
URLs
DELETE zstack/v1/account-groups/{groupUuid}/accountsHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/account-groups/263094628051388c80bb011a63d070f1/accounts参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| groupUuid | String | url | 账户组 UUID | 4.10.0 | |
| accountUuids | List | body | 账户 UUID 列表 | 4.10.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.0 | |
| userTags (可选) | List | body | 用户标签 | 4.10.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
RemoveAccountFromGroupAction action = new RemoveAccountFromGroupAction();
action.groupUuid = "263094628051388c80bb011a63d070f1";
action.accountUuids = asList("0bc44812c44d314482e0fa4389271117");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RemoveAccountFromGroupAction.Result res = action.call();
Python
SDK
RemoveAccountFromGroupAction action = RemoveAccountFromGroupAction()
action.groupUuid = "263094628051388c80bb011a63d070f1"
action.accountUuids = [0bc44812c44d314482e0fa4389271117]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
RemoveAccountFromGroupAction.Result res = action.call()
账户组绑定角色 (AttachRoleToAccountGroup)
API 请求
URLs
POST zstack/v1/account-groups/{groupUuid}/rolesHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"roleUuids": [
"314c999460493f589963a021e0478054"
]
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"roleUuids":["314c999460493f589963a021e0478054"]}}' \
http://localhost:8080/zstack/v1/account-groups/c271dab858c63bd288502e9ee4e0498d/roles参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| groupUuid | String | url | 账户组 UUID | 4.10.0 | |
| roleUuids | List | body(包含在params结构中) |
角色 UUID 列表 | 4.10.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.0 | |
| userTags (可选) | List | body | 用户标签 | 4.10.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
AttachRoleToAccountGroupAction action = new AttachRoleToAccountGroupAction();
action.groupUuid = "c271dab858c63bd288502e9ee4e0498d";
action.roleUuids = asList("314c999460493f589963a021e0478054");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AttachRoleToAccountGroupAction.Result res = action.call();Python
SDK
AttachRoleToAccountGroupAction action = AttachRoleToAccountGroupAction()
action.groupUuid = "c271dab858c63bd288502e9ee4e0498d"
action.roleUuids = [314c999460493f589963a021e0478054]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AttachRoleToAccountGroupAction.Result res = action.call()账户组解绑角色 (DetachRoleFromAccountGroup)
API请求
URLs
DELETE zstack/v1/account-groups/{groupUuid}/rolesHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/account-groups/28c89d7eaf23373baad7e0f8889b2c3d/roles参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| groupUuid | String | url | 账户组 UUID | 4.10.0 | |
| roleUuids | List | body | 角色 UUID 列表 | 4.10.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.0 | |
| userTags (可选) | List | body | 用户标签 | 4.10.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
DetachRoleFromAccountGroupAction action = new DetachRoleFromAccountGroupAction();
action.groupUuid = "28c89d7eaf23373baad7e0f8889b2c3d";
action.roleUuids = asList("b63ab325307535a9b918d5b76b1246f5");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DetachRoleFromAccountGroupAction.Result res = action.call();
Python
SDK
DetachRoleFromAccountGroupAction action = DetachRoleFromAccountGroupAction()
action.groupUuid = "28c89d7eaf23373baad7e0f8889b2c3d"
action.roleUuids = [b63ab325307535a9b918d5b76b1246f5]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DetachRoleFromAccountGroupAction.Result res = action.call()
获取账户组下所有账户和组 (GetAccountsInAccountGroup)
获取账户组下所有账户和组
API请求
URLs
GET zstack/v1/account-groups/treeHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X GET http://localhost:8080/zstack/v1/account-groups/tree?groupUuid=470ce4d7a8dc32f597aa77675da3cd08&level=0&showGroup=true&showAccount=true参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| groupUuid (可选) | String | query | 账户组 UUID; null 表示查询所有最上层账户组 | 4.10.0 | |
| level (可选) | int | query | 向下查询子账户组的深度; 默认为 0 表示不查询子账户下的账户和组; 1 表示查询子账户下的账户和组 | 4.10.0 | |
| showGroup (可选) | boolean | query | 返回结果是否包含账户组信息, 默认为 true 表示返回结果包含账户组信息 | 4.10.0 | |
| showAccount (可选) | boolean | query | 返回结果是否包含账户信息, 默认为 true 表示返回结果包含账户信息 | 4.10.0 | |
| systemTags (可选) | List | query | 系统标签 | 4.10.0 | |
| userTags (可选) | List | query | 用户标签 | 4.10.0 |
API返回
返回示例
{
"inventory": {
"groupUuid": "ff0b3ed5c5d7323b9150ffd45a820a00",
"groupName": "my-group",
"inventory": {
"uuid": "ff0b3ed5c5d7323b9150ffd45a820a00",
"name": "my-group",
"description": "my-group-description",
"rootGroupUuid": "ff0b3ed5c5d7323b9150ffd45a820a00",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
},
"accounts": [
{
"uuid": "ff0b33166633399aae77ea258d2f7900",
"name": "account1",
"description": "account1-description",
"type": "Normal",
"source": "Local",
"state": "Enabled",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
],
"groups": [
{
"groupUuid": "ff0b3ed5c5d7323b9150ffd45a820a00",
"groupName": "child-group",
"accounts": [],
"groups": []
}
]
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 请求是否成功 | 4.10.0 |
| inventories | List | 详情参考inventories | 4.10.0 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.10.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 账户的UUID,唯一标示该资源 | 4.0.0 |
| name | String | 账户名称 | 4.0.0 |
| description | String | 账户的详细描述 | 4.0.0 |
| type | String | 账户类型 | 4.0.0 |
| source | String | 账户来源,创建时确定且不可修改 | 5.1.0 |
| state | String | 账户状态 | 4.0.0 |
| createDate | Timestamp | 创建时间 | 4.0.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.0.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
SDK示例
Java SDK
GetAccountGroupTreeAction action = new GetAccountGroupTreeAction();
action.groupUuid = "470ce4d7a8dc32f597aa77675da3cd08";
action.level = 0;
action.showGroup = true;
action.showAccount = true;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetAccountGroupTreeAction.Result res = action.call();Python SDK
action = GetAccountGroupTreeAction()
action.groupUuid = "470ce4d7a8dc32f597aa77675da3cd08"
action.level = 0
action.showGroup = true
action.showAccount = true
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()获取账户组下所有分享的资源 (GetResourceInAccountGroup)
API请求
URLs
GET zstack/v1/account-groups/{groupUuid}/resourcesHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/account-groups/07954c2a73cf348383db3ccdecbb94fa/resources?includeInheritedResources=false参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| groupUuid | String | url | 账户组 UUID | 4.10.0 | |
| includeInheritedResources (可选) | boolean | query | 是否包含父账户组的继承的资源; 如果为 true, 则结果将包含父账户组分享的资源 | 4.10.0 | |
| systemTags (可选) | List | query | 系统标签 | 4.10.0 | |
| userTags (可选) | List | query | 用户标签 | 4.10.0 |
API返回
返回示例
{
"currentGroup": {
"groupUuid": "f34e8f7c5ae84dc2902c4c54a1eb957b",
"groupName": "my-group",
"resources": [
{
"uuid": "1783b75964da46bda91fe6ee371c8bd0",
"resourceName": "vm1",
"resourceType": "VmInstanceVO"
}
]
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 请求是否成功 | 4.10.0 |
| inventories | List | 详情参考inventories | 4.10.0 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.10.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.0.0 |
| resourceName | String | 资源名称 | 4.0.0 |
| resourceType | String | 资源类型 | 4.0.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
SDK示例
Java SDK
GetResourceInAccountGroupAction action = new GetResourceInAccountGroupAction();
action.groupUuid = "ff0b3ed5c5d7323b9150ffd45a820a00";
action.includeInheritedResources = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetResourceInAccountGroupAction.Result res = action.call();Python SDK
action = GetResourceInAccountGroupAction()
action.groupUuid = "ff0b3ed5c5d7323b9150ffd45a820a00"
action.includeInheritedResources = false
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()查询配额(QueryQuota)
API请求
URLs
GET zstack/v1/accounts/quotasHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/accounts/quotas?q=name=test可查询字段
运行CLI命令行工具,输入QueryQuota并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"name": "quota",
"identityUuid": "b30cc832a5493fe2a6184a78fc20c410",
"value": 20
}
]
}
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventories | List | 详情参考inventories | 0.6 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 0.6 |
| identityUuid | String | 身份UUID(账户UUID,用户UUID) | 0.6 |
| identityType | String | 身份类型(账户,用户) | 0.6 |
| value | Long | 默认配额值 | 0.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 0.6 |
| createDate | Timestamp | 创建时间 | 0.6 |
SDK示例
Java
SDK
QueryQuotaAction action = new QueryQuotaAction();
action.conditions = asList("name=test");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryQuotaAction.Result res = action.call();
Python
SDK
QueryQuotaAction action = QueryQuotaAction()
action.conditions = ["name=test"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryQuotaAction.Result res = action.call()
更新配额(UpdateQuota)
API请求
URLs
PUT zstack/v1/accounts/quotas/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"updateQuota": {
"identityUuid": "4d45e6c7787733979415760d2077fca0",
"name": "quotaname",
"value": 20
},
"systemTags": [],
"userTags": []
}
Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateQuota":{"identityUuid":"4d45e6c7787733979415760d2077fca0","name":"quotaname","value":20}}' \
http://localhost:8080/zstack/v1/accounts/quotas/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| identityUuid | String | body(包含在updateQuota结构中) | 身份实体的UUID(账户的) | 0.6 | |
| name | String | body(包含在updateQuota结构中) | 资源名称 | 0.6 | |
| value | long | body(包含在updateQuota结构中) | 配额值 | 0.6 | |
| systemTags (可选) | List | body | 系统标签 | 0.6 | |
| userTags (可选) | List | body | 用户标签 | 0.6 |
API返回
返回示例
{
"inventory": {
"name": "quota",
"identityUuid": "733689237dd9309f81e6a2f76b7c78b1",
"value": 20
}
}
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 0.6 |
| identityUuid | String | 身份UUID(账户UUID,用户UUID) | 0.6 |
| identityType | String | 身份类型(账户,用户) | 0.6 |
| value | Long | 默认配额值 | 0.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 0.6 |
| createDate | Timestamp | 创建时间 | 0.6 |
SDK示例
Java
SDK
UpdateQuotaAction action = new UpdateQuotaAction();
action.identityUuid = "4d45e6c7787733979415760d2077fca0";
action.name = "quotaname";
action.value = 20;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateQuotaAction.Result res = action.call();
Python
SDK
UpdateQuotaAction action = UpdateQuotaAction()
action.identityUuid = "4d45e6c7787733979415760d2077fca0"
action.name = "quotaname"
action.value = 20
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateQuotaAction.Result res = action.call()
获取资源名称(GetResourceNames)
API请求
URLs
GET zstack/v1/resources/namesHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/resources/names?uuids=393ce06589043e33b397bc21043e8cd4&uuids=b62bdb31280a30a69c2f110bac8cb682参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuids | List | query | 资源的UUID列表 | 0.6 | |
| systemTags (可选) | List | query | 0.6 | ||
| userTags (可选) | List | query | 0.6 |
API返回
返回示例
{
"inventories": [
{
"uuid": "9da599e443ec3d21bb4c766ad51784d3",
"resourceName": "zone",
"resourceType": "ZoneVO"
},
{
"uuid": "a6e1b35c657835c5972e94773e52949b",
"resourceName": "vm",
"resourceType": "VmInstanceVO"
}
]
}
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 2.0 |
| inventories | List | 详情参考inventories | 2.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.0.0 |
| resourceName | String | 资源名称 | 4.0.0 |
| resourceType | String | 资源类型,例如虚拟机为VmInstanceVO | 4.0.0 |
SDK示例
Java
SDK
GetResourceNamesAction action = new GetResourceNamesAction();
action.uuids = asList("393ce06589043e33b397bc21043e8cd4","b62bdb31280a30a69c2f110bac8cb682");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetResourceNamesAction.Result res = action.call();
Python
SDK
GetResourceNamesAction action = GetResourceNamesAction()
action.uuids = [393ce06589043e33b397bc21043e8cd4, b62bdb31280a30a69c2f110bac8cb682]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetResourceNamesAction.Result res = action.call()
获取资源被分享对象 (GetResourceSharing)
API请求
URLs
GET zstack/v1/iam1/resource-ensemble/view-sharingHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/iam1/resource-ensemble/view-sharing参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| resourceUuid | String | query | 资源UUID | 4.10.0 | |
| systemTags (可选) | List | query | 系统标签 | 4.10.0 | |
| userTags (可选) | List | query | 用户标签 | 4.10.0 |
API返回
返回示例
{
"uuid": "a2a658dba2fa385382bc9f29a0788815",
"toPublic": false,
"accounts": [
{
"uuid": "7ded05202370411d85e6bf20168fa08f"
}
],
"accountGroups": [
{
"uuid": "2347044abdbb41d6b2bfb3cd196bfe79"
}
]
}
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| resourceUuid | String | 资源UUID | 4.10.0 |
| masterResourceUuid | String | 如果资源在某个资源组里面,这个值是资源组中主要资源的UUID。如果没有,这个值是null | 4.10.0 |
| masterResourceType | String | 如果资源在某个资源组里面,这个值是资源组中主要资源的类型。如果没有,这个值是null | 4.10.0 |
| toPublic | boolean | 资源是否被全局分享 | 4.10.0 |
| success | boolean | 请求是否成功 | 4.10.0 |
| accounts | List | 详情参考accounts | 4.10.0 |
| accountGroups | List | 详情参考accountGroups | 4.10.0 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.10.0 |
#accounts
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 账户UUID | 4.10.0 |
#accountGroups
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 账户组UUID | 4.10.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
SDK示例
Java SDK
GetResourceSharingAction action = new GetResourceSharingAction();
action.uuid = "ff0811edaad638d5893a0fb09f408300";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetResourceSharingAction.Result res = action.call();Python SDK
action = GetResourceSharingAction()
action.uuid = "ff0811edaad638d5893a0fb09f408300"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()将资源分享给账户组 (ShareResourceToGroup)
API请求
URLs
PUT zstack/v1/account-groups/resources/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"shareResourceToGroup": {
"resourceUuids": [
"7f610aa37f17327d9b1dd74fc4ce871d"
],
"groupUuid": "2334f9ef50f03f2dba17abb79c6b5d53"
},
"systemTags": [],
"userTags": []
}
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"shareResourceToGroup":{"resourceUuids":["7f610aa37f17327d9b1dd74fc4ce871d"],"groupUuid":"2334f9ef50f03f2dba17abb79c6b5d53"}}' \
http://localhost:8080/zstack/v1/account-groups/resources/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| resourceUuids | List | body(包含在shareResourceToGroup结构中) |
待分享的资源 UUID 列表, 必须是资源组中的资源 | 4.10.0 | |
| groupUuid | String | body(包含在shareResourceToGroup结构中) |
账户组 UUID | 4.10.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.0 | |
| userTags (可选) | List | body | 用户标签 | 4.10.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
ShareResourceToGroupAction action = new ShareResourceToGroupAction();
action.resourceUuids = asList("7f610aa37f17327d9b1dd74fc4ce871d");
action.groupUuid = "2334f9ef50f03f2dba17abb79c6b5d53";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ShareResourceToGroupAction.Result res = action.call();
Python
SDK
ShareResourceToGroupAction action = ShareResourceToGroupAction()
action.resourceUuids = [7f610aa37f17327d9b1dd74fc4ce871d]
action.groupUuid = "2334f9ef50f03f2dba17abb79c6b5d53"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ShareResourceToGroupAction.Result res = action.call()
撤销资源分享账户组 (RevokeResourceSharingToGroup)
API请求
URLs
PUT zstack/v1/account-groups/resources/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"revokeResourceSharingToGroup": {
"resourceUuids": [
"3d502ce7557c3aa29f40ab4cfde80bbd"
],
"groupUuid": "c84e3415faca3a94971b14ba5b4dceb2"
},
"systemTags": [],
"userTags": []
}
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"revokeResourceSharingToGroup":{"resourceUuids":["3d502ce7557c3aa29f40ab4cfde80bbd"],"groupUuid":"c84e3415faca3a94971b14ba5b4dceb2"}}' \
http://localhost:8080/zstack/v1/account-groups/resources/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| resourceUuids | List | body(包含在revokeResourceSharingToGroup结构中) |
待撤销分享的资源 UUID 列表, 必须是资源组中的资源 | 4.10.0 | |
| groupUuid | String | body(包含在revokeResourceSharingToGroup结构中) |
账户组 UUID | 4.10.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.0 | |
| userTags (可选) | List | body | 用户标签 | 4.10.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
RevokeResourceSharingToGroupAction action = new RevokeResourceSharingToGroupAction();
action.resourceUuids = asList("3d502ce7557c3aa29f40ab4cfde80bbd");
action.groupUuid = "c84e3415faca3a94971b14ba5b4dceb2";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RevokeResourceSharingToGroupAction.Result res = action.call();
Python
SDK
RevokeResourceSharingToGroupAction action = RevokeResourceSharingToGroupAction()
action.resourceUuids = [3d502ce7557c3aa29f40ab4cfde80bbd]
action.groupUuid = "c84e3415faca3a94971b14ba5b4dceb2"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
RevokeResourceSharingToGroupAction.Result res = action.call()
获取资源组中的所有成员 (GetResourceEnsembleMembers)
API 请求
URLs
GET zstack/v1/iam1/resource-ensemble
GET zstack/v1/iam1/resource-ensemble/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/iam1/resource-ensemble?uuid=14c61568f49a45759c9a75c8fea4f854curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/iam1/resource-ensemble/14c61568f49a45759c9a75c8fea4f854?uuid=14c61568f49a45759c9a75c8fea4f854参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | query | 资源的UUID,资源组中任意成员即可 | 4.10.0 | |
| systemTags (可选) | List | query | 系统标签 | 4.10.0 | |
| userTags (可选) | List | query | 用户标签 | 4.10.0 |
API返回
返回示例
{
"inventory": {
"masterUuid": "14c61568f49a45759c9a75c8fea4f854",
"masterResourceName": "VM1",
"masterResourceType": "VmInstanceVO",
"members": [
{
"uuid": "c1abb7bd0de8489bb183d829c3ccde0e",
"resourceName": "vmcdrom-VM1",
"resourceType": "VmCdRomVO"
},
{},
{}
]
}
}
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| masterUuid | String | 资源组中主要资源的UUID | 4.10.0 |
| masterResourceName | String | 资源组中主要资源的名称 | 4.10.0 |
| masterResourceType | String | 资源组中主要资源的类型 | 4.10.0 |
| members | List | 详情参考members | 4.10.0 |
#members
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.0.0 |
| resourceName | String | 资源名称 | 4.0.0 |
| resourceType | String | 资源类型 | 4.0.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
SDK示例
Java
SDK
GetResourceEnsembleMembersAction action = new GetResourceEnsembleMembersAction();
action.uuid = "14c61568f49a45759c9a75c8fea4f854";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetResourceEnsembleMembersAction.Result res = action.call();
Python
SDK
GetResourceEnsembleMembersAction action = GetResourceEnsembleMembersAction()
action.uuid = "14c61568f49a45759c9a75c8fea4f854"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetResourceEnsembleMembersAction.Result res = action.call()
共享资源给账户(ShareResource)
API请求
URLs
PUT zstack/v1/accounts/resources/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"shareResource": {
"resourceUuids": [
"62113cf71892442daf57fe1a21606e7b",
"e8d14f0a61d7497c83cf9451bdd392a3"
],
"accountUuids": [
"17c6a138e5f04df4ad8938fa8bd06340",
"7063dc465e7c42739fdb5fd7d3e373f4"
],
"toPublic": false
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"shareResource":{"resourceUuids":["05c5cdd1a5693e53ad3212a69b808883","49c6493b8eaf3765806aeb17071e779f"],"accountUuids":["62c084e3a2053b089b8b95fe452856e7","194f8c7d98963e628b9967b0df7eecae"],"toPublic":false}}' \
http://localhost:8080/zstack/v1/accounts/resources/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| resourceUuids | List | body(包含在shareResource结构中) | 资源UUID列表 | 0.6 | |
| accountUuids (可选) | List | body(包含在shareResource结构中) | 账户UUID列表 | 0.6 | |
| toPublic (可选) | boolean | body(包含在shareResource结构中) | 全局共享 Note: toPublic参数被设为false时,账户uuid不能为空 |
0.6 | |
| permission (可选) | String | body(包含在shareResource结构中) | 共享的权限, WRITE 表示写权限, READ 表示读权限 | 4.2.0 | |
| systemTags (可选) | List | body | 系统标签 | 0.6 | |
| userTags (可选) | List | body | 用户标签 | 0.6 |
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
ShareResourceAction action = new ShareResourceAction();
action.resourceUuids = asList("05c5cdd1a5693e53ad3212a69b808883","49c6493b8eaf3765806aeb17071e779f");
action.accountUuids = asList("62c084e3a2053b089b8b95fe452856e7","194f8c7d98963e628b9967b0df7eecae");
action.toPublic = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ShareResourceAction.Result res = action.call();
Python
SDK
ShareResourceAction action = ShareResourceAction()
action.resourceUuids = [05c5cdd1a5693e53ad3212a69b808883, 49c6493b8eaf3765806aeb17071e779f]
action.accountUuids = [62c084e3a2053b089b8b95fe452856e7, 194f8c7d98963e628b9967b0df7eecae]
action.toPublic = false
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ShareResourceAction.Result res = action.call()
解除资源共享(RevokeResourceSharing)
API请求
URLs
PUT zstack/v1/accounts/resources/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"revokeResourceSharing": {
"resourceUuids": [
"6551ce5374243f14875351219cdb69ba",
"18501632374c331692e10ab976f56e28"
],
"toPublic": false,
"accountUuids": [
"9a0c56a8bcbd31edbd384b28b8ffeffc",
"3627b63ad55939cf8df5fa4848abd6f2"
],
"all": false
},
"systemTags": [],
"userTags": []
}
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"revokeResourceSharing":{"resourceUuids":["6551ce5374243f14875351219cdb69ba","18501632374c331692e10ab976f56e28"],"toPublic":false,"accountUuids":["9a0c56a8bcbd31edbd384b28b8ffeffc","3627b63ad55939cf8df5fa4848abd6f2"],"all":false}}' \
http://localhost:8080/zstack/v1/accounts/resources/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| resourceUuids | List | body(包含在revokeResourceSharing结构中) | 资源UUID列表 | 0.6 | |
| toPublic (可选) | boolean | body(包含在结构中) | 全局共享 | 0.6 | |
| accountUuids (可选) | List | body(包含在revokeResourceSharing结构中) Note: all参数设为false时,账户UUID不能为空 |
账户UUID列表 | 0.6 | |
| all (可选) | boolean | body(包含在revokeResourceSharing结构中) | 0.6 | ||
| systemTags (可选) | List | body | 系统标签 | 0.6 | |
| userTags (可选) | List | body | 用户标签 | 0.6 |
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
RevokeResourceSharingAction action = new RevokeResourceSharingAction();
action.resourceUuids = asList("6551ce5374243f14875351219cdb69ba","18501632374c331692e10ab976f56e28");
action.toPublic = false;
action.accountUuids = asList("9a0c56a8bcbd31edbd384b28b8ffeffc","3627b63ad55939cf8df5fa4848abd6f2");
action.all = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RevokeResourceSharingAction.Result res = action.call();
Python
SDK
RevokeResourceSharingAction action = RevokeResourceSharingAction()
action.resourceUuids = [6551ce5374243f14875351219cdb69ba, 18501632374c331692e10ab976f56e28]
action.toPublic = false
action.accountUuids = [9a0c56a8bcbd31edbd384b28b8ffeffc, 3627b63ad55939cf8df5fa4848abd6f2]
action.all = false
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
RevokeResourceSharingAction.Result res = action.call()
变更资源所有者(ChangeResourceOwner)
API请求
URLs
POST zstack/v1/account/{accountUuid}/resourcesHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"resourceUuid": "abfee8286ae43b19a02179cfe37b3294"
},
"systemTags": [],
"userTags": []
}
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"resourceUuid":"abfee8286ae43b19a02179cfe37b3294"}}' \
http://localhost:8080/zstack/v1/account/e9da3eb01abc31c78ac24dec8c8c36b5/resources参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| accountUuid | String | url | 账户UUID | 0.6 | |
| resourceUuid | String | body(包含在params结构中) |
资源UUID | 0.6 | |
| systemTags (可选) | List | body | 系统标签 | 0.6 | |
| userTags (可选) | List | body | 用户标签 | 0.6 |
API返回
返回示例
{
"inventory": {
"id": 1,
"accountUuid": "819950c427763deca51c94ad5e06da42",
"resourceUuid": "844a5dbbd2a632678b67a610e4d761b6",
"resourceType": "ImageVO",
"type": "Own"
}
}
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| accountUuid | String | 账户UUID | 0.6 |
| resourceUuid | String | 资源UUID | 0.6 |
| resourceType | String | 资源类型 | 0.6 |
| createDate | Timestamp | 创建时间 | 0.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 0.6 |
SDK示例
Java
SDK
ChangeResourceOwnerAction action = new ChangeResourceOwnerAction();
action.accountUuid = "e9da3eb01abc31c78ac24dec8c8c36b5";
action.resourceUuid = "abfee8286ae43b19a02179cfe37b3294";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangeResourceOwnerAction.Result res = action.call();
Python
SDK
ChangeResourceOwnerAction action = ChangeResourceOwnerAction()
action.accountUuid = "e9da3eb01abc31c78ac24dec8c8c36b5"
action.resourceUuid = "abfee8286ae43b19a02179cfe37b3294"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ChangeResourceOwnerAction.Result res = action.call()
查看资源所属账户(GetResourceAccount)
输入资源的UUID可以获得该资源所属账户
API请求
URLs
GET zstack/v1/resources/accountsHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X GET http://localhost:8080/zstack/v1/resources/accounts?resourceUuids=59fc59531b6639b3b0bd6263b021df4c&resourceUuids=77115316d36839e9b1a4f832f38de8ba参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| resourceUuids | List | query | 0.6 | ||
| systemTags (可选) | List | query | 0.6 | ||
| userTags (可选) | List | query | 0.6 |
API返回
返回示例
{
"inventories": {
"db4e395223813bafa838ce4285a78757": {
"uuid": "ef68adaf368335ab8d15a4c2195749a7",
"name": "test",
"type": "Normal"
},
"736ee9f80a2230658e999c17e5be1835": {
"uuid": "ef68adaf368335ab8d15a4c2195749a7",
"name": "test",
"type": "Normal"
}
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventories | Map | 详情参考inventories | 0.6 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 账户的UUID,唯一标示该资源 | 4.0.0 |
| name | String | 账户名称 | 4.0.0 |
| description | String | 账户的详细描述 | 4.0.0 |
| type | String | 账户类型 | 4.0.0 |
| source | String | 账户来源,创建时确定且不可修改 | 5.1.0 |
| state | String | 账户状态 | 4.0.0 |
| createDate | Timestamp | 创建时间 | 4.0.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.0.0 |
SDK示例
Java SDK
GetResourceAccountAction action = new GetResourceAccountAction();
action.resourceUuids = asList("59fc59531b6639b3b0bd6263b021df4c","77115316d36839e9b1a4f832f38de8ba");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetResourceAccountAction.Result res = action.call();Python SDK
action = GetResourceAccountAction()
action.resourceUuids = [59fc59531b6639b3b0bd6263b021df4c, 77115316d36839e9b1a4f832f38de8ba]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()验证会话的有效性(ValidateSession)
API请求
URLs
GET zstack/v1/accounts/sessions/{sessionUuid}/validCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-X GET http://localhost:8080/zstack/v1/accounts/sessions/525912127c633468b4fe142528ee3f3b/valid参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| sessionUuid | String | url | 会话UUID | 0.6 | |
| systemTags (可选) | List | query | 系统标签 | 0.6 | |
| userTags (可选) | List | query | 用户标签 | 0.6 |
API返回
返回示例
{
"validSession": true
}
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| valid | boolean | 会话是否有效 | 0.6 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
SDK示例
Java
SDK
ValidateSessionAction action = new ValidateSessionAction();
action.sessionUuid = "525912127c633468b4fe142528ee3f3b";
ValidateSessionAction.Result res = action.call();
Python
SDK
ValidateSessionAction action = ValidateSessionAction()
action.sessionUuid = "525912127c633468b4fe142528ee3f3b"
ValidateSessionAction.Result res = action.call()
更新会话(RenewSession)
API请求
URLs
PUT zstack/v1/accounts/sessions/{sessionUuid}/renewHeaders
Authorization: OAuth the-session-uuidBody
{
"renewSession": {
"duration": 100
},
"systemTags": [],
"userTags": []
}
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"renewSession":{"duration":100}}' \
http://localhost:8080/zstack/v1/accounts/sessions/7b93b7648aea3c8d9109498a32288470/renew参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| sessionUuid | String | url | 会话uuid | 2.3 | |
| duration (可选) | Long | body(包含在renewSession结构中) | 2.3 | ||
| systemTags (可选) | List | body | 系统标签 | 2.3 | |
| userTags (可选) | List | body | 用户标签 | 2.3 |
API返回
返回示例
{
"inventory": {
"uuid": "dce673d8c6d53988b188b4ac34e7304d",
"accountUuid": "fa58814a623d3778a8c91d11b74c6d38",
"expiredDate": "Nov 14, 2017 2:20:57 PM",
"noSessionEvaluation": false
}
}
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 0.6 |
| accountUuid | String | 账户UUID | 0.6 |
| userUuid | String | 用户UUID | 0.6 |
| expiredDate | Timestamp | 会话过期日期 | 0.6 |
| createDate | Timestamp | 创建时间 | 0.6 |
SDK示例
Java
SDK
RenewSessionAction action = new RenewSessionAction();
action.sessionUuid = "7b93b7648aea3c8d9109498a32288470";
action.duration = 100;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RenewSessionAction.Result res = action.call();
Python
SDK
RenewSessionAction action = RenewSessionAction()
action.sessionUuid = "7b93b7648aea3c8d9109498a32288470"
action.duration = 100
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
RenewSessionAction.Result res = action.call()
登录(LogIn)
API 请求
URLs
PUT zstack/v1/loginHeaders
Authorization: OAuth the-session-uuidBody
{
"logIn": {
"username": "admin",
"password": "password",
"loginType": "iam1"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-X PUT -d '{"logIn":{"username":"admin","password":"password","loginType":"iam1"}}' \
http://localhost:8080/zstack/v1/login参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| username | String | body(包含在logIn结构中) |
用户名 | 4.6.0 | |
| password | String | body(包含在logIn结构中) |
用户密码 | 4.6.0 | |
| loginType | String | body(包含在logIn结构中) |
用户类型 | 4.6.0 | |
| captchaUuid (可选) | String | body(包含在logIn结构中) |
验证码uuid | 4.6.0 | |
| verifyCode (可选) | String | body(包含在logIn结构中) |
验证码 | 4.6.0 | |
| clientInfo (可选) | Map | body(包含在logIn结构中) |
客户端信息 | 4.6.0 | |
| properties (可选) | Map | body(包含在logIn结构中) |
登录属性 | 4.6.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.6.0 | |
| userTags (可选) | List | body | 用户标签 | 4.6.0 |
API返回
返回示例
{
"inventory": {
"uuid": "5d77893e242d39ec8b9856a7b8762eab",
"accountUuid": "7ab57f322e4a396b8124ed4fda810966",
"expiredDate": "Nov 14, 2017 2:20:57 PM",
"noSessionEvaluation": false
}
}#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 0.6 |
| accountUuid | String | 账户UUID | 0.6 |
| userUuid | String | 用户UUID | 0.6 |
| expiredDate | Timestamp | 0.6 | |
| createDate | Timestamp | 创建时间 | 0.6 |
SDK示例
Java
SDK
LogInAction action = new LogInAction();
action.username = "admin";
action.password = "password";
action.loginType = "iam1";
LogInAction.Result res = action.call();Python
SDK
LogInAction action = LogInAction()
action.username = "admin"
action.password = "password"
action.loginType = "iam1"
LogInAction.Result res = action.call()退出当前登录状态(LogOut)
API请求
URLs
DELETE zstack/v1/accounts/sessions/{sessionUuid}
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-X DELETE http://localhost:8080/zstack/v1/accounts/sessions/77b3af8ddd67334ebdec0b2e32d1559b参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| sessionUuid (可选) | String | url | 会话UUID | 0.6 | |
| clientInfo (可选) | Map | body(包含在logInByAccount结构中) | 客户端信息 | 3.5.0 | |
| systemTags (可选) | List | body | 系统标签 | 0.6 | |
| userTags (可选) | List | body | 用户标签 | 0.6 |
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
LogOutAction action = new LogOutAction();
action.sessionId = "0c7e729fb59945938752cd4ec99c2a94";
LogOutAction.Result res = action.call();Python
SDK
LogOutAction action = LogOutAction()
action.sessionId = "1cb84b3f5713432aaf42bc230c32aa20"
LogOutAction.Result res = action.call()删除角色 (DeleteRole)
API 请求
URLs
DELETE zstack/v1/identities/roles/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/identities/roles/6576d603b86634d68d49e9df50443e7f参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 角色的UUID,唯一标示该资源 | 4.10.0 | |
| deleteMode (可选) | String | body | 删除模式。'Permissive' 是删除前检查模式, 如果这个角色还绑定着账户, 删除会失败; 'Enforcing' 是强制删除模式, 如果这个角色还绑定着账户,哪些账户自动解绑角色 | 4.10.0 | |
| system Tags (可选) | List | body | 系统标签 | 4.10.0 | |
| userTags (可选) | List | body | 用户标签 | 4.10.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
DeleteRoleAction action = new DeleteRoleAction();
action.uuid = "6576d603b86634d68d49e9df50443e7f";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteRoleAction.Result res = action.call();
Python
SDK
DeleteRoleAction action = DeleteRoleAction()
action.uuid = "6576d603b86634d68d49e9df50443e7f"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteRoleAction.Result res = action.call()
查询角色 (QueryRole)
API 请求
URLs
GET zstack/v1/identities/roles
GET zstack/v1/identities/roles/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/identities/rolescurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/identities/roles/159398ac7d57325daeb62f4abbc5107b可查询字段
运行CLI命令行工具,输入QueryRole并按Tab键查看所有可查询字段以及可跨表查询的资源名。
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
QueryRoleAction action = new QueryRoleAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryRoleAction.Result res = action.call();
Python
SDK
QueryRoleAction action = QueryRoleAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryRoleAction.Result res = action.call()
获取角色权限行动 (GetRolePolicyActions)
API 请求
URLs
GET zstack/v1/identities/role/policy-actionsHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/identities/role/policy-actions?showAllPolicies=false参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| systemTags (可选) | List | query | 系统标签 | 4.10.0 | |
| userTags (可选) | List | query | 用户标签 | 4.10.0 | |
| showAllPolicies (可选) | boolean | query | 是否查询系统内所有角色权限。true 则查询查询系统内所有角色权限,false 仅查询当前账户拥有的角色和权限 | 4.10.0 |
API返回
返回示例
{
"policies": [
".header.identity.APIChangeResourceOwnerMsg",
".header.identity.APICheckResourcePermissionMsg",
".header.identity.APICreateAccountMsg",
".header.identity.APIDeleteAccountMsg",
".header.identity.APIGetAccountQuotaUsageMsg",
".header.identity.APIGetResourceAccountMsg",
".header.identity.APILogInByAccountMsg",
".header.identity.APILogOutMsg",
".header.identity.APIQueryAccountMsg",
".header.identity.APIQueryAccountResourceRefMsg",
".header.identity.APIQueryQuotaMsg",
".header.identity.APIRenewSessionMsg",
".header.identity.APIRevokeResourceSharingMsg",
".header.identity.APIShareResourceMsg",
".header.identity.APIUpdateAccountMsg",
".header.identity.APIUpdateQuotaMsg",
".header.identity.APIValidateSessionMsg"
]
}
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| inventories | List | 所有匹配的行动 | 4.10.0 |
| success | boolean | 请求是否成功 | 4.10.0 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.10.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
SDK示例
Java
SDK
GetRolePolicyActionsAction action = new GetRolePolicyActionsAction();
action.showAllPolicies = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetRolePolicyActionsAction.Result res = action.call();
Python
SDK
GetRolePolicyActionsAction action = GetRolePolicyActionsAction()
action.showAllPolicies = false
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetRolePolicyActionsAction.Result res = action.call()
查询角色账户关系 (QueryRoleAccountRef)
API请求
URLs
GET zstack/v1/identities/role-account-refsHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/identities/role-account-refs?q=roleUuid=686cb963323e491e955a0fd0b49dd743可查询字段
运行CLI命令行工具,输入QuerySharedResource并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"roleUuid": "686cb963323e491e955a0fd0b49dd743",
"accountUuid": "5360250ef145409e862b4e99d2b2efc4",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
]
}
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 查询是否成功 | 4.10.0 |
| inventories | List | 详情参考inventories | 4.10.0 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.10.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| roleUuid | String | 角色 UUID | 4.10.0 |
| accountUuid | String | 账户 UUID | 4.10.0 |
| accountPermissionFrom | String | 账户权限来源, 如果账户是通过加入某个账户组而获得的角色, 那么这个值就是那个账户组的 UUID。如果账户直接绑定了角色, 这个值为 null | 4.10.0 |
| createDate | Timestamp | 创建时间 | 4.10.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.10.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
SDK示例
Java
SDK
QueryRoleAccountRefAction action = new QueryRoleAccountRefAction();
action.conditions = asList("roleUuid=686cb963323e491e955a0fd0b49dd743");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryRoleAccountRefAction.Result res = action.call();
Python
SDK
QueryRoleAccountRefAction action = QueryRoleAccountRefAction()
action.conditions = ["roleUuid=686cb963323e491e955a0fd0b49dd743"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryRoleAccountRefAction.Result res = action.call()
绑定角色和账户 (AttachRoleToAccount)
API 请求
URLs
POST zstack/v1/identities/accounts/{accountUuid}/roles/{roleUuid}Headers
Authorization: OAuth the-session-uuidBody
{
"params": {},
"systemTags": [],
"userTags": []
}
Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{}}' \
http://localhost:8080/zstack/v1/identities/accounts/053a25bbfe2c34a889d75601e64d4a51/roles/b7a901c45db33f12993c9c7aad874ff4参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| roleUuid | String | url | 角色 UUID | 4.10.0 | |
| accountUuid | String | url | 账户 UUID | 4.10.0 | |
| system Tags (可选) | List | body | 系统标签 | 4.10.0 | |
| userTags (可选) | List | body | 用户标签 | 4.10.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
AttachRoleToAccountAction action = new AttachRoleToAccountAction();
action.roleUuid = "b7a901c45db33f12993c9c7aad874ff4";
action.accountUuid = "053a25bbfe2c34a889d75601e64d4a51";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AttachRoleToAccountAction.Result res = action.call();
Python
SDK
AttachRoleToAccountAction action = AttachRoleToAccountAction()
action.roleUuid = "b7a901c45db33f12993c9c7aad874ff4"
action.accountUuid = "053a25bbfe2c34a889d75601e64d4a51"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AttachRoleToAccountAction.Result res = action.call()
解绑角色和账户 (DetachRoleFromAccount)
API 请求
URLs
DELETE zstack/v1/identities/accounts/{accountUuid}/roles/{roleUuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/identities/accounts/ac3ea9154a603cbcabbb1664dbcf66ef/roles/ca3f332b7ffd347fa30ba01be1176b96参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| roleUuid | String | url | 角色 UUID | 4.10.0 | |
| accountUuid | String | url | 账户 UUID | 4.10.0 | |
| deleteMode (可选) | String | body | 删除模式, 当前 API 该字段无效 | 4.10.0 | |
| system Tags (可选) | List | body | 系统标签 | 4.10.0 | |
| userTags (可选) | List | body | 用户标签 | 4.10.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
DetachRoleFromAccountAction action = new DetachRoleFromAccountAction();
action.roleUuid = "ca3f332b7ffd347fa30ba01be1176b96";
action.accountUuid = "ac3ea9154a603cbcabbb1664dbcf66ef";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DetachRoleFromAccountAction.Result res = action.call();
Python
SDK
DetachRoleFromAccountAction action = DetachRoleFromAccountAction()
action.roleUuid = "ca3f332b7ffd347fa30ba01be1176b96"
action.accountUuid = "ac3ea9154a603cbcabbb1664dbcf66ef"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DetachRoleFromAccountAction.Result res = action.call()
为账户绑定 CCS 证书 (AttachCCSCertificateToUser)
API 请求
URLs
POST zstack/v1/crypto/ccs-certificate/attach-account/{accountUuid}Headers
Authorization: OAuth the-session-uuidBody
{
"params": {
"certificateUuid": "37efdf76b03a3028926549ea5f1253f3",
"state": "enable"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"certificateUuid":"37efdf76b03a3028926549ea5f1253f3","state":"enable"}}' \
http://localhost:8080/zstack/v1/crypto/ccs-certificate/attach-account/e0deabb1107f32e7b715d6b5e7f39334参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| certificateUuid (可选) | String | body(包含在params结构中) |
CCS 证书的 UUID | 4.10.0 | |
| accountUuid | String | url | 账户 UUID | 4.10.0 | |
| state (可选) | String | body(包含在params结构中)vv |
启用或禁用,在用户绑定 CCS 证书的同时是否启用通过 UKey 认证登录,enable 表示启用,则后续该用户登录时必须要通过 UKey 认证;disable 表示暂时不启用,但可以通过 UpdateCCSCertificateUserState 开启 |
|
4.10.0 |
| system Tags (可选) | List | body | 系统标签 | 4.10.0 | |
| userTags (可选) | List | body | 用户标签 | 4.10.0 |
API返回
返回示例
{
"inventory": {
"uuid": "271c21f7ef8c4385b09846341cc9deac",
"algorithm": "SM2",
"format": "CER",
"issuerDN": "C\u003dcn,O\u003dinfosec,OU\u003dsystem,CN\u003dca62_sm2",
"subjectDN": "C\u003dCN,O\u003dZStack,OU\u003dZStack,CN\u003dZStackTest2",
"serNumber": "13055887750776402041",
"effectiveTime": "Oct 15, 2021 10:50:09 AM",
"expirationTime": "Oct 15, 2024 10:50:09 AM"
}
}#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.3.12 |
| algorithm | String | 证书类型 | 4.3.12 |
| format | String | 证书格式,国密是 CER,还有 CRT、DER、JKS 等 | 4.3.12 |
| issuerDN | String | 签发人 DN, 又叫 issuer-DN-distinguished name 比如 CN=sm2,O=test,C=cn | 4.3.12 |
| subjectDN | String | 主题 DN | 4.3.12 |
| serNumber | Long | 证书序列号,加上 subjectDN 一起作为双键是全网唯一 | 4.3.12 |
| effectiveTime | Timestamp | 开始生效的日期 | 4.3.12 |
| expirationTime | Timestamp | 过期日期 | 4.3.12 |
| createDate | Timestamp | 创建时间 | 4.3.12 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.3.12 |
| userCertificateRefs | List | 详情参考userCertificateRefs | 4.3.12 |
#userCertificateRefs
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| userUuid | String | 用户UUID | 4.3.12 |
| certificateUuid | String | CCS 证书 UUID | 4.3.12 |
| createDate | Timestamp | 创建时间 | 4.3.12 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.3.12 |
| state | CCSCertificateUserState | 详情参考state | 4.3.12 |
#state
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| Enabled | CCSCertificateUserState | 需要验证 | 4.3.12 |
| Disabled | CCSCertificateUserState | 不需要验证 | 4.3.12 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
SDK示例
Java
SDK
AttachCCSCertificateToAccountAction action = new AttachCCSCertificateToAccountAction();
action.certificateUuid = "37efdf76b03a3028926549ea5f1253f3";
action.accountUuid = "e0deabb1107f32e7b715d6b5e7f39334";
action.state = "enable";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AttachCCSCertificateToAccountAction.Result res = action.call();Python
SDK
AttachCCSCertificateToAccountAction action = AttachCCSCertificateToAccountAction()
action.certificateUuid = "37efdf76b03a3028926549ea5f1253f3"
action.accountUuid = "e0deabb1107f32e7b715d6b5e7f39334"
action.state = "enable"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AttachCCSCertificateToAccountAction.Result res = action.call()账户解绑 CCS 证书 (DetachCCSCertificateFromUser)
API 请求
URLs
POST zstack/v1/crypto/ccs-certificate/detach-account/{accountUuid}Headers
Authorization: OAuth the-session-uuidBody
{
"params": {},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{}}' \
http://localhost:8080/zstack/v1/crypto/ccs-certificate/detach-account/0f708fb369393654acdf1f145a2408c2参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| accountUuid | String | url | 需要解绑的用户 UUID | 4.10.0 | |
| system Tags (可选) | List | body | 系统标签 | 4.10.0 | |
| userTags (可选) | List | body | 用户标签 | 4.10.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
DetachCCSCertificateFromAccountAction action = new DetachCCSCertificateFromAccountAction();
action.accountUuid = "0f708fb369393654acdf1f145a2408c2";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DetachCCSCertificateFromAccountAction.Result res = action.call();Python
SDK
DetachCCSCertificateFromAccountAction action = DetachCCSCertificateFromAccountAction()
action.accountUuid = "0f708fb369393654acdf1f145a2408c2"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DetachCCSCertificateFromAccountAction.Result res = action.call()更新账户绑定的 CCS 证书的状态 (UpdateCCSCertificateUserState)
API 请求
URLs
POST zstack/v1/crypto/ccs-certificate/update-state/{accountUuid}Headers
Authorization: OAuth the-session-uuidBody
{
"params": {
"state": "enable"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"state":"enable"}}' \
http://localhost:8080/zstack/v1/crypto/ccs-certificate/update-state/c418d26244b43e31bfe400652695f62a参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| accountUuid | String | url | 账户UUID | 4.10.0 | |
| state | String | body(包含在params结构中) |
状态,描述是否在下次登录时启用该证书的校验 |
|
4.10.0 |
| system Tags (可选) | List | body | 系统标签 | 4.10.0 | |
| userTags (可选) | List | body | 用户标签 | 4.10.0 |
API返回
返回示例
{
"inventory": {
"uuid": "4e1cab9a3a0f4a1eb6a919510814d8f8",
"algorithm": "SM2",
"format": "CER",
"issuerDN": "C\u003dcn,O\u003dinfosec,OU\u003dsystem,CN\u003dca62_sm2",
"subjectDN": "C\u003dCN,O\u003dZStack,OU\u003dZStack,CN\u003dZStackTest2",
"serNumber": "13055887750776402041",
"effectiveTime": "Oct 15, 2021 10:50:09 AM",
"expirationTime": "Oct 15, 2024 10:50:09 AM"
}
}#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.3.12 |
| algorithm | String | 证书类型 | 4.3.12 |
| format | String | 证书格式,国密是 CER,还有 CRT、DER、JKS 等 | 4.3.12 |
| issuerDN | String | 签发人 DN, 又叫 issuer-DN-distinguished name 比如 CN=sm2,O=test,C=cn | 4.3.12 |
| subjectDN | String | 主题 DN | 4.3.12 |
| serNumber | Long | 证书序列号,加上 subjectDN 一起作为双键是全网唯一 | 4.3.12 |
| effectiveTime | Timestamp | 开始生效的日期 | 4.3.12 |
| expirationTime | Timestamp | 过期日期 | 4.3.12 |
| createDate | Timestamp | 创建时间 | 4.3.12 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.3.12 |
| userCertificateRefs | List | 详情参考userCertificateRefs | 4.3.12 |
#userCertificateRefs
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| userUuid | String | 用户UUID | 4.3.12 |
| certificateUuid | String | CCS 证书 UUID | 4.3.12 |
| createDate | Timestamp | 创建时间 | 4.3.12 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.3.12 |
| state | CCSCertificateUserState | 详情参考state | 4.3.12 |
#state
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| Enabled | CCSCertificateUserState | 需要验证 | 4.3.12 |
| Disabled | CCSCertificateUserState | 不需要验证 | 4.3.12 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
SDK示例
Java
SDK
UpdateCCSCertificateAccountStateAction action = new UpdateCCSCertificateAccountStateAction();
action.accountUuid = "c418d26244b43e31bfe400652695f62a";
action.state = "enable";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateCCSCertificateAccountStateAction.Result res = action.call();Python
SDK
UpdateCCSCertificateAccountStateAction action = UpdateCCSCertificateAccountStateAction()
action.accountUuid = "c418d26244b43e31bfe400652695f62a"
action.state = "enable"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateCCSCertificateAccountStateAction.Result res = action.call()变更账户类型(提权/降权)(ChangeAccountType)
API 请求
URLs
PUT zstack/v1/accounts/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"changeAccountType": {
"type": "SystemAdmin"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"changeAccountType":{"type":"SystemAdmin"}}' \
http://localhost:8080/zstack/v1/accounts/f0c72e5b9d723dbaa716d2f0fad341d9/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 5.0.0 | |
| type | String | body(包含在changeAccountType结构中) |
账户类型,SystemAdmin表示管理员,Normal表示普通用户(Normal暂不支持,即暂不支持降权) | 5.0.0 | |
| system Tags (可选) | List | body | 系统标签 | 5.0.0 | |
| userTags (可选) | List | body | 用户标签 | 5.0.0 |
SDK示例
Java SDK
ChangeAccountTypeAction action = new ChangeAccountTypeAction();
action.uuid = "f0c72e5b9d723dbaa716d2f0fad341d9";
action.type = "SystemAdmin";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangeAccountTypeAction.Result res = action.call();Python SDK
action = ChangeAccountTypeAction()
action.uuid = "f0c72e5b9d723dbaa716d2f0fad341d9"
action.type = "SystemAdmin"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()