Créer retentionLabel
Article 04/09/2024
10 contributeurs
Commentaires
Dans cet article
Espace de noms : microsoft.graph.security
Importante
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 retentionLabel .
Pour créer une étape de révision de destruction , incluez la propriété actionAfterRetentionPeriod dans le corps de la demande avec l’une des valeurs possibles spécifiées.
Cette API est disponible dans les déploiements de cloud national suivants.
Service global
Gouvernement des États-Unis L4
Us Government L5 (DOD)
Chine gérée par 21Vianet
✅
✅
✅
❌
Autorisations
Choisissez l’autorisation ou les autorisations marquées comme moins privilégiées pour cette API. Utilisez une autorisation ou des autorisations privilégiées plus élevées uniquement si votre application en a besoin . Pour plus d’informations sur les autorisations déléguées et d’application, consultez Types d’autorisations . Pour en savoir plus sur ces autorisations, consultez les informations de référence sur les autorisations .
Type d’autorisation
Autorisations avec privilèges minimum
Autorisations privilégiées plus élevées
Déléguée (compte professionnel ou scolaire)
RecordsManagement.ReadWrite.All
Non disponible.
Déléguée (compte Microsoft personnel)
Non prise en charge.
Non prise en charge.
Application
Non prise en charge.
Non prise en charge.
Requête HTTP
POST /security/labels/retentionLabels
Corps de la demande
Dans le corps de la demande, fournissez une représentation JSON de l’objet retentionLabel .
Spécifiez les propriétés suivantes lorsque vous créez un retentionLabel .
Propriété
Type
Description
actionAfterRetentionPeriod
microsoft.graph.security.actionAfterRetentionPeriod
Spécifie l’action à entreprendre sur un document avec cette étiquette appliquée pendant la période de rétention. Les valeurs possibles sont : none
, delete
, startDispositionReview
, unknownFutureValue
.
behaviorDuringRetentionPeriod
microsoft.graph.security.behaviorDuringRetentionPeriod
Spécifie le comportement d’un document avec cette étiquette pendant la période de rétention. Les valeurs possibles sont : doNotRetain
, retain
, retainAsRecord
, retainAsRegulatoryRecord
, unknownFutureValue
.
descriptionForAdmins
Chaîne
Fournit des informations d’étiquette pour l’administrateur. Facultatif.
descriptionForUsers
Chaîne
Fournit les informations d’étiquette pour l’utilisateur. Optional.
displayName
Chaîne
Chaîne unique qui définit un nom d’étiquette.
dispositionReviewStages
collection microsoft.graph.security.dispositionReviewStage
Étapes de révision au cours desquelles les réviseurs sont avertis pour déterminer si un document doit être supprimé ou conservé.
retentionDuration
microsoft.graph.security.retentionDuration
Spécifie le nombre de jours pendant lesquels conserver le contenu.
retentionTrigger
microsoft.graph.security.retentionTrigger
Spécifie si la durée de rétention est calculée à partir de la date de création du contenu, de la date étiquetée ou de la date de la dernière modification. Les valeurs possibles sont : dateLabeled
, dateCreated
, dateModified
, dateOfEvent
, unknownFutureValue
.
defaultRecordBehavior
microsoft.graph.security.defaultRecordBehavior
Spécifie l’état verrouillé ou déverrouillé d’une étiquette d’enregistrement lors de sa création. Les valeurs possibles sont startLocked
, startUnlocked
, unknownFutureValue
.
labelToBeApplied
Chaîne
Spécifie l’étiquette de remplacement à appliquer automatiquement après la fin de la période de rétention de l’étiquette actuelle.
Réponse
Si elle réussit, cette méthode renvoie un 201 Created
code de réponse et un objet microsoft.graph.security.retentionLabel dans le corps de la réponse.
Exemples
Demande
Voici un exemple de demande.
POST https://graph.microsoft.com/beta/security/labels/retentionLabels
Content-Type: application/json
Content-length: 555
{
"@odata.type": "#microsoft.graph.security.retentionLabel",
"displayName": "Retention Schedule 10005",
"behaviorDuringRetentionPeriod": "retain",
"actionAfterRetentionPeriod": "startDispositionReview",
"retentionTrigger": "dateOfEvent",
"retentionEventType@odata.bind": "https://graph.microsoft.com/beta/security/triggerTypes/retentionEventTypes('e095f4fc-b966-4c40-94de-fb8a383658e4')",
"retentionDuration": {
"@odata.type": "microsoft.graph.security.retentionDurationInDays",
"days": 2555
},
"dispositionReviewStages": [
{
"stageNumber" : 1,
"name": "Stage1",
"reviewersEmailAddresses ": [
"Admin@contoso.onmicrosoft.com"
]
}
],
"descriptionForAdmins": "retain for 7 years",
"descriptionForUsers": "retain for 7 years",
"descriptors": {
"authorityTemplate@odata.bind" : "https://graph.microsoft.com/beta/security/labels/authorities('fie3f4fc-b966-4c40-94de-fb8a383658e4')",
"categoryTemplate@odata.bind" : "https://graph.microsoft.com/beta/security/labels/categories('0bjk8-b966-4c40-94de-fb8a383658e4')",
"citationTemplate@odata.bind" : "https://graph.microsoft.com/beta/security/labels/citations('0e23f4fc-b966-4c40-94de-fb8a383658e4')",
"departmentTemplate@odata.bind" : "https://graph.microsoft.com/beta/security/labels/departments('p99ef4fc-b966-4c40-94de-fb8a383658e4')",
"filePlanReferenceTemplate@odata.bind" : "https://graph.microsoft.com/beta/security/labels/filePlanReferences('e095f4fc-b966-4c40-94de-fb8a383658e4')"
},
"defaultRecordBehavior":"startLocked",
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models.Security;
var requestBody = new RetentionLabel
{
OdataType = "#microsoft.graph.security.retentionLabel",
DisplayName = "Retention Schedule 10005",
BehaviorDuringRetentionPeriod = BehaviorDuringRetentionPeriod.Retain,
ActionAfterRetentionPeriod = ActionAfterRetentionPeriod.StartDispositionReview,
RetentionTrigger = RetentionTrigger.DateOfEvent,
RetentionDuration = new RetentionDurationInDays
{
OdataType = "microsoft.graph.security.retentionDurationInDays",
Days = 2555,
},
DispositionReviewStages = new List<DispositionReviewStage>
{
new DispositionReviewStage
{
StageNumber = 1,
Name = "Stage1",
AdditionalData = new Dictionary<string, object>
{
{
"reviewersEmailAddresses " , new List<string>
{
"Admin@contoso.onmicrosoft.com",
}
},
},
},
},
DescriptionForAdmins = "retain for 7 years",
DescriptionForUsers = "retain for 7 years",
Descriptors = new FilePlanDescriptor
{
AdditionalData = new Dictionary<string, object>
{
{
"authorityTemplate@odata.bind" , "https://graph.microsoft.com/beta/security/labels/authorities('fie3f4fc-b966-4c40-94de-fb8a383658e4')"
},
{
"categoryTemplate@odata.bind" , "https://graph.microsoft.com/beta/security/labels/categories('0bjk8-b966-4c40-94de-fb8a383658e4')"
},
{
"citationTemplate@odata.bind" , "https://graph.microsoft.com/beta/security/labels/citations('0e23f4fc-b966-4c40-94de-fb8a383658e4')"
},
{
"departmentTemplate@odata.bind" , "https://graph.microsoft.com/beta/security/labels/departments('p99ef4fc-b966-4c40-94de-fb8a383658e4')"
},
{
"filePlanReferenceTemplate@odata.bind" , "https://graph.microsoft.com/beta/security/labels/filePlanReferences('e095f4fc-b966-4c40-94de-fb8a383658e4')"
},
},
},
DefaultRecordBehavior = DefaultRecordBehavior.StartLocked,
AdditionalData = new Dictionary<string, object>
{
{
"retentionEventType@odata.bind" , "https://graph.microsoft.com/beta/security/triggerTypes/retentionEventTypes('e095f4fc-b966-4c40-94de-fb8a383658e4')"
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Security.Labels.RetentionLabels.PostAsync(requestBody);
mgc-beta security labels retention-labels create --body '{\
"@odata.type": "#microsoft.graph.security.retentionLabel",\
"displayName": "Retention Schedule 10005",\
"behaviorDuringRetentionPeriod": "retain",\
"actionAfterRetentionPeriod": "startDispositionReview",\
"retentionTrigger": "dateOfEvent",\
"retentionEventType@odata.bind": "https://graph.microsoft.com/beta/security/triggerTypes/retentionEventTypes('e095f4fc-b966-4c40-94de-fb8a383658e4')",\
"retentionDuration": {\
"@odata.type": "microsoft.graph.security.retentionDurationInDays",\
"days": 2555\
},\
"dispositionReviewStages": [\
{\
"stageNumber" : 1,\
"name": "Stage1",\
"reviewersEmailAddresses ": [\
"Admin@contoso.onmicrosoft.com"\
]\
}\
],\
"descriptionForAdmins": "retain for 7 years",\
"descriptionForUsers": "retain for 7 years",\
"descriptors": {\
"authorityTemplate@odata.bind" : "https://graph.microsoft.com/beta/security/labels/authorities('fie3f4fc-b966-4c40-94de-fb8a383658e4')",\
"categoryTemplate@odata.bind" : "https://graph.microsoft.com/beta/security/labels/categories('0bjk8-b966-4c40-94de-fb8a383658e4')",\
"citationTemplate@odata.bind" : "https://graph.microsoft.com/beta/security/labels/citations('0e23f4fc-b966-4c40-94de-fb8a383658e4')",\
"departmentTemplate@odata.bind" : "https://graph.microsoft.com/beta/security/labels/departments('p99ef4fc-b966-4c40-94de-fb8a383658e4')",\
"filePlanReferenceTemplate@odata.bind" : "https://graph.microsoft.com/beta/security/labels/filePlanReferences('e095f4fc-b966-4c40-94de-fb8a383658e4')"\
},\
"defaultRecordBehavior":"startLocked",\
}\
'
// 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"
graphmodelssecurity "github.com/microsoftgraph/msgraph-beta-sdk-go/models/security"
//other-imports
)
requestBody := graphmodelssecurity.NewRetentionLabel()
displayName := "Retention Schedule 10005"
requestBody.SetDisplayName(&displayName)
behaviorDuringRetentionPeriod := graphmodels.RETAIN_BEHAVIORDURINGRETENTIONPERIOD
requestBody.SetBehaviorDuringRetentionPeriod(&behaviorDuringRetentionPeriod)
actionAfterRetentionPeriod := graphmodels.STARTDISPOSITIONREVIEW_ACTIONAFTERRETENTIONPERIOD
requestBody.SetActionAfterRetentionPeriod(&actionAfterRetentionPeriod)
retentionTrigger := graphmodels.DATEOFEVENT_RETENTIONTRIGGER
requestBody.SetRetentionTrigger(&retentionTrigger)
retentionDuration := graphmodelssecurity.NewRetentionDurationInDays()
days := int32(2555)
retentionDuration.SetDays(&days)
requestBody.SetRetentionDuration(retentionDuration)
dispositionReviewStage := graphmodelssecurity.NewDispositionReviewStage()
stageNumber := int32(1)
dispositionReviewStage.SetStageNumber(&stageNumber)
name := "Stage1"
dispositionReviewStage.SetName(&name)
additionalData := map[string]interface{}{
reviewersEmailAddresses := []string {
"Admin@contoso.onmicrosoft.com",
}
}
dispositionReviewStage.SetAdditionalData(additionalData)
dispositionReviewStages := []graphmodelssecurity.DispositionReviewStageable {
dispositionReviewStage,
}
requestBody.SetDispositionReviewStages(dispositionReviewStages)
descriptionForAdmins := "retain for 7 years"
requestBody.SetDescriptionForAdmins(&descriptionForAdmins)
descriptionForUsers := "retain for 7 years"
requestBody.SetDescriptionForUsers(&descriptionForUsers)
descriptors := graphmodelssecurity.NewFilePlanDescriptor()
additionalData := map[string]interface{}{
"authorityTemplate@odata.bind" : "https://graph.microsoft.com/beta/security/labels/authorities('fie3f4fc-b966-4c40-94de-fb8a383658e4')",
"categoryTemplate@odata.bind" : "https://graph.microsoft.com/beta/security/labels/categories('0bjk8-b966-4c40-94de-fb8a383658e4')",
"citationTemplate@odata.bind" : "https://graph.microsoft.com/beta/security/labels/citations('0e23f4fc-b966-4c40-94de-fb8a383658e4')",
"departmentTemplate@odata.bind" : "https://graph.microsoft.com/beta/security/labels/departments('p99ef4fc-b966-4c40-94de-fb8a383658e4')",
"filePlanReferenceTemplate@odata.bind" : "https://graph.microsoft.com/beta/security/labels/filePlanReferences('e095f4fc-b966-4c40-94de-fb8a383658e4')",
}
descriptors.SetAdditionalData(additionalData)
requestBody.SetDescriptors(descriptors)
defaultRecordBehavior := graphmodels.STARTLOCKED_DEFAULTRECORDBEHAVIOR
requestBody.SetDefaultRecordBehavior(&defaultRecordBehavior)
additionalData := map[string]interface{}{
"retentionEventType@odata.bind" : "https://graph.microsoft.com/beta/security/triggerTypes/retentionEventTypes('e095f4fc-b966-4c40-94de-fb8a383658e4')",
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
retentionLabels, err := graphClient.Security().Labels().RetentionLabels().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.models.security.RetentionLabel retentionLabel = new com.microsoft.graph.beta.models.security.RetentionLabel();
retentionLabel.setOdataType("#microsoft.graph.security.retentionLabel");
retentionLabel.setDisplayName("Retention Schedule 10005");
retentionLabel.setBehaviorDuringRetentionPeriod(com.microsoft.graph.beta.models.security.BehaviorDuringRetentionPeriod.Retain);
retentionLabel.setActionAfterRetentionPeriod(com.microsoft.graph.beta.models.security.ActionAfterRetentionPeriod.StartDispositionReview);
retentionLabel.setRetentionTrigger(com.microsoft.graph.beta.models.security.RetentionTrigger.DateOfEvent);
com.microsoft.graph.beta.models.security.RetentionDurationInDays retentionDuration = new com.microsoft.graph.beta.models.security.RetentionDurationInDays();
retentionDuration.setOdataType("microsoft.graph.security.retentionDurationInDays");
retentionDuration.setDays(2555);
retentionLabel.setRetentionDuration(retentionDuration);
LinkedList<com.microsoft.graph.beta.models.security.DispositionReviewStage> dispositionReviewStages = new LinkedList<com.microsoft.graph.beta.models.security.DispositionReviewStage>();
com.microsoft.graph.beta.models.security.DispositionReviewStage dispositionReviewStage = new com.microsoft.graph.beta.models.security.DispositionReviewStage();
dispositionReviewStage.setStageNumber(1);
dispositionReviewStage.setName("Stage1");
HashMap<String, Object> additionalData = new HashMap<String, Object>();
LinkedList<String> reviewersEmailAddresses = new LinkedList<String>();
reviewersEmailAddresses.add("Admin@contoso.onmicrosoft.com");
additionalData.put("reviewersEmailAddresses ", reviewersEmailAddresses);
dispositionReviewStage.setAdditionalData(additionalData);
dispositionReviewStages.add(dispositionReviewStage);
retentionLabel.setDispositionReviewStages(dispositionReviewStages);
retentionLabel.setDescriptionForAdmins("retain for 7 years");
retentionLabel.setDescriptionForUsers("retain for 7 years");
com.microsoft.graph.beta.models.security.FilePlanDescriptor descriptors = new com.microsoft.graph.beta.models.security.FilePlanDescriptor();
HashMap<String, Object> additionalData1 = new HashMap<String, Object>();
additionalData1.put("authorityTemplate@odata.bind", "https://graph.microsoft.com/beta/security/labels/authorities('fie3f4fc-b966-4c40-94de-fb8a383658e4')");
additionalData1.put("categoryTemplate@odata.bind", "https://graph.microsoft.com/beta/security/labels/categories('0bjk8-b966-4c40-94de-fb8a383658e4')");
additionalData1.put("citationTemplate@odata.bind", "https://graph.microsoft.com/beta/security/labels/citations('0e23f4fc-b966-4c40-94de-fb8a383658e4')");
additionalData1.put("departmentTemplate@odata.bind", "https://graph.microsoft.com/beta/security/labels/departments('p99ef4fc-b966-4c40-94de-fb8a383658e4')");
additionalData1.put("filePlanReferenceTemplate@odata.bind", "https://graph.microsoft.com/beta/security/labels/filePlanReferences('e095f4fc-b966-4c40-94de-fb8a383658e4')");
descriptors.setAdditionalData(additionalData1);
retentionLabel.setDescriptors(descriptors);
retentionLabel.setDefaultRecordBehavior(com.microsoft.graph.beta.models.security.DefaultRecordBehavior.StartLocked);
HashMap<String, Object> additionalData2 = new HashMap<String, Object>();
additionalData2.put("retentionEventType@odata.bind", "https://graph.microsoft.com/beta/security/triggerTypes/retentionEventTypes('e095f4fc-b966-4c40-94de-fb8a383658e4')");
retentionLabel.setAdditionalData(additionalData2);
com.microsoft.graph.models.security.RetentionLabel result = graphClient.security().labels().retentionLabels().post(retentionLabel);
const options = {
authProvider,
};
const client = Client.init(options);
const retentionLabel = {
'@odata.type': '#microsoft.graph.security.retentionLabel',
displayName: 'Retention Schedule 10005',
behaviorDuringRetentionPeriod: 'retain',
actionAfterRetentionPeriod: 'startDispositionReview',
retentionTrigger: 'dateOfEvent',
'retentionEventType@odata.bind': 'https://graph.microsoft.com/beta/security/triggerTypes/retentionEventTypes(\'e095f4fc-b966-4c40-94de-fb8a383658e4\')',
retentionDuration: {
'@odata.type': 'microsoft.graph.security.retentionDurationInDays',
days: 2555
},
dispositionReviewStages: [
{
stageNumber: 1,
name: 'Stage1',
'reviewersEmailAddresses ': [
'Admin@contoso.onmicrosoft.com'
]
}
],
descriptionForAdmins: 'retain for 7 years',
descriptionForUsers: 'retain for 7 years',
descriptors: {
'authorityTemplate@odata.bind': 'https://graph.microsoft.com/beta/security/labels/authorities(\'fie3f4fc-b966-4c40-94de-fb8a383658e4\')',
'categoryTemplate@odata.bind': 'https://graph.microsoft.com/beta/security/labels/categories(\'0bjk8-b966-4c40-94de-fb8a383658e4\')',
'citationTemplate@odata.bind': 'https://graph.microsoft.com/beta/security/labels/citations(\'0e23f4fc-b966-4c40-94de-fb8a383658e4\')',
'departmentTemplate@odata.bind': 'https://graph.microsoft.com/beta/security/labels/departments(\'p99ef4fc-b966-4c40-94de-fb8a383658e4\')',
'filePlanReferenceTemplate@odata.bind': 'https://graph.microsoft.com/beta/security/labels/filePlanReferences(\'e095f4fc-b966-4c40-94de-fb8a383658e4\')'
},
defaultRecordBehavior: 'startLocked',
};
await client.api('/security/labels/retentionLabels')
.version('beta')
.post(retentionLabel);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\Security\RetentionLabel;
use Microsoft\Graph\Beta\Generated\Models\Security\BehaviorDuringRetentionPeriod;
use Microsoft\Graph\Beta\Generated\Models\Security\ActionAfterRetentionPeriod;
use Microsoft\Graph\Beta\Generated\Models\Security\RetentionTrigger;
use Microsoft\Graph\Beta\Generated\Models\Security\RetentionDurationInDays;
use Microsoft\Graph\Beta\Generated\Models\Security\DispositionReviewStage;
use Microsoft\Graph\Beta\Generated\Models\Security\FilePlanDescriptor;
use Microsoft\Graph\Beta\Generated\Models\Security\DefaultRecordBehavior;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new RetentionLabel();
$requestBody->setOdataType('#microsoft.graph.security.retentionLabel');
$requestBody->setDisplayName('Retention Schedule 10005');
$requestBody->setBehaviorDuringRetentionPeriod(new BehaviorDuringRetentionPeriod('retain'));
$requestBody->setActionAfterRetentionPeriod(new ActionAfterRetentionPeriod('startDispositionReview'));
$requestBody->setRetentionTrigger(new RetentionTrigger('dateOfEvent'));
$retentionDuration = new RetentionDurationInDays();
$retentionDuration->setOdataType('microsoft.graph.security.retentionDurationInDays');
$retentionDuration->setDays(2555);
$requestBody->setRetentionDuration($retentionDuration);
$dispositionReviewStagesDispositionReviewStage1 = new DispositionReviewStage();
$dispositionReviewStagesDispositionReviewStage1->setStageNumber(1);
$dispositionReviewStagesDispositionReviewStage1->setName('Stage1');
$additionalData = [
'reviewersEmailAddresses ' => [
'Admin@contoso.onmicrosoft.com', ],
];
$dispositionReviewStagesDispositionReviewStage1->setAdditionalData($additionalData);
$dispositionReviewStagesArray []= $dispositionReviewStagesDispositionReviewStage1;
$requestBody->setDispositionReviewStages($dispositionReviewStagesArray);
$requestBody->setDescriptionForAdmins('retain for 7 years');
$requestBody->setDescriptionForUsers('retain for 7 years');
$descriptors = new FilePlanDescriptor();
$additionalData = [
'authorityTemplate@odata.bind' => 'https://graph.microsoft.com/beta/security/labels/authorities(\'fie3f4fc-b966-4c40-94de-fb8a383658e4\')',
'categoryTemplate@odata.bind' => 'https://graph.microsoft.com/beta/security/labels/categories(\'0bjk8-b966-4c40-94de-fb8a383658e4\')',
'citationTemplate@odata.bind' => 'https://graph.microsoft.com/beta/security/labels/citations(\'0e23f4fc-b966-4c40-94de-fb8a383658e4\')',
'departmentTemplate@odata.bind' => 'https://graph.microsoft.com/beta/security/labels/departments(\'p99ef4fc-b966-4c40-94de-fb8a383658e4\')',
'filePlanReferenceTemplate@odata.bind' => 'https://graph.microsoft.com/beta/security/labels/filePlanReferences(\'e095f4fc-b966-4c40-94de-fb8a383658e4\')',
];
$descriptors->setAdditionalData($additionalData);
$requestBody->setDescriptors($descriptors);
$requestBody->setDefaultRecordBehavior(new DefaultRecordBehavior('startLocked'));
$additionalData = [
'retentionEventType@odata.bind' => 'https://graph.microsoft.com/beta/security/triggerTypes/retentionEventTypes(\'e095f4fc-b966-4c40-94de-fb8a383658e4\')',
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->security()->labels()->retentionLabels()->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.security.retention_label import RetentionLabel
from msgraph_beta.generated.models.behavior_during_retention_period import BehaviorDuringRetentionPeriod
from msgraph_beta.generated.models.action_after_retention_period import ActionAfterRetentionPeriod
from msgraph_beta.generated.models.retention_trigger import RetentionTrigger
from msgraph_beta.generated.models.security.retention_duration_in_days import RetentionDurationInDays
from msgraph_beta.generated.models.security.disposition_review_stage import DispositionReviewStage
from msgraph_beta.generated.models.security.file_plan_descriptor import FilePlanDescriptor
from msgraph_beta.generated.models.default_record_behavior import DefaultRecordBehavior
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = RetentionLabel(
odata_type = "#microsoft.graph.security.retentionLabel",
display_name = "Retention Schedule 10005",
behavior_during_retention_period = BehaviorDuringRetentionPeriod.Retain,
action_after_retention_period = ActionAfterRetentionPeriod.StartDispositionReview,
retention_trigger = RetentionTrigger.DateOfEvent,
retention_duration = RetentionDurationInDays(
odata_type = "microsoft.graph.security.retentionDurationInDays",
days = 2555,
),
disposition_review_stages = [
DispositionReviewStage(
stage_number = 1,
name = "Stage1",
additional_data = {
"reviewers_email_addresses " : [
"Admin@contoso.onmicrosoft.com",
],
}
),
],
description_for_admins = "retain for 7 years",
description_for_users = "retain for 7 years",
descriptors = FilePlanDescriptor(
additional_data = {
"authority_template@odata_bind" : "https://graph.microsoft.com/beta/security/labels/authorities('fie3f4fc-b966-4c40-94de-fb8a383658e4')",
"category_template@odata_bind" : "https://graph.microsoft.com/beta/security/labels/categories('0bjk8-b966-4c40-94de-fb8a383658e4')",
"citation_template@odata_bind" : "https://graph.microsoft.com/beta/security/labels/citations('0e23f4fc-b966-4c40-94de-fb8a383658e4')",
"department_template@odata_bind" : "https://graph.microsoft.com/beta/security/labels/departments('p99ef4fc-b966-4c40-94de-fb8a383658e4')",
"file_plan_reference_template@odata_bind" : "https://graph.microsoft.com/beta/security/labels/filePlanReferences('e095f4fc-b966-4c40-94de-fb8a383658e4')",
}
),
default_record_behavior = DefaultRecordBehavior.StartLocked,
additional_data = {
"retention_event_type@odata_bind" : "https://graph.microsoft.com/beta/security/triggerTypes/retentionEventTypes('e095f4fc-b966-4c40-94de-fb8a383658e4')",
}
)
result = await graph_client.security.labels.retention_labels.post(request_body)
Réponse
Voici un exemple de réponse.
Remarque : l’objet de réponse affiché ci-après peut être raccourci pour plus de lisibilité.
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.security.retentionLabel",
"id": "64a99fb4-07be-0481-8746-44c15c0eef1f",
"displayName": "Retention Schedule 10005",
"behaviorDuringRetentionPeriod": "retain",
"actionAfterRetentionPeriod": "startDispositionReview",
"retentionTrigger": "dateOfEvent",
"retentionDuration": {
"@odata.type": "microsoft.graph.security.retentionDurationInDays",
"days": 2555
},
"dispositionReviewStages": [
{
"stageNumber" : 1,
"name": "Stage1",
"reviewersEmailAddresses ": [
"Admin@contoso.onmicrosoft.com"
]
}
],
"isInUse": true,
"descriptionForAdmins": "retain for 7 years",
"descriptionForUsers": "retain for 7 years",
"defaultRecordBehavior":"startLocked",
"createdBy": {
"user": {
"id": "9563a605-e827-4324-a5a9-09efddff1e90",
"displayName": "Admin"
}
},
"createdDateTime": "2021-08-23T16:43:55Z",
"labelToBeApplied": " ",
"defaultRecordBehavior": "startLocked",
"descriptors": {
"authority": {
"displayName": "Business"
},
"category": {
"displayName": "Accounts Payable",
},
"citation": {
"displayName" : "Contoso Company Policy",
"citationUrl": "www.citationUrl.com",
"citationJurisdiction": "Contoso"
},
"department": {
"displayName" : "Finance"
},
"filePlanReference": {
"displayName" : "FIN 01-02-001"
}
}
}