Les API sous la version /beta dans Microsoft Graph sont susceptibles d’être modifiées. L’utilisation de ces API dans des applications de production n’est pas prise en charge. Pour déterminer si une API est disponible dans v1.0, utilisez le sélecteur Version .
Créez un objet accessPackageResourceRequest pour demander l’ajout d’une ressource à un catalogue de packages d’accès, la mise à jour d’une ressource ou la suppression d’une ressource d’un catalogue. Une ressource doit être incluse dans un catalogue de packages d’accès avant qu’un rôle de cette ressource puisse être ajouté à un package d’accès.
Dans le corps de la demande, fournissez une représentation JSON d’un objet accessPackageResourceRequest . Incluez la accessPackageResource relation avec un objet accessPackageResource dans le cadre de la requête.
Pour ajouter un groupe Microsoft Entra en tant que ressource à un catalogue, définissez catalogId sur l’ID du catalogue, requestTypeAdminAddsur et représentant accessPackageResource la ressource. La valeur de la propriété originSystem dans le accessPackageResource doit être AadGroup et la valeur de l’originId est l’identificateur du groupe. Si vous utilisez des autorisations déléguées, l’utilisateur qui demande l’ajout d’un groupe doit être propriétaire du groupe ou dans un rôle d’annuaire qui lui permet de modifier des groupes. Si vous utilisez des autorisations d’application, l’autorisation doit également être attribuée à l’application demandant d’ajouter le Group.ReadWrite.All groupe.
Pour ajouter une application Microsoft Entra en tant que ressource à un catalogue, définissez catalogId sur l’ID du catalogue, requestType sur AdminAddet accessPackageResource représentant la ressource. La valeur de la propriété originSystem dans doit accessPackageResource être AadApplication et la valeur de l’originId est l’identificateur du servicePrincipal. Si vous utilisez des autorisations déléguées, l’utilisateur qui demande à ajouter une application doit être propriétaire de l’application ou dans un rôle d’annuaire qui lui permet de modifier les attributions de rôles d’application.
Pour ajouter un site SharePoint Online en tant que ressource à un catalogue, définissez catalogId sur l’ID du catalogue, requestTypeAdminAddsur et accessPackageResource représentant la ressource. La valeur de la propriété originSystem dans le accessPackageResource doit être SharePointOnline et la valeur de originId est l’URI du site. Si vous utilisez des autorisations déléguées, l’utilisateur doit avoir le rôle Administrateur SharePoint. Si vous utilisez des autorisations d’application, l’application qui demande l’ajout du site doit également se voir attribuer l’autorisation Sites.FullControl.All . Pour affecter l’environnement de géolocalisation pour une ressource Sharepoint Online multigéographique, incluez la relation accessPackageResourceEnvironment dans l’objet accessPackageResource . Cette opération peut être effectuée de deux manières :
Utilisez @odata.bind l’annotation pour affecter le id de accessPackageResourceEnvironment à un accessPackageResourceEnvironment objet .
Spécifiez le originId paramètre de dans accessPackageResourceEnvironment un accessPackageResourceEnvironment objet .
Pour supprimer une ressource d’un catalogue, définissez catalogId sur l’ID du catalogue, requestTypeAdminRemovesur et sur l’objet accessPackageResource de ressource à supprimer. L’objet de ressource peut être récupéré à l’aide de list accessPackageResources.
Réponse
Si elle réussit, cette méthode renvoie un 201 Created code de réponse et un nouvel objet accessPackageResourceRequest dans le corps de la réponse.
Exemples
Exemple 1 : Créer un accessPackageResourceRequest pour ajouter un site en tant que ressource
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new AccessPackageResourceRequest
{
CatalogId = "26ac0c0a-08bc-4a7b-a313-839f58044ba5",
RequestType = "AdminAdd",
Justification = "",
AccessPackageResource = new 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",
},
};
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.IdentityGovernance.EntitlementManagement.AccessPackageResourceRequests.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
AccessPackageResourceRequest accessPackageResourceRequest = new AccessPackageResourceRequest();
accessPackageResourceRequest.setCatalogId("26ac0c0a-08bc-4a7b-a313-839f58044ba5");
accessPackageResourceRequest.setRequestType("AdminAdd");
accessPackageResourceRequest.setJustification("");
AccessPackageResource accessPackageResource = new AccessPackageResource();
accessPackageResource.setDisplayName("Sales");
accessPackageResource.setDescription("https://contoso.sharepoint.com/sites/Sales");
accessPackageResource.setUrl("https://contoso.sharepoint.com/sites/Sales");
accessPackageResource.setResourceType("SharePoint Online Site");
accessPackageResource.setOriginId("https://contoso.sharepoint.com/sites/Sales");
accessPackageResource.setOriginSystem("SharePointOnline");
accessPackageResourceRequest.setAccessPackageResource(accessPackageResource);
AccessPackageResourceRequest result = graphClient.identityGovernance().entitlementManagement().accessPackageResourceRequests().post(accessPackageResourceRequest);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.access_package_resource_request import AccessPackageResourceRequest
from msgraph_beta.generated.models.access_package_resource import AccessPackageResource
# To initialize your graph_client, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = AccessPackageResourceRequest(
catalog_id = "26ac0c0a-08bc-4a7b-a313-839f58044ba5",
request_type = "AdminAdd",
justification = "",
access_package_resource = AccessPackageResource(
display_name = "Sales",
description = "https://contoso.sharepoint.com/sites/Sales",
url = "https://contoso.sharepoint.com/sites/Sales",
resource_type = "SharePoint Online Site",
origin_id = "https://contoso.sharepoint.com/sites/Sales",
origin_system = "SharePointOnline",
),
)
result = await graph_client.identity_governance.entitlement_management.access_package_resource_requests.post(request_body)
Exemple 2 : Créer un accessPackageResourceRequest pour ajouter un site en tant que ressource et affecter un accessPackageResourceEnvironment à l’aide de @odata.bind
Demande
L’exemple suivant illustre une demande. Dans cet exemple, l’annotation @odata.bind est utilisée pour affecter le id de à accessPackageResourceEnvironment un accessPackageResourceEnvironment objet .
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new AccessPackageResourceRequest
{
CatalogId = "de9315c1-272b-4905-924b-cc112ca180c7",
AccessPackageResource = new AccessPackageResource
{
DisplayName = "Community Outreach",
Description = "https://contoso.sharepoint.com/sites/CSR",
ResourceType = "SharePoint Online Site",
OriginId = "https://contoso.sharepoint.com/sites/CSR",
OriginSystem = "SharePointOnline",
AdditionalData = new Dictionary<string, object>
{
{
"accessPackageResourceEnvironment@odata.bind" , "accessPackageResourceEnvironments/615f2218-678f-471f-a60a-02c2f4f80c57"
},
},
},
RequestType = "AdminAdd",
};
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.IdentityGovernance.EntitlementManagement.AccessPackageResourceRequests.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
AccessPackageResourceRequest accessPackageResourceRequest = new AccessPackageResourceRequest();
accessPackageResourceRequest.setCatalogId("de9315c1-272b-4905-924b-cc112ca180c7");
AccessPackageResource accessPackageResource = new AccessPackageResource();
accessPackageResource.setDisplayName("Community Outreach");
accessPackageResource.setDescription("https://contoso.sharepoint.com/sites/CSR");
accessPackageResource.setResourceType("SharePoint Online Site");
accessPackageResource.setOriginId("https://contoso.sharepoint.com/sites/CSR");
accessPackageResource.setOriginSystem("SharePointOnline");
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("accessPackageResourceEnvironment@odata.bind", "accessPackageResourceEnvironments/615f2218-678f-471f-a60a-02c2f4f80c57");
accessPackageResource.setAdditionalData(additionalData);
accessPackageResourceRequest.setAccessPackageResource(accessPackageResource);
accessPackageResourceRequest.setRequestType("AdminAdd");
AccessPackageResourceRequest result = graphClient.identityGovernance().entitlementManagement().accessPackageResourceRequests().post(accessPackageResourceRequest);
Exemple 3 : Créer un accessPackageResourceRequest pour ajouter un site en tant que ressource et affecter un accessPackageResourceEnvironment à l’aide de originId
Demande
L’exemple suivant illustre une demande. Dans cet exemple, les paramètres d’un accessPackageResourceEnvironment sont spécifiés dans un accessPackageResourceEnvironment objet .
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new AccessPackageResourceRequest
{
CatalogId = "de9315c1-272b-4905-924b-cc112ca180c7",
AccessPackageResource = new 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 = new AccessPackageResourceEnvironment
{
OriginId = "https://contoso-admin.sharepoint.com/",
},
},
RequestType = "AdminAdd",
};
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.IdentityGovernance.EntitlementManagement.AccessPackageResourceRequests.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
AccessPackageResourceRequest accessPackageResourceRequest = new AccessPackageResourceRequest();
accessPackageResourceRequest.setCatalogId("de9315c1-272b-4905-924b-cc112ca180c7");
AccessPackageResource accessPackageResource = new AccessPackageResource();
accessPackageResource.setDisplayName("Community Outreach");
accessPackageResource.setDescription("https://contoso.sharepoint.com/sites/CSR");
accessPackageResource.setResourceType("SharePoint Online Site");
accessPackageResource.setOriginId("https://contoso.sharepoint.com/sites/CSR");
accessPackageResource.setOriginSystem("SharePointOnline");
AccessPackageResourceEnvironment accessPackageResourceEnvironment = new AccessPackageResourceEnvironment();
accessPackageResourceEnvironment.setOriginId("https://contoso-admin.sharepoint.com/");
accessPackageResource.setAccessPackageResourceEnvironment(accessPackageResourceEnvironment);
accessPackageResourceRequest.setAccessPackageResource(accessPackageResource);
accessPackageResourceRequest.setRequestType("AdminAdd");
AccessPackageResourceRequest result = graphClient.identityGovernance().entitlementManagement().accessPackageResourceRequests().post(accessPackageResourceRequest);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.access_package_resource_request import AccessPackageResourceRequest
from msgraph_beta.generated.models.access_package_resource import AccessPackageResource
from msgraph_beta.generated.models.access_package_resource_environment import AccessPackageResourceEnvironment
# To initialize your graph_client, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = AccessPackageResourceRequest(
catalog_id = "de9315c1-272b-4905-924b-cc112ca180c7",
access_package_resource = AccessPackageResource(
display_name = "Community Outreach",
description = "https://contoso.sharepoint.com/sites/CSR",
resource_type = "SharePoint Online Site",
origin_id = "https://contoso.sharepoint.com/sites/CSR",
origin_system = "SharePointOnline",
access_package_resource_environment = AccessPackageResourceEnvironment(
origin_id = "https://contoso-admin.sharepoint.com/",
),
),
request_type = "AdminAdd",
)
result = await graph_client.identity_governance.entitlement_management.access_package_resource_requests.post(request_body)
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new AccessPackageResourceRequest
{
CatalogId = "beedadfe-01d5-4025-910b-84abb9369997",
RequestType = "AdminAdd",
AccessPackageResource = new AccessPackageResource
{
OriginId = "c6294667-7348-4f5a-be73-9d2c65f574f3",
OriginSystem = "AadGroup",
},
};
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.IdentityGovernance.EntitlementManagement.AccessPackageResourceRequests.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewAccessPackageResourceRequest()
catalogId := "beedadfe-01d5-4025-910b-84abb9369997"
requestBody.SetCatalogId(&catalogId)
requestType := "AdminAdd"
requestBody.SetRequestType(&requestType)
accessPackageResource := graphmodels.NewAccessPackageResource()
originId := "c6294667-7348-4f5a-be73-9d2c65f574f3"
accessPackageResource.SetOriginId(&originId)
originSystem := "AadGroup"
accessPackageResource.SetOriginSystem(&originSystem)
requestBody.SetAccessPackageResource(accessPackageResource)
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
accessPackageResourceRequests, err := graphClient.IdentityGovernance().EntitlementManagement().AccessPackageResourceRequests().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
AccessPackageResourceRequest accessPackageResourceRequest = new AccessPackageResourceRequest();
accessPackageResourceRequest.setCatalogId("beedadfe-01d5-4025-910b-84abb9369997");
accessPackageResourceRequest.setRequestType("AdminAdd");
AccessPackageResource accessPackageResource = new AccessPackageResource();
accessPackageResource.setOriginId("c6294667-7348-4f5a-be73-9d2c65f574f3");
accessPackageResource.setOriginSystem("AadGroup");
accessPackageResourceRequest.setAccessPackageResource(accessPackageResource);
AccessPackageResourceRequest result = graphClient.identityGovernance().entitlementManagement().accessPackageResourceRequests().post(accessPackageResourceRequest);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\AccessPackageResourceRequest;
use Microsoft\Graph\Beta\Generated\Models\AccessPackageResource;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AccessPackageResourceRequest();
$requestBody->setCatalogId('beedadfe-01d5-4025-910b-84abb9369997');
$requestBody->setRequestType('AdminAdd');
$accessPackageResource = new AccessPackageResource();
$accessPackageResource->setOriginId('c6294667-7348-4f5a-be73-9d2c65f574f3');
$accessPackageResource->setOriginSystem('AadGroup');
$requestBody->setAccessPackageResource($accessPackageResource);
$result = $graphServiceClient->identityGovernance()->entitlementManagement()->accessPackageResourceRequests()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.access_package_resource_request import AccessPackageResourceRequest
from msgraph_beta.generated.models.access_package_resource import AccessPackageResource
# To initialize your graph_client, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = AccessPackageResourceRequest(
catalog_id = "beedadfe-01d5-4025-910b-84abb9369997",
request_type = "AdminAdd",
access_package_resource = AccessPackageResource(
origin_id = "c6294667-7348-4f5a-be73-9d2c65f574f3",
origin_system = "AadGroup",
),
)
result = await graph_client.identity_governance.entitlement_management.access_package_resource_requests.post(request_body)
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new AccessPackageResourceRequest
{
CatalogId = "beedadfe-01d5-4025-910b-84abb9369997",
RequestType = "AdminRemove",
AccessPackageResource = new AccessPackageResource
{
Id = "354078e5-dbce-4894-8af4-0ab274d41662",
},
};
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.IdentityGovernance.EntitlementManagement.AccessPackageResourceRequests.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewAccessPackageResourceRequest()
catalogId := "beedadfe-01d5-4025-910b-84abb9369997"
requestBody.SetCatalogId(&catalogId)
requestType := "AdminRemove"
requestBody.SetRequestType(&requestType)
accessPackageResource := graphmodels.NewAccessPackageResource()
id := "354078e5-dbce-4894-8af4-0ab274d41662"
accessPackageResource.SetId(&id)
requestBody.SetAccessPackageResource(accessPackageResource)
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
accessPackageResourceRequests, err := graphClient.IdentityGovernance().EntitlementManagement().AccessPackageResourceRequests().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
AccessPackageResourceRequest accessPackageResourceRequest = new AccessPackageResourceRequest();
accessPackageResourceRequest.setCatalogId("beedadfe-01d5-4025-910b-84abb9369997");
accessPackageResourceRequest.setRequestType("AdminRemove");
AccessPackageResource accessPackageResource = new AccessPackageResource();
accessPackageResource.setId("354078e5-dbce-4894-8af4-0ab274d41662");
accessPackageResourceRequest.setAccessPackageResource(accessPackageResource);
AccessPackageResourceRequest result = graphClient.identityGovernance().entitlementManagement().accessPackageResourceRequests().post(accessPackageResourceRequest);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\AccessPackageResourceRequest;
use Microsoft\Graph\Beta\Generated\Models\AccessPackageResource;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AccessPackageResourceRequest();
$requestBody->setCatalogId('beedadfe-01d5-4025-910b-84abb9369997');
$requestBody->setRequestType('AdminRemove');
$accessPackageResource = new AccessPackageResource();
$accessPackageResource->setId('354078e5-dbce-4894-8af4-0ab274d41662');
$requestBody->setAccessPackageResource($accessPackageResource);
$result = $graphServiceClient->identityGovernance()->entitlementManagement()->accessPackageResourceRequests()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.access_package_resource_request import AccessPackageResourceRequest
from msgraph_beta.generated.models.access_package_resource import AccessPackageResource
# To initialize your graph_client, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = AccessPackageResourceRequest(
catalog_id = "beedadfe-01d5-4025-910b-84abb9369997",
request_type = "AdminRemove",
access_package_resource = AccessPackageResource(
id = "354078e5-dbce-4894-8af4-0ab274d41662",
),
)
result = await graph_client.identity_governance.entitlement_management.access_package_resource_requests.post(request_body)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
AccessPackageResourceRequest accessPackageResourceRequest = new AccessPackageResourceRequest();
accessPackageResourceRequest.setCatalogId("26ac0c0a-08bc-4a7b-a313-839f58044ba5");
accessPackageResourceRequest.setRequestType("AdminAdd");
accessPackageResourceRequest.setJustification("");
AccessPackageResource accessPackageResource = new AccessPackageResource();
accessPackageResource.setDisplayName("Faculty cafeteria ordering");
accessPackageResource.setDescription("Example application");
accessPackageResource.setUrl("https://myapps.microsoft.com/example.com/signin/Faculty%20cafeteria%20ordering/f1e3b407-942d-4934-9a3f-cef1975cb988/");
accessPackageResource.setResourceType("Application");
accessPackageResource.setOriginId("2f1099a6-d4fc-4cc9-a0ef-ddd3f1bf0b7e");
accessPackageResource.setOriginSystem("AadApplication");
LinkedList<AccessPackageResourceAttribute> attributes = new LinkedList<AccessPackageResourceAttribute>();
AccessPackageResourceAttribute accessPackageResourceAttribute = new AccessPackageResourceAttribute();
accessPackageResourceAttribute.setAttributeName("extension_2b676109c7c74ae2b41549205f1947ed_personalTitle");
accessPackageResourceAttribute.setIsEditable(true);
accessPackageResourceAttribute.setIsPersistedOnAssignmentRemoval(true);
AccessPackageResourceAttributeQuestion attributeSource = new AccessPackageResourceAttributeQuestion();
attributeSource.setOdataType("#microsoft.graph.accessPackageResourceAttributeQuestion");
AccessPackageTextInputQuestion question = new AccessPackageTextInputQuestion();
question.setOdataType("#microsoft.graph.accessPackageTextInputQuestion");
question.setIsRequired(false);
question.setSequence(0);
question.setIsSingleLineQuestion(true);
AccessPackageLocalizedContent text = new AccessPackageLocalizedContent();
text.setDefaultText("Title");
LinkedList<AccessPackageLocalizedText> localizedTexts = new LinkedList<AccessPackageLocalizedText>();
text.setLocalizedTexts(localizedTexts);
question.setText(text);
attributeSource.setQuestion(question);
accessPackageResourceAttribute.setAttributeSource(attributeSource);
AccessPackageUserDirectoryAttributeStore attributeDestination = new AccessPackageUserDirectoryAttributeStore();
attributeDestination.setOdataType("#microsoft.graph.accessPackageUserDirectoryAttributeStore");
accessPackageResourceAttribute.setAttributeDestination(attributeDestination);
attributes.add(accessPackageResourceAttribute);
accessPackageResource.setAttributes(attributes);
accessPackageResourceRequest.setAccessPackageResource(accessPackageResource);
AccessPackageResourceRequest result = graphClient.identityGovernance().entitlementManagement().accessPackageResourceRequests().post(accessPackageResourceRequest);