创建 accessPackageResourceRequest

命名空间:microsoft.graph

重要

Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。

创建新的 accessPackageResourceRequest 对象,以请求向访问包目录添加资源,或者从目录中删除资源。 必须先将资源包含在访问包目录中,然后才能将资源的角色添加到访问包中。

权限

要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限

权限类型 权限(从最低特权到最高特权)
委派(工作或学校帐户) EntitlementManagement.ReadWrite.All
委派(个人 Microsoft 帐户) 不支持。
应用程序 EntitlementManagement.ReadWrite.All

HTTP 请求

POST /identityGovernance/entitlementManagement/accessPackageResourceRequests

请求标头

名称 说明
Authorization Bearer {token}。必需。
Content-Type application/json. Required.

请求正文

在请求正文中,提供 accessPackageResourceRequest 对象的 JSON 表示形式。 在请求 accessPackageResource 中包括 与 accessPackageResource 对象的关系。

若要将Azure AD组作为资源添加到目录,请设置 catalogId 为目录的 ID,将 requestType AdminAdd设置为 ,将 设置为 ,将 设置为 表示accessPackageResource资源的 。 内的 originSystem 属性的值accessPackageResource应为 ,AadGrouporiginId 的值是组的标识符。 如果使用委派权限,请求添加组的用户应是组的所有者或目录角色(允许他们修改组)。 如果使用应用程序权限,还应向请求添加组的应用程序分配 Group.ReadWrite.All 权限。

若要将Azure AD应用程序作为资源添加到目录,请设置 catalogId 作为目录的 ID,将 requestType AdminAdd设置为 ,将 设置为 accessPackageResource 表示资源的 。 内的 originSystem 属性的值accessPackageResource应为 ,AadApplicationoriginId 的值是 servicePrincipal 的标识符。 如果使用委派权限,请求添加应用程序的用户应是应用程序的所有者或目录角色(允许他们修改应用程序角色分配)。

若要将 SharePoint Online 网站作为资源添加到目录,请设置 catalogId 为目录 ID,将 requestType AdminAdd设置为 ,将 设置为 ,将 设置为 表示accessPackageResource资源。 内的 originSystem 属性的值accessPackageResource应为 ,SharePointOnlineoriginId 的值为站点的 URI。 如果使用委派权限,则用户应担任 SharePoint 管理员角色。 如果使用应用程序权限,还应向请求添加网站的应用程序分配权限 Sites.FullControl.All 。 若要为多地理位置 Sharepoint Online 资源分配地理位置环境,在 对象中包括 accessPackageResourceEnvironment accessPackageResource 关系。 可通过两种方式完成此操作:

  • 使用 @odata.bind annotation 将 idaccessPackageResourceEnvironment 分配给对象 accessPackageResourceEnvironment
  • originId指定 对象中的 accessPackageResourceEnvironment 参数accessPackageResourceEnvironment

若要从目录中删除资源,请设置 catalogId 为目录 ID, 将 requestType AdminRemove设置为 , accessPackageResource 将 资源对象设置为 要删除的资源对象。 可以使用 list accessPackageResources 检索 resource 对象

响应

如果成功,此方法在响应 201 Created 正文中返回 响应代码和新 accessPackageResourceRequest 对象。

示例

示例 1:创建 accessPackageResourceRequest 以将网站添加为资源

请求

下面展示了示例请求。

POST https://graph.microsoft.com/beta/identityGovernance/entitlementManagement/accessPackageResourceRequests
Content-type: application/json

{
  "catalogId":"26ac0c0a-08bc-4a7b-a313-839f58044ba5",
  "requestType": "AdminAdd",
  "justification": "",
  "accessPackageResource": {
     "displayName": "Sales",
     "description": "https://contoso.sharepoint.com/sites/Sales",
     "url": "https://contoso.sharepoint.com/sites/Sales",
     "resourceType": "SharePoint Online Site",
     "originId": "https://contoso.sharepoint.com/sites/Sales",
     "originSystem": "SharePointOnline"
  }
}

响应

下面展示了示例响应。

注意: 为了提高可读性,可能缩短了此处显示的响应对象。

HTTP/1.1 201 Created
Content-type: application/json

{
  "catalogId": "26ac0c0a-08bc-4a7b-a313-839f58044ba5",
  "id": "1fe272f0-d463-42aa-a9a8-b07ab50a1c4d",
  "isValidationOnly": false,
  "justification": "",
  "requestState": "Delivered",
  "requestStatus": "Fulfilled",
  "requestType": "AdminAdd"
}

示例 2:创建 accessPackageResourceRequest 以将网站添加为资源,然后使用 @odata.bind 分配 accessPackageResourceEnvironment

请求

下面展示了示例请求。 本示例中,批注@odata.bind用于将 分配给id``accessPackageResourceEnvironment对象accessPackageResourceEnvironment

POST https://graph.microsoft.com/beta/identityGovernance/entitlementManagement/accessPackageResourceRequests
Content-type: application/json

{
    "catalogId": "de9315c1-272b-4905-924b-cc112ca180c7",
    "accessPackageResource": {
        "displayName": "Community Outreach",
        "description": "https://contoso.sharepoint.com/sites/CSR",
        "resourceType": "SharePoint Online Site",
        "originId": "https://contoso.sharepoint.com/sites/CSR",
        "originSystem": "SharePointOnline",
        "accessPackageResourceEnvironment@odata.bind": "accessPackageResourceEnvironments/615f2218-678f-471f-a60a-02c2f4f80c57"
    },
    "requestType": "AdminAdd"
}

响应

下面展示了示例响应。

HTTP/1.1 201 Created
Content-type: application/json

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#identityGovernance/entitlementManagement/accessPackageResourceRequests/$entity",
    "catalogId": "de9315c1-272b-4905-924b-cc112ca180c7",
    "executeImmediately": false,
    "id": "d3f800d5-0dd6-47f3-9e90-ef562c7551dc",
    "requestType": "AdminAdd",
    "requestState": "Delivered",
    "requestStatus": "Fulfilled",
    "isValidationOnly": false,
    "expirationDateTime": null,
    "justification": null
}

示例 3:创建 accessPackageResourceRequest 以将网站添加为资源,然后使用 originId 分配 accessPackageResourceEnvironment

请求

下面展示了示例请求。 本示例在对象 accessPackageResourceEnvironment 中指定 的参数 accessPackageResourceEnvironment

POST https://graph.microsoft.com/beta/identityGovernance/entitlementManagement/accessPackageResourceRequests
Content-type: application/json

{
    "catalogId": "de9315c1-272b-4905-924b-cc112ca180c7",
    "accessPackageResource": {
        "displayName": "Community Outreach",
        "description": "https://contoso.sharepoint.com/sites/CSR",
        "resourceType": "SharePoint Online Site",
        "originId": "https://contoso.sharepoint.com/sites/CSR",
        "originSystem": "SharePointOnline",
        "accessPackageResourceEnvironment": {
            "originId": "https://contoso-admin.sharepoint.com/"
        }
    },
    "requestType": "AdminAdd"
}

响应

下面展示了示例响应。

HTTP/1.1 201 Created
Content-type: application/json

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#identityGovernance/entitlementManagement/accessPackageResourceRequests/$entity",
    "catalogId": "de9315c1-272b-4905-924b-cc112ca180c7",
    "executeImmediately": false,
    "id": "eadf3fbb-668c-4c3a-8d84-7c8bd73dc3e4",
    "requestType": "AdminAdd",
    "requestState": "Delivered",
    "requestStatus": "Fulfilled",
    "isValidationOnly": false,
    "expirationDateTime": null,
    "justification": null
}

示例 4:创建 accessPackageResourceRequest 以将组添加为资源

请求

下面展示了示例请求。

POST https://graph.microsoft.com/beta/identityGovernance/entitlementManagement/accessPackageResourceRequests
Content-type: application/json

{

  "catalogId":"beedadfe-01d5-4025-910b-84abb9369997",
  "requestType": "AdminAdd",
  "accessPackageResource": {
     "originId": "c6294667-7348-4f5a-be73-9d2c65f574f3",
     "originSystem": "AadGroup"
  }
}

响应

下面展示了示例响应。

注意: 为了提高可读性,可能缩短了此处显示的响应对象。

HTTP/1.1 201 Created
Content-type: application/json

{
  "catalogId": "beedadfe-01d5-4025-910b-84abb9369997",
  "id": "acc2294e-f37f-42d3-981d-4e83847ed0ce",
  "requestType": "AdminAdd",
  "requestState": "Delivered",
  "requestStatus": "Fulfilled"
}

示例 5:创建用于删除资源的 accessPackageResourceRequest

请求

下面展示了示例请求。

POST https://graph.microsoft.com/beta/identityGovernance/entitlementManagement/accessPackageResourceRequests
Content-type: application/json

{
  "catalogId": "beedadfe-01d5-4025-910b-84abb9369997",
  "requestType": "AdminRemove",
  "accessPackageResource": {
    "id": "354078e5-dbce-4894-8af4-0ab274d41662"
  }
}

响应

下面展示了示例响应。

注意: 为了提高可读性,可能缩短了此处显示的响应对象。

HTTP/1.1 201 Created
Content-type: application/json

{
  "catalogId": "beedadfe-01d5-4025-910b-84abb9369997",
  "id": "65c3340d-defb-49a9-8930-63841fda0e68",
  "requestType": "AdminRemove",
  "requestState": "Delivered",
  "requestStatus": "Fulfilled"
}

示例 6:创建用于添加应用程序的 accessPackageResourceRequest

请求

下面是向目录添加应用程序的请求示例,包括指定该应用程序的必需属性。

POST https://graph.microsoft.com/beta/identityGovernance/entitlementManagement/accessPackageResourceRequests
Content-type: application/json

{
  "catalogId": "26ac0c0a-08bc-4a7b-a313-839f58044ba5",
  "requestType": "AdminAdd",
  "justification": "",
  "accessPackageResource": {
      "displayName": "Faculty cafeteria ordering",
      "description": "Example application",
      "url": "https://myapps.microsoft.com/example.com/signin/Faculty%20cafeteria%20ordering/f1e3b407-942d-4934-9a3f-cef1975cb988/",
      "resourceType": "Application",
      "originId": "2f1099a6-d4fc-4cc9-a0ef-ddd3f1bf0b7e",
      "originSystem": "AadApplication",
      "attributes": [
        {
          "attributeName": "extension_2b676109c7c74ae2b41549205f1947ed_personalTitle",
          "isEditable": true,
          "isPersistedOnAssignmentRemoval": true,
          "attributeSource": {
              "@odata.type": "#microsoft.graph.accessPackageResourceAttributeQuestion",
              "question": {
                  "@odata.type": "#microsoft.graph.accessPackageTextInputQuestion",
                  "isRequired": false,
                  "sequence": 0,
                  "isSingleLineQuestion": true,
                  "text": {
                      "defaultText": "Title",
                      "localizedTexts": []
                  }
              }
          },
          "attributeDestination": {
              "@odata.type": "#microsoft.graph.accessPackageUserDirectoryAttributeStore"
          }
        }
      ]
  }
}

响应

下面展示了示例响应。

注意: 为了提高可读性,可能缩短了此处显示的响应对象。

HTTP/1.1 201 Created
Content-type: application/json

{
  "id": "f0e632ed-afd2-41d3-8d6e-ccefda457e5e",
  "requestType": "AdminAdd",
  "requestState": "Delivered",
  "requestStatus": "Fulfilled"
}