统一认证服务器相关接口
查询统一认证用户来源绑定关系 (QueryThirdPartyAccountSourceBinding)
查询第三方用户来源绑定关系
API请求
URLs
GET zstack/v1/account-import/bindingsHeaders
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-import/bindings?q=accountUuid=ff0b33166633399aae77ea258d2f7900可查询字段
运行CLI命令行工具,输入QueryThirdPartyAccountSourceBinding并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"id": 1,
"credentials": "ou\u003dEmployee,uid\u003dtest",
"accountSourceUuid": "ff0df349f4d13f4081d57b3715851900",
"accountUuid": "ff0b33166633399aae77ea258d2f7900"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 请求是否成功 | 4.3.0 |
| error | ErrorCode | 详情参考error | 4.3.0 |
| inventories | List | 详情参考inventories | 4.3.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
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| id | Long | 唯一标示该关系 | 4.3.0 |
| credentials | String | 导入源使用的用户唯一标识,例如LDAP源导入的用户则为登录使用的UID | 4.3.0 |
| accountSourceUuid | String | 导入源服务器 UUID | 4.3.0 |
| accountUuid | String | 账户UUID | 4.3.0 |
| createDate | Timestamp | 创建时间 | 4.3.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.3.0 |
SDK示例
Java SDK
QueryThirdPartyAccountSourceBindingAction action = new QueryThirdPartyAccountSourceBindingAction();
action.conditions = asList("accountUuid=ff0b33166633399aae77ea258d2f7900");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryThirdPartyAccountSourceBindingAction.Result res = action.call();Python SDK
action = QueryThirdPartyAccountSourceBindingAction()
action.conditions = ["accountUuid=ff0b33166633399aae77ea258d2f7900"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()添加LDAP服务器 (AddLdapServer)
API请求
URLs
POST zstack/v1/ldap/serversHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "miao",
"description": "miao desc",
"url": "ldap://localhost:1888",
"base": "dc\u003dexample,dc\u003dcom",
"username": "",
"password": "",
"encryption": "None",
"serverType": "WindowsAD",
"usernameProperty": "cn",
"filter": "(cn\u003dMicha Kops)",
"syncCreatedAccountStrategy": "CreateAccount",
"syncDeletedAccountStrategy": "StaleAccount"
},
"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":"miao","description":"miao desc","url":"ldap://localhost:1888","base":"dc=example,dc=com","username":"","password":"","encryption":"None","serverType":"WindowsAD","usernameProperty":"cn","filter":"(cn=Micha Kops)","syncCreatedAccountStrategy":"CreateAccount","syncDeletedAccountStrategy":"StaleAccount"}}' \
http://localhost:8080/zstack/v1/ldap/servers参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在params结构中) |
资源名称 | 4.3.0 | |
| description (可选) | String | body(包含在params结构中) |
资源的详细描述 | 4.3.0 | |
| url | String | body(包含在params结构中) |
LDAP服务器访问地址 | 4.3.0 | |
| base | String | body(包含在params结构中) |
LDAP服务查询BaseDN | 4.3.0 | |
| username | String | body(包含在params结构中) |
访问LDAP服务器使用的用户名 | 4.3.0 | |
| password | String | body(包含在params结构中) |
密码 | 4.3.0 | |
| encryption | String | body(包含在params结构中) |
加密方式 |
|
4.3.0 |
| systemTags (可选) | List | body | 系统标签 | 4.3.0 | |
| userTags (可选) | List | body | 用户标签 | 4.3.0 | |
| serverType (可选) | String | body(包含在params结构中) |
LDAP服务器类型 |
|
4.3.0 |
| usernameProperty (可选) | String | body(包含在params结构中) |
用户登录该虚拟化平台时使用哪个字段用作用户名 | 4.3.0 | |
| filter (可选) | String | body(包含在params结构中) |
从LDAP服务器同步时,使用的过滤器,确定哪些用户是需要同步的 | 4.3.0 | |
| syncCreatedAccountStrategy (可选) | String | body(包含在params结构中) |
从LDAP服务器同步时,对于LDAP服务器中新创建的用户,该虚拟化平台的处理策略,是创建对应的account还是无动作 |
|
4.3.0 |
| syncDeletedAccountStrategy (可选) | String | body(包含在params结构中) |
从LDAP服务器同步时,对于LDAP服务器中已删除的用户,该虚拟化平台的处理策略,是删除对应的account、标记已删除还是无动作 |
|
4.3.0 |
API返回
返回示例
{
"inventory": {
"uuid": "01b489793e3d31728ccbbc4fdfd99ed0",
"name": "miao",
"description": "miao desc",
"url": "ldap://localhost:1888",
"base": "dc\u003dexample,dc\u003dcom",
"username": "",
"password": "",
"encryption": "None"
}
}#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.3.0 |
| name | String | 资源名称 | 4.3.0 |
| type | String | 用户源类型,一般是ldap | 4.3.0 |
| description | String | 资源的详细描述 | 4.3.0 |
| url | String | 4.3.0 | |
| base | String | LDAP服务器访问地址 | 4.3.0 |
| username | String | 用于访问LDAP服务器的用户名 | 4.3.0 |
| password | String | 密码 | 4.3.0 |
| encryption | String | 加密方式 | 4.3.0 |
| serverType | String | 服务器类型,可能是OpenLdap或WindowsAD,如果不确定会返回Unknown | 4.3.0 |
| createDate | Timestamp | 创建时间 | 4.3.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.3.0 |
SDK示例
Java
SDK
AddLdapServerAction action = new AddLdapServerAction();
action.name = "miao";
action.description = "miao desc";
action.url = "ldap://localhost:1888";
action.base = "dc=example,dc=com";
action.username = "";
action.password = "";
action.encryption = "None";
action.serverType = "WindowsAD";
action.usernameProperty = "cn";
action.filter = "(cn=Micha Kops)";
action.syncCreatedAccountStrategy = "CreateAccount";
action.syncDeletedAccountStrategy = "StaleAccount";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddLdapServerAction.Result res = action.call();Python
SDK
AddLdapServerAction action = AddLdapServerAction()
action.name = "miao"
action.description = "miao desc"
action.url = "ldap://localhost:1888"
action.base = "dc=example,dc=com"
action.username = ""
action.password = ""
action.encryption = "None"
action.serverType = "WindowsAD"
action.usernameProperty = "cn"
action.filter = "(cn=Micha Kops)"
action.syncCreatedAccountStrategy = "CreateAccount"
action.syncDeletedAccountStrategy = "StaleAccount"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AddLdapServerAction.Result res = action.call()删除LDAP服务器 (DeleteLdapServer)
API请求
URLs
DELETE zstack/v1/ldap/servers/{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/ldap/servers/01d547012c9a39cf85964e578842f5a5参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 4.3.0 | |
| deleteMode (可选) | String | body | 删除模式 | 4.3.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.3.0 | |
| userTags (可选) | List | body | 用户标签 | 4.3.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
DeleteLdapServerAction action = new DeleteLdapServerAction();
action.uuid = "01d547012c9a39cf85964e578842f5a5";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteLdapServerAction.Result res = action.call();
Python
SDK
DeleteLdapServerAction action = DeleteLdapServerAction()
action.uuid = "01d547012c9a39cf85964e578842f5a5"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteLdapServerAction.Result res = action.call()
查询LDAP服务器 (QueryLdapServer)
API请求
URLs
GET zstack/v1/ldap/servers
GET zstack/v1/ldap/servers/{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/ldap/servers?q=name=ldap servercurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/ldap/servers/68ff5ef58b4634dba740b26db67d3b01可查询字段
运行CLI命令行工具,输入QueryLdapServer并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"uuid": "fea82960cbaa33bb9f3de91c8054af8d",
"name": "miao",
"description": "miao desc",
"url": "ldap://localhost:1888",
"base": "dc\u003dexample,dc\u003dcom",
"username": "",
"password": "",
"encryption": "None"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 4.3.0 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.3.0 |
| inventories | List | 详情参考inventories | 4.3.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 | Long | 资源的UUID,唯一标示该资源 | 4.3.0 |
| name | String | 资源名称 | 4.3.0 |
| type | String | 用户源类型,一般是ldap | 4.3.0 |
| description | String | 资源的详细描述 | 4.3.0 |
| url | String | 4.3.0 | |
| base | String | LDAP服务器访问地址 | 4.3.0 |
| username | String | 用于访问LDAP服务器的用户名 | 4.3.0 |
| password | String | 密码 | 4.3.0 |
| encryption | String | 加密方式 | 4.3.0 |
| serverType | String | 服务器类型,可能是OpenLdap或WindowsAD,如果不确定会返回Unknown | 4.3.0 |
| createDate | Timestamp | 创建时间 | 4.3.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.3.0 |
SDK示例
Java
SDK
QueryLdapServerAction action = new QueryLdapServerAction();
action.conditions = asList("name=ldap server");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryLdapServerAction.Result res = action.call();
Python
SDK
QueryLdapServerAction action = QueryLdapServerAction()
action.conditions = ["name=ldap server"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryLdapServerAction.Result res = action.call()
更新LDAP服务器 (UpdateLdapServer)
API请求
URLs
PUT zstack/v1/ldap/servers/{ldapServerUuid}Headers
Authorization: OAuth the-session-uuidBody
{
"updateLdapServer": {
"name": "new name"
},
"systemTags": [],
"userTags": []
}
Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateLdapServer":{"name":"new name"}}' \
http://localhost:8080/zstack/v1/ldap/servers/ddd2491867273e6d8fb7c891faf0413f参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| ldapServerUuid | String | url | LDAP服务器的UUID | 4.3.0 | |
| name (可选) | String | body(包含在updateLdapServer结构中) |
资源名称 | 4.3.0 | |
| description (可选) | String | body(包含在updateLdapServer结构中) |
资源的详细描述 | 4.3.0 | |
| url (可选) | String | body(包含在updateLdapServer结构中) |
LDAP服务器的访问地址 | 4.3.0 | |
| base (可选) | String | body(包含在updateLdapServer结构中) |
LDAP服务器的查询BaseDN | 4.3.0 | |
| username (可选) | String | body(包含在updateLdapServer结构中) |
访问LDAP服务器的用户名 | 4.3.0 | |
| password (可选) | String | body(包含在updateLdapServer结构中) |
密码 | 4.3.0 | |
| encryption (可选) | String | body(包含在updateLdapServer结构中) |
加密方式 |
|
4.3.0 |
| systemTags (可选) | List | body | 系统标签 | 4.3.0 | |
| userTags (可选) | List | body | 用户标签 | 4.3.0 | |
| serverType (可选) | String | body(包含在updateLdapServer结构中) |
LDAP服务器类型 |
|
4.3.0 |
| usernameProperty (可选) | String | body(包含在updateLdapServer结构中) |
用户登录该虚拟化平台时使用哪个字段用作用户名 | 4.3.0 | |
| filter (可选) | String | body(包含在updateLdapServer结构中) |
从LDAP服务器同步时,使用的过滤器,确定哪些用户是需要同步的 | 4.3.0 | |
| syncCreatedAccountStrategy (可选) | String | body(包含在updateLdapServer结构中) |
在从LDAP服务器同步时,对于LDAP服务器中新创建的用户,该虚拟化平台的处理策略,是创建对应的account还是无动作 |
|
4.3.0 |
| syncDeletedAccountStrategy (可选) | String | body(包含在updateLdapServer结构中) |
在从LDAP服务器同步时,对于LDAP服务器中已删除的用户,该虚拟化平台的处理策略,是删除对应的account、标记已删除还是无动作 |
|
4.3.0 |
API返回
返回示例
{
"inventory": {
"uuid": "5c502802c9633f4398e9f286d8187f49",
"name": "new name",
"description": "miao desc",
"url": "ldap://localhost:1888",
"base": "dc\u003dexample,dc\u003dcom",
"username": "",
"password": "",
"encryption": "None"
}
}#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.3.0 |
| name | String | 资源名称 | 4.3.0 |
| type | String | 用户源类型,一般是ldap | 4.3.0 |
| description | String | 资源的详细描述 | 4.3.0 |
| url | String | 4.3.0 | |
| base | String | LDAP服务器访问地址 | 4.3.0 |
| username | String | 用于访问LDAP服务器的用户名 | 4.3.0 |
| password | String | 密码 | 4.3.0 |
| encryption | String | 加密方式 | 4.3.0 |
| serverType | String | 服务器类型,可能是OpenLdap或WindowsAD,如果不确定会返回Unknown | 4.3.0 |
| createDate | Timestamp | 创建时间 | 4.3.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.3.0 |
SDK示例
Java
SDK
UpdateLdapServerAction action = new UpdateLdapServerAction();
action.ldapServerUuid = "ddd2491867273e6d8fb7c891faf0413f";
action.name = "new name";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateLdapServerAction.Result res = action.call();
Python
SDK
UpdateLdapServerAction action = UpdateLdapServerAction()
action.ldapServerUuid = "ddd2491867273e6d8fb7c891faf0413f"
action.name = "new name"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateLdapServerAction.Result res = action.call()
创建LDAP绑定 (CreateLdapBinding)
API请求
URLs
POST zstack/v1/ldap/bindingsHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"ldapUid": "ou\u003dEmployee,uid\u003dtest",
"accountUuid": "ed7d933c7a6d37fb9bd444140faeec5c"
},
"systemTags": [],
"userTags": []
}
Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"ldapUid":"ou=Employee,uid=test","accountUuid":"ed7d933c7a6d37fb9bd444140faeec5c"}}' \
http://localhost:8080/zstack/v1/ldap/bindings参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| ldapUid | String | body(包含在params结构中) |
LDAP UID | 4.3.0 | |
| accountUuid | String | body(包含在params结构中) |
账户UUID | 4.3.0 | |
| ldapServerUuid (可选) | String | body(包含在params结构中) |
LDAP服务器UUID。如果不指定,系统会选择当前正在使用的LDAP服务器的UUID | 4.3.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.3.0 | |
| userTags (可选) | List | body | 用户标签 | 4.3.0 |
API返回
返回示例
{
"inventory": {
"id": 1,
"credentials": "ou\u003dEmployee,uid\u003dtest",
"accountSourceUuid": "41006790733e38db9ce810878e19f8a3",
"accountUuid": "3be58c2832a939bf9bce2ea959e04ce8"
}
}
#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
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| id | Long | 唯一标示该关系 | 4.3.0 |
| credentials | String | 导入源使用的用户唯一标识,例如LDAP源导入的用户则为登录使用的UID | 4.3.0 |
| accountSourceUuid | String | 导入源服务器UUID | 4.3.0 |
| accountUuid | String | 账户UUID | 4.3.0 |
| createDate | Timestamp | 创建时间 | 4.3.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.3.0 |
SDK示例
Java
SDK
CreateLdapBindingAction action = new CreateLdapBindingAction();
action.ldapUid = "ou=Employee,uid=test";
action.accountUuid = "ed7d933c7a6d37fb9bd444140faeec5c";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateLdapBindingAction.Result res = action.call();
Python
SDK
CreateLdapBindingAction action = CreateLdapBindingAction()
action.ldapUid = "ou=Employee,uid=test"
action.accountUuid = "ed7d933c7a6d37fb9bd444140faeec5c"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateLdapBindingAction.Result res = action.call()
删除LDAP绑定 (DeleteLdapBinding)
API请求
URLs
DELETE zstack/v1/ldap/bindings/{accountUuid}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/ldap/bindings/f1fb55eee96c3437991a0055d5d0abaa参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| accountUuid | String | url | 账户UUID | 4.3.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.3.0 | |
| userTags (可选) | List | body | 用户标签 | 4.3.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
DeleteLdapBindingAction action = new DeleteLdapBindingAction();
action.accountUuid = "f1fb55eee96c3437991a0055d5d0abaa";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteLdapBindingAction.Result res = action.call();Python
SDK
DeleteLdapBindingAction action = DeleteLdapBindingAction()
action.accountUuid = "f1fb55eee96c3437991a0055d5d0abaa"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteLdapBindingAction.Result res = action.call()查询可绑定的LDAP/AD条目 (GetCandidateLdapEntryForBinding)
API请求
URLs
GET zstack/v1/ldap/entries/candidatesHeaders
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/ldap/entries/candidates?ldapFilter=(cn=user_xxx)&limit=2500参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| ldapFilter | String | query | 查询条件 | 4.3.0 | |
| ldapServerUuid (可选) | String | query | 查询使用的LDAP服务器UUID。如果未指定会查找当前启用的LDAP服务器UUID | 4.3.0 | |
| systemTags (可选) | List | query | 系统标签 | 4.3.0 | |
| userTags (可选) | List | query | 用户标签 | 4.3.0 | |
| limit (可选) | Integer | query | 最多返回的记录数,类似MySQL的limit | 4.3.0 |
API返回
返回示例
{
"inventories": []
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 4.3.0 | |
| inventories | List | 4.3.0 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.3.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
GetCandidateLdapEntryForBindingAction action = new GetCandidateLdapEntryForBindingAction();
action.ldapFilter = "(cn=user_xxx)";
action.limit = 2500;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetCandidateLdapEntryForBindingAction.Result res = action.call();
Python
SDK
GetCandidateLdapEntryForBindingAction action = GetCandidateLdapEntryForBindingAction()
action.ldapFilter = "(cn=user_xxx)"
action.limit = 2500
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetCandidateLdapEntryForBindingAction.Result res = action.call()
查询LDAP/AD条目 (GetLdapEntry)
API请求
URLs
GET zstack/v1/ldap/entryHeaders
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/ldap/entry?ldapFilter=(cn=user_xxx)&limit=2500参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| ldapFilter | String | query | 查询条件 | 4.3.0 | |
| ldapServerUuid (可选) | String | query | 查询使用的LDAP服务器UUID。如果未指定会查找当前启用的LDAP服务器UUID | 4.3.0 | |
| systemTags (可选) | List | query | 系统标签 | 4.3.0 | |
| userTags (可选) | List | query | 用户标签 | 4.3.0 | |
| limit (可选) | Integer | query | 最多返回的记录数,类似MySQL的limit | 4.3.0 |
API返回
返回示例
{
"inventories": []
}
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 4.3.0 | |
| inventories | List | 4.3.0 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.3.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
GetLdapEntryAction action = new GetLdapEntryAction();
action.ldapFilter = "(cn=user_xxx)";
action.limit = 2500;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetLdapEntryAction.Result res = action.call();
Python
SDK
GetLdapEntryAction action = GetLdapEntryAction()
action.ldapFilter = "(cn=user_xxx)"
action.limit = 2500
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetLdapEntryAction.Result res = action.call()
从LDAP服务器上同步用户 (SyncAccountsFromLdapServer)
API请求
URLs
PUT zstack/v1/ldap/servers/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"syncAccountsFromLdapServer": {},
"systemTags": [],
"userTags": []
}
Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"syncAccountsFromLdapServer":{}}' \
http://localhost:8080/zstack/v1/ldap/servers/0fdb3f15019f362396cd13645d5e5135/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | LDAP服务器的UUID,唯一标示该资源 | 4.3.0 | |
| createAccountStrategy (可选) | String | body(包含在syncAccountsFromLdapServer结构中) |
从LDAP服务器同步时,对于LDAP服务器中新创建的用户,该虚拟化平台的处理策略,是创建对应的account还是无动作 | 4.3.0 | |
| deleteAccountStrategy (可选) | String | body(包含在syncAccountsFromLdapServer结构中) |
从LDAP服务器同步时,对于LDAP服务器中已删除的用户,该虚拟化平台的处理策略,是删除对应的account、标记已删除还是无动作 | 4.3.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.3.0 | |
| userTags (可选) | List | body | 用户标签 | 4.3.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
SyncAccountsFromLdapServerAction action = new SyncAccountsFromLdapServerAction();
action.uuid = "0fdb3f15019f362396cd13645d5e5135";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
SyncAccountsFromLdapServerAction.Result res = action.call();
Python
SDK
SyncAccountsFromLdapServerAction action = SyncAccountsFromLdapServerAction()
action.uuid = "0fdb3f15019f362396cd13645d5e5135"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
SyncAccountsFromLdapServerAction.Result res = action.call()
创建认证成功跳转的模版 (CreateSSORedirectTemplate)
API请求
URLs
POST zstack/v1/create/sso/redirect/template/Headers
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "test",
"description": "desc",
"clientUuid": "64053daa6b56335d843b3fb837fd8133",
"redirectTemplate": "http://172.24.194.28:5000/oauth1/verify/?username\u003d${username}\u0026sessionId\u003d${sessionId}\u0026userUuid\u003d${userUuid}\u0026accountUuid\u003d${accountUuid}\u0026loginType\u003d${loginType}\u0026userType\u003d${userType}\u0027"
},
"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","description":"desc","clientUuid":"64053daa6b56335d843b3fb837fd8133","redirectTemplate":"http://172.24.194.28:5000/oauth1/verify/?username=${username}&sessionId=${sessionId}&userUuid=${userUuid}&accountUuid=${accountUuid}&loginType=${loginType}&userType=${userType}'"}}' \
http://localhost:8080/zstack/v1/create/sso/redirect/template/参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在params结构中) |
资源名称 | 4.3.0 | |
| description | String | body(包含在params结构中) |
资源的详细描述 | 4.3.0 | |
| clientUuid | String | body(包含在params结构中) |
对应的 SSO 客户端 UUID,即第三方账户源的 UUID | 4.3.0 | |
| redirectTemplate | String | body(包含在params结构中) |
跳转的模版 | 4.3.0 | |
| resourceUuid (可选) | String | body(包含在params结构中) |
资源 UUID | 4.3.0 | |
| tagUuids (可选) | List | body(包含在params结构中) |
标签 UUID 列表 | 4.3.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.3.0 | |
| userTags (可选) | List | body | 用户标签 | 4.3.0 |
API返回
返回示例
{
"inventory": {
"uuid": "8b233284793c3da397f6ebd7351c3a54",
"name": "test",
"description": "desv",
"clientUuid": "827d2ea3ae8133bbba0b726c1d8e716d"
}
}#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 模版的 UUID,唯一标示该资源 | 4.3.0 |
| name | String | 模版名称 | 4.3.0 |
| description | String | 模版的详细描述 | 4.3.0 |
| clientUuid | String | 对应的 SSO 客户端 UUID,即第三方账户源的 UUID | 4.3.0 |
| redirectTemplate | String | 跳转的模板 | 4.3.0 |
| createDate | Timestamp | 创建时间 | 4.3.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.3.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
CreateSSORedirectTemplateAction action = new CreateSSORedirectTemplateAction();
action.name = "test";
action.description = "desc";
action.clientUuid = "64053daa6b56335d843b3fb837fd8133";
action.redirectTemplate = "http://172.24.194.28:5000/oauth1/verify/?username=${username}&sessionId=${sessionId}&userUuid=${userUuid}&accountUuid=${accountUuid}&loginType=${loginType}&userType=${userType}'";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateSSORedirectTemplateAction.Result res = action.call();Python
SDK
CreateSSORedirectTemplateAction action = CreateSSORedirectTemplateAction()
action.name = "test"
action.description = "desc"
action.clientUuid = "64053daa6b56335d843b3fb837fd8133"
action.redirectTemplate = "http://172.24.194.28:5000/oauth1/verify/?username=${username}&sessionId=${sessionId}&userUuid=${userUuid}&accountUuid=${accountUuid}&loginType=${loginType}&userType=${userType}'"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateSSORedirectTemplateAction.Result res = action.call()删除认证跳转模板 (DeleteSSORedirectTemplate)
API请求
URLs
POST zstack/v1/delete/sso/redirect/templateHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"uuid": "9df30dceb13a3989aa3bfa20051bae9a",
"deleteMode": "Permissive"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"uuid":"9df30dceb13a3989aa3bfa20051bae9a","deleteMode":"Permissive"}}' \
http://localhost:8080/zstack/v1/delete/sso/redirect/template参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | body(包含在params结构中) |
模板的 UUID,唯一标示该资源 | 4.3.0 | |
| deleteMode (可选) | String | body(包含在params结构中) |
删除模式(Permissive / Enforcing,Permissive) | 4.3.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.3.0 | |
| userTags (可选) | List | body | 用户标签 | 4.3.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
DeleteSSORedirectTemplateAction action = new DeleteSSORedirectTemplateAction();
action.uuid = "9df30dceb13a3989aa3bfa20051bae9a";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteSSORedirectTemplateAction.Result res = action.call();Python
SDK
DeleteSSORedirectTemplateAction action = DeleteSSORedirectTemplateAction()
action.uuid = "9df30dceb13a3989aa3bfa20051bae9a"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteSSORedirectTemplateAction.Result res = action.call()修改跳转模版 (UpdateSSORedirectTemplate)
API请求
URLs
POST zstack/v1/update/sso/redirectTemplateHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"uuid": "35cc6909f0f23e55a209cd552d8bc938",
"redirectTemplate": "http://zstack.com/userinfoUrl"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"uuid":"35cc6909f0f23e55a209cd552d8bc938","redirectTemplate":"http://zstack.com/userinfoUrl"}}' \
http://localhost:8080/zstack/v1/update/sso/redirectTemplate参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | body(包含在params结构中) |
模版的 UUID,唯一标示该资源 | 4.3.0 | |
| redirectTemplate | String | body(包含在params结构中) |
跳转的模板 | 4.3.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.3.0 | |
| userTags (可选) | List | body | 用户标签 | 4.3.0 |
API返回
返回示例
{
"inventory": {
"uuid": "43679041066d37b28f676a49851ade69",
"clientUuid": "3e5541e27b9c320fa4ad0a86777cc5ab",
"redirectTemplate": "http://zstack.com/code"
}
}#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 模版的 UUID,唯一标示该资源 | 4.3.0 |
| name | String | 模版名称 | 4.3.0 |
| description | String | 模版的详细描述 | 4.3.0 |
| clientUuid | String | 对应的 SSO 客户端 UUID,即第三方账户源的 UUID | 4.3.0 |
| redirectTemplate | String | 跳转的模板 | 4.3.0 |
| createDate | Timestamp | 创建时间 | 4.3.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.3.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
UpdateSSORedirectTemplateAction action = new UpdateSSORedirectTemplateAction();
action.uuid = "35cc6909f0f23e55a209cd552d8bc938";
action.redirectTemplate = "http://zstack.com/userinfoUrl";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateSSORedirectTemplateAction.Result res = action.call();Python
SDK
UpdateSSORedirectTemplateAction action = UpdateSSORedirectTemplateAction()
action.uuid = "35cc6909f0f23e55a209cd552d8bc938"
action.redirectTemplate = "http://zstack.com/userinfoUrl"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateSSORedirectTemplateAction.Result res = action.call()获取SSO客户端(GetSSOClient)
获取 SSO 客户端
API请求
URLs
GET zstack/v1/get/sso/clientCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/zstack/v1/get/sso/client?参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| systemTags (可选) | List | query | 系统标签 | 4.3.0 | |
| userTags (可选) | List | query | 用户标签 | 4.3.0 |
API返回
返回示例
{
"inventories": [
{
"uuid": "ff0df349f4d13f4081d57b3715851900",
"name": "Test-ldap",
"description": "some descriptions",
"type": "OAuth2",
"createAccountStrategy": "CreateDisabledAccount",
"updateAccountStrategies": [
"AccountStateKeepSameWithSource"
],
"deleteAccountStrategy": "StaleAccount",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 获取是否成功 | 4.3.0 |
| error | ErrorCode | 详情参考error | 4.3.0 |
| inventories | List | 详情参考inventories | 4.3.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
GetSSOClientAction action = new GetSSOClientAction();
GetSSOClientAction.Result res = action.call();Python SDK
action = GetSSOClientAction()
res = action.call()获取 OAuth2 客户端的 Client Secret (GetOAuthClientSecret)
API请求
URLs
GET zstack/v1/oauth2/clients/{uuid}/client-secretHeaders
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/oauth2/clients/d734cef1f11137e3954f73fc337474ab/client-secret参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | OAuth2 客户端 UUID | 5.0.0 | |
| systemTags (可选) | List | query | 系统标签 | 5.0.0 | |
| userTags (可选) | List | query | 用户标签 | 5.0.0 |
API返回
返回示例
{
"clientSecret": "exampleClientSecret"
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 获取是否成功 | 5.0.0 |
| clientSecret | String | OAuth2 客户端的 Client Secret | 5.0.0 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 5.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
GetOAuthClientSecretAction action = new GetOAuthClientSecretAction();
action.uuid = "d734cef1f11137e3954f73fc337474ab";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetOAuthClientSecretAction.Result res = action.call();Python SDK
action = GetOAuthClientSecretAction()
action.uuid = "d734cef1f11137e3954f73fc337474ab"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()