角色端點
角色定義管理員、專家或一般使用者對貴組織資源的存取權。 在基於角色的存取控制環境中,使用者存取布建是透過共同責任和需求進行分組。 一個角色具有一組給定的權限,您的組織成員可以指派到一個或多個角色,依據他們需要的視圖範圍或寫入權限而定。
以屬性為基礎的存取控制API中的/roles
端點可讓您以程式設計方式管理組織中的角色。
快速入門
本指南中使用的API端點屬於屬性型存取控制API的一部分。 繼續之前,請先檢閱快速入門手冊,以取得相關檔案的連結、閱讀本檔案中範例API呼叫的手冊,以及有關成功呼叫任何Experience PlatformAPI所需必要標題的重要資訊。
擷取角色清單 list
您可以透過向/roles
端點發出GET要求,列出屬於您組織的所有現有角色。
API格式
GET /roles/
要求
下列請求會擷取屬於您組織的角色清單。
curl -X GET \
https://platform.adobe.io/data/foundation/access-control/administration/roles \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {IMS_ORG}' \
回應
成功的回應會傳回組織中的角色清單,包括有關其各自角色型別、許可權集和主體屬性的資訊。
{
"roles": [
{
"id": "3dfa045d-de58-4dfd-8ea9-e4e2c1b6d809",
"name": "Administrator Role",
"description": "Role for administrator type of responsibilities and access",
"roleType": "user-defined",
"permissionSets": [
"manage-datasets",
"manage-schemas"
],
"sandboxes": [
"prod"
],
"subjectAttributes": {
"labels": [
"core/S1"
]
},
"createdBy": "{CREATED_BY}",
"createdAt": 1648153201825,
"modifiedBy": "{MODIFIED_BY}",
"modifiedAt": 1648153201825,
"etag": null
}
],
"_page": {
"limit": 1,
"count": 1
},
"_links": {
"next": {
"href": "https://platform.adobe.io:443/data/foundation/access-control/administration/roles/3dfa045d-de58-4dfd-8ea9-e4e2c1b6d809",
"templated": true
},
"page": {
"href": "https://platform.adobe.io:443/data/foundation/access-control/administration/roles/3dfa045d-de58-4dfd-8ea9-e4e2c1b6d809",
"templated": true
},
"subjects": {
"href": "https://platform.adobe.io:443/data/foundation/access-control/administration/roles/3dfa045d-de58-4dfd-8ea9-e4e2c1b6d809",
"templated": true
}
}
}
id
name
description
roleType
user-defined
和system-defined
。permissionSets
sandboxes
subjectAttributes
subjectAttributes.labels
查詢角色 lookup
您可以透過在請求路徑中包含對應roleId
的GET請求來查詢個別角色。
API格式
GET /roles/{ROLE_ID}
要求
下列要求會擷取{ROLE_ID}
的資訊。
curl -X GET \
https://platform.adobe.io/data/foundation/access-control/administration/roles/3dfa045d-de58-4dfd-8ea9-e4e2c1b6d809 \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {IMS_ORG}' \
回應
成功的回應會傳回查詢角色ID的詳細資料,包括其角色型別、許可權集和主體屬性的資訊。
{
"id": "3dfa045d-de58-4dfd-8ea9-e4e2c1b6d809",
"name": "Administrator Role",
"description": "Role for administrator type of responsibilities and access",
"roleType": "user-defined",
"permissionSets": [
"manage-datasets",
"manage-schemas"
],
"sandboxes": [
"prod"
],
"subjectAttributes": {
"labels": [
"core/S1"
]
},
"createdBy": "{CREATED_BY}",
"createdAt": 1648153201825,
"modifiedBy": "{MODIFIED_BY}",
"modifiedAt": 1648153201825,
"etag": null
}
id
name
description
roleType
user-defined
和system-defined
。permissionSets
sandboxes
subjectAttributes
subjectAttributes.labels
依角色ID查詢主題
您也可以在提供{ROLE_ID}的同時向/roles
端點提出GET要求來擷取主題。
API格式
GET /roles/{ROLE_ID}/subjects
要求
下列要求會擷取與3dfa045d-de58-4dfd-8ea9-e4e2c1b6d809
關聯的主體。
curl -X GET \
https://platform.adobe.io/data/foundation/access-control/administration/roles/3dfa045d-de58-4dfd-8ea9-e4e2c1b6d809/subjects \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {IMS_ORG}' \
回應
成功回應會傳回與查詢的角色ID相關聯的主題,包括對應的主題ID和主題型別。
{
"items": [
{
"roleId": "3dfa045d-de58-4dfd-8ea9-e4e2c1b6d809",
"subjectType": "user",
"subjectId": "03Z07HFQCCUF3TUHAX274206@AdobeID"
},
{
"roleId": "3dfa045d-de58-4dfd-8ea9-e4e2c1b6d809",
"subjectType": "user",
"subjectId": "PIRJ7WE5T3QT9Z4TCLVH86DE@AdobeID"
},
{
"roleId": "3dfa045d-de58-4dfd-8ea9-e4e2c1b6d809",
"subjectType": "user",
"subjectId": "WHPWE00MC26SHZ7AKBFG403D@AdobeID"
},
]
"_page": {
"limit": 0,
"count": 0
},
"_links": {
"self": {
"href": "/roles/{ROLE_ID}/subjects",
"templated": false,
"type": null,
"method": null
},
"page": {
"href": "/roles/{ROLE_ID}/subjects?limit={limit}&start={start}&orderBy={orderBy}&property={property}",
"templated": true,
"type": null,
"method": null
}
}
}
roleId
subjectType
subjectId
建立角色 create
若要建立新角色,請在提供角色名稱、說明和角色型別的值時,向/roles
端點提出POST要求。
API格式
POST /roles/
要求
curl -X POST \
https://platform.adobe.io/data/foundation/access-control/administration/roles \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {IMS_ORG}'
-d'{
"name": "Administrator Role",
"description": "Role for administrator type of responsibilities and access",
"roleType": "user-defined"
}'
name
description
roleType
user-defined
和system-defined
。回應
成功的回應會傳回您新建立的角色,以及其對應的角色ID,以及其角色型別、許可權集和主體屬性的資訊。
{
"id": "3dfa045d-de58-4dfd-8ea9-e4e2c1b6d809",
"name": "Administrator Role",
"description": "Role for administrator type of responsibilities and access",
"roleType": "user-defined",
"permissionSets": [
"manage-datasets",
"manage-schemas"
],
"sandboxes": [
"prod"
],
"subjectAttributes": {
"labels": [
"core/S1"
]
},
"createdBy": "{CREATED_BY}",
"createdAt": 1648153201825,
"modifiedBy": "{MODIFIED_BY}",
"modifiedAt": 1648153201825,
"etag": null
}
id
name
description
roleType
user-defined
和system-defined
。permissionSets
sandboxes
subjectAttributes
subjectAttributes.labels
更新角色 patch
您可以透過向/roles
端點發出PATCH要求來更新角色的屬性,同時為您要套用的操作提供對應的角色ID和值。
API格式
PATCH /roles/{ROLE_ID}
要求
curl -X PATCH \
https://platform.adobe.io/data/foundation/access-control/administration/roles/{ROLE_ID} \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {IMS_ORG}'
-d'{
"operations": [
{
"op": "add",
"path": "/description",
"value": "Role with permission sets for admin type of access"
}
]
}'
op
add
、replace
和remove
。path
value
回應
成功的回應會傳回更新的角色,包括您選擇更新的屬性的新值。
{
"id": "3dfa045d-de58-4dfd-8ea9-e4e2c1b6d809",
"name": "Administrator Role",
"description": "Role with permission sets for admin type of access",
"roleType": "user-defined",
"permissionSets": [
"manage-datasets",
"manage-schemas"
],
"sandboxes": [
"prod"
],
"subjectAttributes": {
"labels": [
"core/S1"
]
},
"createdBy": "{CREATED_BY}",
"createdAt": 1648153201825,
"modifiedBy": "{MODIFIED_BY}",
"modifiedAt": 1648153201825,
"etag": null
}
id
name
description
roleType
user-defined
和system-defined
。permissionSets
sandboxes
subjectAttributes
subjectAttributes.labels
依角色ID更新角色 put
您可以對/roles
端點發出PUT要求,並指定與您要更新之角色對應的角色ID,以更新角色。
API格式
PUT /roles/{ROLE_ID}
要求
下列要求會更新角色ID的名稱、說明和角色型別: 3dfa045d-de58-4dfd-8ea9-e4e2c1b6d809
。
curl -X PUT \
https://platform.adobe.io/data/foundation/access-control/administration/roles/3dfa045d-de58-4dfd-8ea9-e4e2c1b6d809 \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {IMS_ORG}'
-d'{
"name": "Administrator role for ACME",
"description": "New administrator role for ACME",
"roleType": "user-defined"
}'
name
description
roleType
user-defined
和system-defined
。回應
成功的回應會傳回您更新的角色,包括其名稱、說明和角色型別的新值。
{
"id": "3dfa045d-de58-4dfd-8ea9-e4e2c1b6d809",
"name": "Administrator role for ACME",
"description": "New administrator role for ACME",
"roleType": "user-defined",
"permissionSets": [
"manage-datasets",
"manage-schemas"
],
"sandboxes": [
"prod"
],
"subjectAttributes": {
"labels": [
"core/S1"
]
},
"createdBy": "{CREATED_BY}",
"createdAt": 1648153201825,
"modifiedBy": "{MODIFIED_BY}",
"modifiedAt": 1648153201825,
"etag": null
}
id
name
description
roleType
user-defined
和system-defined
。permissionSets
sandboxes
subjectAttributes
subjectAttributes.labels
依角色ID更新主旨
若要更新與角色相關聯的主體,請在提供您要更新之主體的角色ID時,向/roles
端點提出PATCH要求。
API格式
PATCH /roles/{ROLE_ID}/subjects
要求
下列要求會更新與{ROLE_ID}
關聯的主體。
curl --location --request PATCH 'https://platform.adobe.io/data/foundation/access-control/administration/roles/<ROLE_ID>/subjects' \
--header 'Authorization: Bearer {ACCESS_TOKEN}' \
--header 'x-api-key: {API_KEY}' \
--header 'x-gw-ims-org-id: {IMS_ORG}' \
--header 'Content-Type: application/json' \
--data-raw '[
{
"op": "add",
"path": "/user",
"value": "{USER ID}"
}
]'
op
add
、replace
和remove
。path
value
回應
成功的回應會傳回您更新的角色,包括主題的新值。
{
"subjects": [
[
{
"subjectId": "03Z07HFQCCUF3TUHAX274206@AdobeID",
"subjectType": "user"
}
]
],
"_page": {
"limit": 1,
"count": 1
},
"_links": {
"self": {
"href": "https://platform.adobe.io:443/data/foundation/access-control/administration/roles/{ROLE_ID}/subjects",
"templated": true
},
"page": {
"href": "https://platform.adobe.io:443/data/foundation/access-control/administration/roles/{ROLE_ID}/subjects?limit={limit}&start={start}&orderBy={orderBy}&property={property}",
"templated": true
}
}
}
刪除角色 delete
若要刪除角色,請在指定您要刪除的DELETE識別碼時,向/roles
端點提出角色要求。
API格式
DELETE /roles/{ROLE_ID}
要求
下列請求會刪除識別碼為{ROLE_ID}
的角色。
curl -X DELETE \
https://platform.adobe.io/data/foundation/access-control/administration/roles/{ROLE_ID} \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {IMS_ORG}' \
回應
成功的回應會傳回HTTP狀態204 (無內容)和空白內文。
您可以嘗試向角色查詢(GET)請求以確認刪除。 您會收到HTTP狀態404 (找不到),因為角色已從管理中移除。
新增API認證 apicredential
若要新增API認證,請在提供主體的角色ID時,向/roles
端點提出PATCH要求。
API格式
curl --location --request PATCH 'https://platform.adobe.io/data/foundation/access-control/administration/roles/<ROLE_ID>/subjects' \
--header 'Authorization: Bearer {ACCESS_TOKEN}' \
--header 'x-api-key: {API_KEY}' \
--header 'x-gw-ims-org-id: {IMS_ORG}' \
--header 'Content-Type: application/json' \
--data-raw '[
{
"op": "add",
"path": "/api-integration",
"value": "{TECHNICAL ACCOUNT ID}"
}
]'
op
add
、replace
和remove
。path
value
回應
成功的回應會傳回HTTP狀態204 (無內容)和空白內文。