开发者中心

用户

用户接口由以下部分组成:

  • 用户 API 资源将 URI 和 URI模板 返回给用户, 组和角色的集合, 以便可以查询具有特定名称的所有用户, 群组, 角色和用户或群组。
  • 用户集合资源检索用户集,并允许创建新用户。
  • 用户>资源表示可以查询和删除的各个用户。
  • >用户引用集合资源检索对用户的引用集。 这些可以是例如特定用户组的用户。 它还可以将新用户添加到集合。
  • 用户引用<资源表示对用户的一个单独引用, 可以检索或删除。
  • 当前用户资源表示已登录的用户, 可以查询和修改。
  • 群组集合资源检索群组的集合并启用创建新群组。
  • 群组资源表示可以查询和删除的各个群组。
  • 群组引用集合资源检索对群组的引用集。 它可以是例如特定用户的群组。
  • 群组引用资源表示对群组的一个单独引用, 可以检索或删除该引用。
  • 角色集合资源检索角色集。
  • 角色资源表示可以查询和分配或取消分配给用户或群组的各个角色。
  • 角色引用集合资源检索对角色的引用集。 这些可以是例如特定用户或群组的角色。
  • 角色引用资源表示对角色的一个单独引用, 可以检索该引用。

此API中使用的"Realm"通常对应于租户。

注意: 所有的PUT/POST请求必须设置accept头, 否则会返回空的应答正文。

用户API

用户API [application/vnd.com.nsn.cumulocity.userApi+json]
名称 类型 次数 描述
self URL 1 资源链接。
userByName URI Template/User 1 对类型为User的资源的引用。模板包含占位符 {realm} 和 {userName}。
users URI Template/UserCollection 1 属于给定领域的所有用户的集合。 模板包含占位符{realm}。
currentUser URI Template/User 1 对登录用户的资源的引用。
groupByName URI Template/Group 1 对类型Group的资源的引用。 模板包含占位符{realm}和{groupName}。
groups URI Template/GroupCollection 1 属于给定领域的所有用户的集合。 模板包含占位符{realm}。
roles URI Template/RoleCollection 1 所有角色的集合。
GET - 查询用户API资源

应答正文: 用户Api 请求示例: 查询用户API资源信息

GET /user
                      Host: [hostname]
                      Authorization: Basic xxxxxxxxxxxxxxxxxxx
                      Accept: application/vnd.com.nsn.cumulocity.userApi+json;ver=0.9
                    

应答示例:

HTTP/1.1 200 OK
                      Content-Type: application/vnd.com.nsn.cumulocity.userApi+json;ver=0.9
                      Content-Length: nnn
                      {
                      "self" : "<<UserAPI URL>>",
                      "userByName" : "<<URL to the UserByName resource with realm and user name parameter>>",
                      "users" : "<<URL to the UserCollection resource with realm parameter>>",
                      "currentUser" : "<<URL to the CurrentUser resource>>",
                      "groupByName" : "<<URL to the GroupByName resource with realm and group name parameter>>",
                      "groups" : "<<URL to the GroupCollection resource with realm parameter>>",
                      "roles" : "<<URL to the RoleCollection resource>>"
                    }
                  

用户集合

用户集合 [application/vnd.com.nsn.cumulocity.userCollection+json]
名称 类型 次数 描述
self URI 1 资源链接。
users User 0..n 用户列表。
statistics PagingStatistics 1 分页统计信息。
prev URI 0..1 上一页链接。
next URI 0..1 下一页链接。
GET - 查询用户集合的表示

应答正文: 用户集合

请求示例: 查询用户集合信息

GET /user/<<tenant>>/users
                    Host: [hostname]
                    Authorization: Basic xxxxxxxxxxxxxxxxxxx
                    Accept: application/vnd.com.nsn.cumulocity.userCollection+json;ver=0.9
                  

应答示例:

HTTP/1.1 200 OK
                    Content-Type: application/vnd.com.nsn.cumulocity.userCollection+json;ver=0.9
                    Content-Length: nnn
                    {
                    "self":"[URL to this resource]",
                    "users":[
                    {
                    "id" : "jsmith",
                    "self" : "[URL to the resource]",
                    "userName" : "jsmith",
                    "firstName" : "John",
                    "lastName" : "Smith",
                    "phone" : "+1234567890",
                    "email" : "jsmith@abc.com",
                    "enabled" : true,
                    "groups" : {[collection of groups the user belongs to]},
                    "roles" : {[collection of roles the user has]},
                    "devicePermissions": {}
                  }, ... {
                  "id" : "mblack",
                  "self" : "[URL to the resource]",
                  "userName" : "mblack",
                  "firstName" : "Michael",
                  "lastName" : "Black",
                  "phone" : "+10988765432",
                  "email" : "mblack@abc.com",
                  "enabled" : true,
                  "groups" : {[collection of groups the user belongs to]},
                  "roles" : {[collection of roles the user has]},
                  "devicePermissions": {}
                }
                ],
                "statistics" : {
                "totalPages" : 22,
                "pageSize" : 5,
                "currentPage : 1
              },
              "prev" : "[URL to previous page]",
              "next" : "[URL to next page]"
            }
          
POST - 集合内创建新用户

请求正文: 用户

应答正文: 用户 请求示例: 创建新用户

POST /user/<<tenant>>/users
             Host: [hostname]
             Authorization: Basic xxxxxxxxxxxxxxxxxxx
             Content-Length: nnn
             Content-Type: application/vnd.com.nsn.cumulocity.user+json;ver=0.9
             {
             "userName" : "jsmith",
             "password" : "password",
             "firstName" : "John",
             "lastName" : "Smith",
             "phone" : "+1234567890",
             "customProperties" : {"language":"en"},
             "email" : "jsmith@abc.com",
             "enabled" : true,
             "sendPasswordResetEmail": true
           }
         

应答示例:

HTTP/1.1 201 Created
           Content-Type: application/vnd.com.nsn.cumulocity.user+json;ver=0.9
           Content-Length: nnn
           Location: [location]
           {
           "id" : "jsmith",
           "self" : "[URL to this resource]",
           "userName" : "jsmith",
           "firstName" : "John",
           "lastName" : "Smith",
           "phone" : "+1234567890",
           "email" : "jsmith@abc.com",
           "customProperties" : {"language":"en"},
           "enabled" : true,
           "groups" : {[collection of groups the user belongs to]},
           "roles" : {[collection of roles the user has]},
           "devicePermissions": {}
         }
       

用户

用户 [application/vnd.com.nsn.cumulocity.user+json]

"用户"资源类型包含以下字段:

名称 类型 次数 描述 在PUT/POST请求中允许
id String 1 唯一标识用户 不允许
self URI 1 资源链接 不允许
userName String 1 用户名, 给定领域唯一。 最大: 1000字符 POST:必选 PUT:不允许
password String 1 用户密码。 最小: 6, 最大: 32字符。 只允许拉丁字符。 POST:必选 PUT:可选
firstName String 1 用户名字。 可选
lastName String 1 用户姓氏。 可选
phone String 1 用户电话号码。 可选
email String 1 用户邮件地址。 可选
enabled boolean 1 用户激活状态(true/false) 可选
customProperties Object 1 保留自定义属性的列表 可选
groups GroupReferenceCollection 1 群组引用列表 不允许
roles RoleReferenceCollection 1 角色引用列表 不允许
devicePermissions Object 1 设备权限列表 可选

嵌入用户包含除密码之外的所有属性。 GET用户从不返回密码属性

用户 [application/vnd.com.nsn.cumulocity.currentUser+json]>

"当前用户"资源类型包括以下字段:

名称 类型 次数 描述 在PUT/POST请求中允许
id String 1 唯一标识用户 不允许
self URI 1 资源链接 不允许
userName String 1 用户名, 给定领域唯一。 最大: 1000字符 POST:mandatory PUT:不允许
password String 1 用户密码。 最小: 6, 最大: 32字符。 只允许拉丁字符。 POST:必选 PUT:可选
firstName String 1 用户名字。 可选
lastName String 1 用户姓氏。 可选
phone String 1 用户电话号码。 可选
email String 1 用户邮件地址。 可选
enabled boolean 1 用户激活状态(true/false) 可选
devicePermissions Object 1 设备权限列表 可选
effectiveRoles Role 0..n 当前用户已分配(通过关联组显式或隐式)的所有角色列表。 不允许

用户名 最大1000字符 嵌入用户包含除密码之外的所有属性。 GET用户从不返回密码属性

设备权限结构:

[API:fragment_name:permission] 其中:

  1. API是以下值之一: "OPERATION", "ALARM", "AUDIT", "EVENT", "MANAGED_OBJECT", "MEASUREMENT" 或 "*"
  2. 片段名是任意片段名, 如 "c8y_Restart" 或 "*"
  3. 权限是 "ADMIN", "READ" 或 "*"
每个HTTP方法所需的权限:
  • POST - "ADMIN" 或 "*"
  • PUT - "ADMIN" 或 "*"
  • DELETE - "ADMIN" 或 "*"
  • GET - "READ" 或 "*"

"*" 是通配符。 它允许您访问每个API和CRUD对象, 而不管其中的片段。

查询集合:

只有允许用户看到的对象才会返回给用户。 可以使用来自页面统计的下一链接来查询下一页。 需要注意的是, 在这种情况下, "currentPage"字段表示偏移而不是实际的页数。

重要提示:

如果对象中没有任何片段, 那么如果读取该对象, 您必须将通配符放置到设备权限的片段名称部分, 即 "10200":["MEASUREMENT:*:READ"]

审核日志

用户角色, 设备权限和组中的任何更改都会创建具有类型'User'和活动'User updated'的审计记录, 其中包含已更改属性的信息。

GET - 查询用户表示

应答正文: 用户 请求示例: 查询用户信息

GET /user/<<tenant>>/users/<<userId>>
             Host: [hostname]
             Authorization: Basic xxxxxxxxxxxxxxxxxxx
             Accept: application/vnd.com.nsn.cumulocity.user+json;ver=0.9
           

应答示例:

Content-Type: application/vnd.com.nsn.cumulocity.user+json;ver=0.9
            Content-Length: nnn
            {
            "id" : "jsmith",
            "self" : "[URL to this resource]",
            "userName" : "jsmith",
            "firstName" : "John",
            "lastName" : "Smith",
            "phone" : "+1234567890",
            "email" : "jsmith@abc.com",
            "enabled" : true,
            "groups" : {[collection of groups the user belongs to]},
            "roles" : {[collection of roles the user has]},
            "devicePermissions": {}
          }
        

在GET响应中永远不会返回用户密码。 认证机制由另一个接口提供。

GET - 以用户名查询用户表示

应答正文: 用户 请求示例: 查询用户信息

GET /user/<<tenant>>/userByName/<<userName>>
           Host: [hostname]
           Authorization: Basic xxxxxxxxxxxxxxxxxxx
           Accept: application/vnd.com.nsn.cumulocity.user+json;ver=0.9
         

应答示例:

Content-Type: application/vnd.com.nsn.cumulocity.user+json;ver=0.9
          Content-Location: [location]
          Content-Length: nnn
          {
          "id" : "jsmith",
          "self" : "[URL to this resource]",
          "userName" : "jsmith",
          "firstName" : "John",
          "lastName" : "Smith",
          "phone" : "+1234567890",
          "email" : "jsmith@abc.com",
          "enabled" : true,
          "groups" : {[collection of groups the user belongs to]},
          "roles" : {[collection of roles the user has]},
          "devicePermissions": {}
        }
      
PUT - 更新用户资源的修改

请求正文: 用户

应答正文: 用户

请求示例: 修改用户名字

PUT /user/<<tenant>>/users/<<userId>>
       Host: [hostname]
       Authorization: Basic xxxxxxxxxxxxxxxxxxx
       Accept: application/vnd.com.nsn.cumulocity.user+json;ver=0.9
       Content-Type: application/vnd.com.nsn.cumulocity.user+json;ver=0.9
       Content-Length: nnn
       {
       "firstName" : "Robert"
     }
   

应答示例:

Content-Type: application/vnd.com.nsn.cumulocity.user+json;ver=0.9
    Content-Length: nnn
    {
    "id" : "jsmith",
    "self" : "[URL to this resource]",
    "userName" : "jsmith",
    "firstName" : "Robert",
    "lastName" : "Smith",
    "phone" : "+1234567890",
    {emailcloak=off}"email" : "jsmith@abc.com",
    "enabled" : true,
    "groups" : {[collection of groups the user belongs to]},
    "roles" : {[collection of roles the user has]},
    "devicePermissions": {}
  }

当使用更改的权限或组更新用户时, 将创建具有类型'User'和活动'User updated'的审核记录。

DELETE - 删除用户表示

请求正文: N/A.

应答正文: N/A. 请求示例: 删除用户

DELETE /user/<<tenant>>/users/<<userName>>
   Host: [hostname]
   Authorization: Basic xxxxxxxxxxxxxxxxxxx
 

应答示例:

HTTP/1.1  204 NO CONTENT
 
GET - 查询当前用户资源

应答正文: 用户

应答正文: 当前用户

请求示例: 查询已登录用户信息

GET /user/currentUser
   Host: [hostname]
   Authorization: Basic xxxxxxxxxxxxxxxxxxx
   Accept: application/vnd.com.nsn.cumulocity.user+json;ver=0.9
 

应答示例:

HTTP/1.1 200 OK
   Content-Type: application/vnd.com.nsn.cumulocity.user+json;ver=0.9
   Content-Length: nnn

   {
   "email": "jsmith@abc.com",
   "enabled": true,
   "firstName": "John",
   "devicePermissions": {},
   "groups": {
   "references": [...],
   "self": "[URL to User's Groups]"
 },
 "id": "jsmith",
 "lastName": "Smith",
 "phone": "+1234567890",
 "roles": {
 "references": [...],
 "self": "[URL to the User's Roles]"
},
"self": "[URL to the User resource]",
"userName": "jsmith"}
PUT - 更新当前用户资源的修改

请求正文: 用户

应答正文: 用户 请求示例: 修改已登录用户名字

PUT /user/currentUser
   Host: [hostname]
   Authorization: Basic xxxxxxxxxxxxxxxxxxx
   Accept: application/vnd.com.nsn.cumulocity.user+json;ver=0.9
   Content-Type: application/vnd.com.nsn.cumulocity.user+json;ver=0.9
   Content-Length: nnn

   {
   "firstName" : "Robert"
 }

应答示例:

HTTP/1.1 200 OK
 Content-Type: application/vnd.com.nsn.cumulocity.user+json;ver=0.9
 Content-Length: nnn

 {
 "email": "jsmith@abc.com",
 "enabled": true,
 "firstName": "Robert",
 "groups": {
 "references": [...],
 "self": "[URL to User's Groups]"
},
"id": "jsmith",
"lastName": "Smith",
"phone": "+1234567890",
"roles": {
"references": [...],
"self": "[URL to the User's Roles]"
},
"self": "[URL to the User resource]",
"userName": "jsmith",
"devicePermissions": {}
}

用户参考集合

用户参考集合 [application/vnd.com.nsn.cumulocity.userReferenceCollection+json]
名称 类型 次数 描述
self URI 1 资源链接。
references UserReference 0..n 用户引用列表。
statistics PagingStatistics 1 分页统计信息。
prev URI 0..1 上一页链接。
next URI 0..1 下一页链接。
添加用户到群组

请求正文: 用户引用

应答正文: 用户引用 请求示例: 创建用户引用

POST /user/<<tenant>>/groups/<<groupId>>/users
   Host: [hostname]
   Authorization: Basic xxxxxxxxxxxxxxxxxxx
   Content-Length: nnn
   Content-Type: application/vnd.com.nsn.cumulocity.userReference+json;ver=0.9

   {
   "user" : {
   "self" : "[URL to the User resource]"
 }
}

应答示例:

HTTP/1.1 201 Created
 Content-Type: application/vnd.com.nsn.cumulocity.userReference+json;ver=0.9
 Content-Length: nnn
 Location: [location]

 {
 "self": "[URL to this resource]",
 "user": {
 "email": "jsmith@abc.com",
 "enabled": true,
 "firstName": "John",
 "groups": {
 "references": [...],
 "self": "[URL to the User's Groups]"
},
"id": "jsmith",
"lastName": "Smith",
"phone": "+1234567890",
"roles": {
"references": [...],
"self": "[URL to the User's Roles]"
},
"self": "[URL to the User resource]",
"userName": "jsmith"
}}

当用户添加到群组时,将创建具有类型'User'和活动'User updated'的审核记录。

从群组移除用户

请求正文: N/A.

应答正文: N/A. 请求示例: 删除用户引用

 DELETE /user/<<tenant>>/groups/<<groupId>>/users/<<yourUserName>>
   Host: [hostname]
   Authorization: Basic xxxxxxxxxxxxxxxxxxx
 

应答示例:

HTTP/1.1  204 NO CONTENT
 

当从群组移除用户时,将创建具有类型'User'和活动'User updated'的审核记录。

GET - 查询群组中所有用户

应答正文: 用户引用集合 请求示例: 查询群组中所有用户信息

GET /user/management/groups/<<groupId>>
     Host: [hostname]
     Authorization: Basic xxxxxxxxxxxxxxxxxxx
     Accept: application/vnd.com.nsn.cumulocity.userReferenceCollection+json;ver=0.9
   

应答示例:

Content-Type: application/vnd.com.nsn.cumulocity.userReferenceCollection+json;ver=0.9
    Content-Length: nnn

    {
    "self" : "[URL to this resource]",
    "references" : [
    {
    "self" : "[URL to this UserReference resource]",
    "user" : {
    "self" : "[URL to this User resource]",
    "id" : "1",
    "userName" : "jsmith",
    ...
  }
}
],
"statistics" : {
"totalPages" : 3,
"pageSize" : 5,
"currentPage : 1
},
"prev" : "[URL to previous page]",
"next" : "[URL to next page]"
}

用户引用

用户引用 [application/vnd.com.nsn.cumulocity.userReference+json]
名称 类型 次数 描述
self URI 1 资源链接。
user User 1 被引用的用户资源。

群组集合

群组集合 [application/vnd.com.nsn.cumulocity.groupCollection+json]
名称 类型 次数 描述
self URI 1 资源链接。
groups Group 0..n 群组列表。
statistics PagingStatistics 1 分页统计信息。
prev URI 0..1 上一页链接。
next URI 0..1 下一页链接。
审核日志

组的角色和设备权限的任何更改将创建具有类型'Group'和活动'Group updated'的审核记录,其中包含已更改属性的信息。

群组列表

应答正文: 群组集合

请求示例: 查询群组集合信息

GET /user/management/groups/
 Host: [hostname]
 Authorization: Basic xxxxxxxxxxxxxxxxxxx
 Accept: application/vnd.com.nsn.cumulocity.groupCollection+json;ver=0.9

应答示例:

HTTP/1.1 200 OK
  Content-Type: application/vnd.com.nsn.cumulocity.groupCollection+json;ver=0.9
  Content-Length: nnn

  {
  "self":"[URL to this resource]",
  "groups": [
  {
  "id" : "1",
  "self" : "[URL to this resource]",
  "name" : "administrators",
  "roles" : [...],
  "users" : ["self" : "[URL to collection of Users in this Group]"],
  "devicePermissions": {}
},
{
  "id" : "2",
  "self" : "[URL to this resource]",
  "name" : "readers",
  "roles" : [...],
  "users" : ["self" : "[URL to collection of Users in this Group]"],
  "devicePermissions": {}
}
],
"statistics" : {
"totalPages" : 2,
"pageSize" : 5,
"currentPage : 1
},
"prev" : "[URL to previous page]",
"next" : "[URL to next page]"
}
创建群组

请求正文: 群组

应答正文: 群组 请求示例: 创建新群组

POST /user/management/groups
   Host: [hostname]
   Authorization: Basic xxxxxxxxxxxxxxxxxxx
   Content-Length: nnn
   Content-Type: application/vnd.com.nsn.cumulocity.group+json;ver=0.9

   {
   "name" : "monitoring"
 }

应答示例:

HTTP/1.1 201 Created
 Content-Type: application/vnd.com.nsn.cumulocity.group+json;ver=0.9
 Content-Length: nnn
 Location: [URL to the resource]

 {
 "id" : "3",
 "self" : "[URL to this resource]",
 "name" : "monitoring"
 "users" : {
 "self" : "[URL to the UserReferenceCollection resource]",
 "references" : []
},
"roles" : {
"self" : "[URL to the RoleReferenceCollection resource]",
"references" : []
},
"devicePermissions": {}
}
群组
群组 [application/vnd.com.nsn.cumulocity.group+json]
名称 类型 次数 描述 在PUT/POST请求中允许
id String 1 群组唯一标识 不允许
self URI 1 资源链接 不允许
name String 1 群组描述名称 必选
roles RoleReferenceCollection 1 角色引用列表 不允许
devicePermissions Object 1 设备权限列表 可选
显示群组细节

应答正文: 群组 请求示例: 查询群组信息

GET /user/management/groups/<<groupId>>
   Host: [hostname]
   Authorization: Basic xxxxxxxxxxxxxxxxxxx
   Accept: application/vnd.com.nsn.cumulocity.group+json;ver=0.9
 

应答示例:

Content-Type: application/vnd.com.nsn.cumulocity.group+json;ver=0.9
  Content-Length: nnn

  {
  "id" : "1",
  "self" : "[URL to this resource]",
  "name" : "administrators",
  "devicePermissions": {},
  "roles" : {
  "self" : "[URL to the RoleReferenceCollection resource]",
  "references" : [
  {
  "self" :  "[URL to the RoleReference resource]",
  "role" : {
  "self" :  "[URL to the Role resource]",
  "id" : "1",
  "name" : "ROLE_USER_MGMT_ADMIN"
}
},
{
  "self" :  "[URL to the RoleReference resource]",
  "role" : {
  "self" :  "[URL to the Role resource]",
  "id" : "1",
  "name" : "ROLE_INVENTORY_MGMT_ADMIN"
}
},
...
]
}
GET - 用名称查询群组表示

应答正文: 群组 请求示例: 查询群组信息

GET /user/<<tenant>>/groupByName/<<groupName>>
   Host: [hostname]
   Authorization: Basic xxxxxxxxxxxxxxxxxxx
   Accept: application/vnd.com.nsn.cumulocity.group+json;ver=0.9
 

应答示例:

Content-Type: application/vnd.com.nsn.cumulocity.group+json;ver=0.9
  Content-Location: [main URL of this resource]
  Content-Length: nnn

  {
  "id" : "1",
  "self" : "[URL to this resource]",
  "name" : "administrators",
  ...
}
删除群组

请求正文: N/A.

应答正文: N/A. 请求示例: 删除群组

DELETE /user/<<tenant>>/groups/<<groupId>>
   Host: [hostname]
   Authorization: Basic xxxxxxxxxxxxxxxxxxx
 

应答示例:

HTTP/1.1  204 NO CONTENT
 

删除群组时, 将使用类型'User'和活动'User updated'创建审核记录, 其中包含已从群组中删除用户的信息。

更新群组

请求正文: 群组

应答正文: 群组 请求示例: 修改群组名称

PUT /user/<<tenant>>/groups/<<groupId>>
     Host: [hostname]
     Authorization: Basic xxxxxxxxxxxxxxxxxxx
     Accept: application/vnd.com.nsn.cumulocity.group+json;ver=0.9
     Content-Type: application/vnd.com.nsn.cumulocity.group+json;ver=0.9
     Content-Length: nnn

     {
     "name" : "PlatformAdministrators"
   }
 

应答示例:

Content-Type: application/vnd.com.nsn.cumulocity.group+json;ver=0.9
  Content-Length: nnn

  {
  "id" : "1",
  "self" : "[URL to this resource]",
  "name" : "PlatformAdministrators",
  ...
}

当使用更改的角色或权限更新组时, 将使用类型'Group'和活动'Group updated'创建审核记录。

群组引用集合

群组引用集合 [application/vnd.com.nsn.cumulocity.groupReferenceCollection+json]
名称 类型 次数 描述
self URI 1 资源链接。
groups GroupReference 0..n 群组引用列表。
statistics PagingStatistics 1 分页统计信息。
prev URI 0..1 上一页链接。
next URI 0..1 下一页链接。
GET - 查询用户的群组

应答正文: 群组引用集合 请求示例: 查询用户的群组信息

GET /user/<<tenant>>/users/<<userName>>/groups
   Host: [hostname]
   Authorization: Basic xxxxxxxxxxxxxxxxxxx
   Accept: application/vnd.com.nsn.cumulocity.groupReferenceCollection+json;ver=0.9
 

应答示例:

Content-Type: application/vnd.com.nsn.cumulocity.groupReferenceCollection+json;ver=0.9
  Content-Length: nnn

  {
  "self" : "[URL to this resource]",
  "references": [{        "group": {            "id": 21,            "name": "admins",            "roles": {                "references": [...],                "self": "[URL to this Group's Roles]"            },            "self": "[URL to this Group]",            "users": {                "self": "{URL to this Group's Users]"            }        },        "self": "[URL to this User's Group]"    },   ...   ],   "statistics" : {
  "totalPages" : 1,
  "pageSize" : 5,
  "currentPage : 1
},
"prev" : "[URL to previous page]",
"next" : "[URL to next page]"
}

群组引用

群组引用 [application/vnd.com.nsn.cumulocity.groupReference+json]
名称 类型 次数 描述
self URI 1 资源链接
group Group 1 被引用的群组资源

角色集合

角色集合 [application/vnd.com.nsn.cumulocity.roleCollection+json]
名称 类型 次数 描述
self URI 1 资源链接。
roles Role 0..n 角色列表。
statistics PagingStatistics 1 分页统计信息。
prev URI 0..1 上一页链接。
next URI 0..1 下一页链接。

角色

角色 [application/vnd.com.nsn.cumulocity.role+json]
名称 类型 次数 描述
id String 1 角色唯一标识。
name String 1 角色的描述性名称, 遵循角色命名模式。
GET - 查询所有可用角色

应答正文: 角色集合 请求示例: 查询角色集合信息

 GET /user/roles
   Host: [hostname]
   Authorization: Basic xxxxxxxxxxxxxxxxxxx
 

应答示例:

HTTP/1.1 200 OK
   Content-Type: application/vnd.com.nsn.cumulocity.roleCollection+json;ver=0.9
   Content-Length: nnn

   {
   "self":"[URL to this resource]",
   "roles": [
   {
   "self" :  "[URL to the Role resource]",
   "id" : "ROLE_INVENTORY_ADMIN",
   "name" : "ROLE_INVENTORY_ADMIN"
 },
 {
 "self" :  "[URL to the Role resource]",
 "id" : "ROLE_USER_MGMT_ADMIN",
 "name" : "ROLE_USER_MGMT_ADMIN"
},    ...
],
"statistics" : {
"totalPages" : 5,
"pageSize" : 5,
"currentPage : 1
},
"prev" : "[URL to previous page]",
"next" : "[URL to next page]"
}
给用户分配角色

请求正文: 角色引用

应答正文: 角色引用 请求示例: 创建角色引用

POST /user/<<tenant>>/users/<<userName>>/roles
   Host: [hostname]
   Authorization: Basic xxxxxxxxxxxxxxxxxxx
   Content-Length: nnn
   Content-Type: application/vnd.com.nsn.cumulocity.roleReference+json;ver=0.9

   {
   "role" : {
   "self" : "[URL to the Role resource]"
 }
}

应答示例:

HTTP/1.1 201 Created
 Content-Type: application/vnd.com.nsn.cumulocity.roleReference+json;ver=0.9
 Content-Length: nnn
 Location: [URL to this resource]

 {
 "self" : "[URL to this resource]",
 "role" : {
 "self" :  "[URL to the Role resource]",
 "id" : "ROLE_USER_MGMT_ADMIN",
 "name" : "ROLE_USER_MGMT_ADMIN"
}
}

当角色分配给用户时,将创建具有类型'User'和活动'User updated'的审核记录。

给群组分配角色

请求正文: 角色引用

应答正文: 角色引用 请求示例: 创建角色引用

POST /user/<<tenant>>/groups/<<groupId>>/roles
   Host: [hostname]
   Authorization: Basic xxxxxxxxxxxxxxxxxxx
   Content-Length: nnn
   Content-Type: application/vnd.com.nsn.cumulocity.roleReference+json;ver=0.9

   {
   "role" : {
   "self" : "[URL to the Role resource]"
 }
}

应答示例:

HTTP/1.1 201 Created
 Content-Type: application/vnd.com.nsn.cumulocity.roleReference+json;ver=0.9
 Content-Length: nnn
 Location: [URL to this resource]

 {
 "self" : "[URL to this resource]",
 "role" : {
 "self" :  "[URL to the Role resource]",
 "id" : "ROLE_USER_MGMT_ADMIN",
 "name" : "ROLE_USER_MGMT_ADMIN"
}
}

当角色分配到组时, 将创建具有类型'Group'和活动'Group updated'的审核记录。

从用户取消角色分配

请求正文: N/A.

应答正文: N/A. 请求示例: 删除角色引用

DELETE /user/<<tenant>>/users/<<userName>>/roles/<<roleName>> (Example:ROLE_TENANT_MANAGEMENT_ADMIN)}}
   Host: [hostname]
   Authorization: Basic xxxxxxxxxxxxxxxxxxx
 

应答示例:

HTTP/1.1  204 NO CONTENT
 
从群组取消分配角色

请求正文: N/A.

应答正文: N/A. 请求示例: 删除角色引用

DELETE /user/<<tenant>>/groups/<<groupId>>/roles/<<roleName>> (Example:ROLE_TENANT_MANAGEMENT_ADMIN)}}
     Authorization: Basic xxxxxxxxxxxxxxxxxxx
   

应答示例:

HTTP/1.1  204 NO CONTENT
   

当角色从组取消分配时, 将创建具有类型'Group'和活动'Group updated'的审核记录。

角色引用集合

角色引用集合 [application/vnd.com.nsn.cumulocity.roleReferenceCollection+json]
名称 类型 次数 描述
self URI 1 资源链接。
references RoleReference 0..n 角色引用列表。
statistics PagingStatistics 1 分页统计信息。
prev URI 0..1 上一页链接。
next URI 0..1 下一页链接。
GET - 查询用户所有角色

应答正文: 角色引用集合 请求示例: 查询角色引用集合信息

GET /user/<<tenant>>/users/<<userName>>/roles
     Host: [hostname]
     Authorization: Basic xxxxxxxxxxxxxxxxxxx
     Accept: application/vnd.com.nsn.cumulocity.roleReferenceCollection+json;ver=0.9
   

应答示例:

HTTP/1.1 200 OK
     Content-Type: application/vnd.com.nsn.cumulocity.roleReferenceCollection+json;ver=0.9
     Content-Length: nnn
     {
     "self":"[URL to this resource]",
     "references": [
     {
     "self" :  "[URL to the Role Reference resource]",
     "role" : {
     "self" :  "[URL to the Role resource]",
     "id" : "ROLE_INVENTORY_ADMIN",
     "name" : "ROLE_INVENTORY_ADMIN"
   }
 },
 {
 "self" :  "[URL to the Role Reference resource]",
 "role" : {
 "self" :  "[URL to the Role resource]",
 "id" : "ROLE_USER_MGMT_ADMIN",
 "name" : "ROLE_USER_MGMT_ADMIN"
}
}
],
"statistics" : {
"totalPages" : 1,
"pageSize" : 5,
"currentPage : 1
},
"prev" : "[URL to previous page]",
"next" : "[URL to next page]"
}
GET - 查询群组所有角色

应答正文: 角色引用集合 请求示例: 查询角色引用集合信息

GET /user/<<tenant>>/groups/<<groupId>>/roles
   Host: [hostname]
   Authorization: Basic xxxxxxxxxxxxxxxxxxx
   Accept: application/vnd.com.nsn.cumulocity.roleReferenceCollection+json;ver=0.9
 

应答示例:

HTTP/1.1 200 OK
   Content-Type: application/vnd.com.nsn.cumulocity.roleReferenceCollection+json;ver=0.9
   Content-Length: nnn

   {
   "self":"[URL to this resource]",
   "references": [
   {
   "self" :  "[URL to the Role Reference resource]",
   "role" : {
   "self" :  "[URL to the Role resource]",
   "id" : "ROLE_INVENTORY_ADMIN",
   "name" : "ROLE_INVENTORY_ADMIN"
 }
},
{
 "self" :  "[URL to the Role Reference resource]",
 "role" : {
 "self" :  "[URL to the Role resource]",
 "id" : "ROLE_USER_MGMT_ADMIN",
 "name" : "ROLE_USER_MGMT_ADMIN"
}
}
],
"statistics" : {
"totalPages" : 1,
"pageSize" : 5,
"currentPage : 1
},
"prev" : "[URL to previous page]",
"next" : "[URL to next page]"
}

角色引用

角色引用 [application/vnd.com.nsn.cumulocity.roleReference+json]
名称 类型 次数 描述
self URI 1 资源链接
role Role 1 被引用的角色资源