批量更新迁移用户信息
功能介绍
数据库的迁移过程中,迁移用户需要进行单独处理,该接口可以批量设置需要迁移的用户和角色。
接口约束
仅迁移场景、PostgreSQL同步支持。
URI
PUT /v3/{project_id}/jobs/batch-update-user
| 参数 | 是否必选 | 参数类型 | 描述 | 
|---|---|---|---|
| project_id | 是 | String | 租户在某一Region下的Project ID。 获取方法请参见获取项目ID。 | 
请求参数
| 参数 | 是否必选 | 参数类型 | 描述 | 
|---|---|---|---|
| Content-Type | 是 | String | 指定类型为application/json。 缺省值:application/json | 
| X-Auth-Token | 是 | String | 从IAM服务获取的用户Token。 | 
| X-Language | 否 | String | 请求语言类型。 缺省值:en-us 取值: 
 | 
| 参数 | 是否必选 | 参数类型 | 描述 | 
|---|---|---|---|
| jobs | 是 | Array of objects | 批量更新迁移用户请求列表。 详情请参见表4。 | 
| 参数 | 是否必选 | 参数类型 | 描述 | 
|---|---|---|---|
| job_id | 是 | String | 任务ID。 | 
| password | 否 | String | 全局密码。 | 
| list | 否 | Array of objects | 用户迁移信息,迁移用户时必填。 详情请参见表5。 | 
| user_roles | 否 | Array of objects | 角色迁移信息,迁移用户时必填。 详情请参见表6。 | 
| is_set_password | 是 | Boolean | 是否设置密码。 | 
| is_migrate_user | 是 | Boolean | 是否迁移用户。 | 
| is_sync_object_privilege | 否 | Boolean | 是否同步权限,不填默认为false,PostgreSQL同步使用。 | 
响应参数
状态码: 200
| 参数 | 参数类型 | 描述 | 
|---|---|---|
| all_counts | Integer | 总数。 | 
| results | Array of objects | 迁移用户信息。 详情请参见表8 | 
| 参数 | 参数类型 | 描述 | 
|---|---|---|
| job_id | String | 任务ID。 | 
| is_global_password | String | 是否使用全局密码。 | 
| message | String | 错误码。 | 
| user_list | Array of objects | 用户列表数据。 详情请参见表9。 | 
| roles_list | Array of objects | 角色列表数据。 详情请参见表10。 | 
| is_success | Boolean | 是否成功。 | 
| 参数 | 参数类型 | 描述 | 
|---|---|---|
| id | String | 用户账号ID。 | 
| account | String | 账号。 | 
| comment | String | 说明。 | 
| is_transfer | Boolean | 是否迁移。 | 
| privileges | Array of strings | 权限。 | 
| password | String | 密码。 | 
| roles | Array of strings | 拥有的角色。 | 
| selected | Boolean | 是否选择。 | 
| no_privileges | String | 无法同步的用户权限。 | 
| parent_account | String | 父用户。 | 
| no_parent_account | String | 无法同步父子关系的父用户。 | 
请求示例
- 指定任务设置需要迁移的用户
    https://{endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/batch-update-user { "jobs": [{ "is_migrate_user": true, "is_set_password": false, "job_id": "36c368d7-c03f-46e1-839a-b5c5bddjb105", "list": [{ "account": "admin.testuser2", "comment": "", "id": "admin.testuser2", "is_set_password": true, "is_transfer": true, "password": null, "privileges": null, "roles": ["admin.clusterAdmin"], "selected": true }], "password": "", "user_roles": [{ "comment": "", "inherits_roles": [ "admin.roletest1", "admin.roletest3", "fastunit.roletest1" ], "is_transfer": true, "privileges": "[{u'resource': {u'cluster': True}, u'actions': [u'addShard']}, {u'resource': {u'db': u'fastunit', u'collection': u'coll'}, u'actions': [u'find', u'insert', u'remove', u'update']}, {u'resource': {u'db': u'mgo', u'collection': u'mycollection3'}, u'actions': [u'insert', u'remove', u'update']}, {u'resource': {u'db': u'', u'collection': u''}, u'actions': [u'find']}, {u'resource': {u'db': u'admin', u'collection': u''}, u'actions': [u'find']}]", "role": "admin.roletest4", "selected": true }] }] }
- 指定任务设置不迁移用户
    https://{endpoint}/v3/0549a6a31000d4e82fd1c00c3d6f2d76/jobs/batch-update-user { "jobs" : [ { "is_migrate_user" : false, "is_set_password" : false, "job_id" : "a281f62f-4631-45d6-a2d3-679a9f4jb105" } ] }
响应示例
状态码: 200
OK
{
  "all_counts" : 1,
  "results" : [ {
    "job_id" : "71604be1-f441-42f1-a09f-c5a52f0djb15",
    "is_success" : true
  } ]
}
 状态码
| 状态码 | 描述 | 
|---|---|
| 200 | OK | 
| 400 | Bad Request | 
错误码
请参见错误码。
 
    