名前空間: microsoft.graph
Microsoft 365 の OneDrive サービスの保護ポリシーを更新します。 このメソッドは、 driveProtectionUnit を oneDriveForBusinessProtectionPolicy オブジェクトに追加または削除します。
この API は、次の国内クラウド展開で使用できます。
グローバル サービス |
米国政府機関 L4 |
米国政府機関 L5 (DOD) |
21Vianet が運営する中国 |
✅ |
❌ |
❌ |
❌ |
アクセス許可
この API の最小特権としてマークされているアクセス許可またはアクセス許可を選択します。
アプリで必要な場合にのみ、より高い特権のアクセス許可またはアクセス許可を使用します。 委任されたアクセス許可とアプリケーションのアクセス許可の詳細については、「アクセス許可の種類」を参照してください。 これらのアクセス許可の詳細については、「アクセス許可のリファレンス」を参照してください。
アクセス許可の種類 |
最小特権アクセス許可 |
より高い特権のアクセス許可 |
委任 (職場または学校のアカウント) |
BackupRestore-Configuration.ReadWrite.All |
注意事項なし。 |
委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
サポートされていません。 |
アプリケーション |
BackupRestore-Configuration.ReadWrite.All |
注意事項なし。 |
HTTP 要求
PATCH /solutions/backupRestore/oneDriveForBusinessProtectionPolicies/{oneDriveForBusinessProtectionPolicyId}
名前 |
説明 |
Authorization |
ベアラー {token}。 必須です。
認証と認可についての詳細をご覧ください。 |
Content-Type |
application/json. 必須です。 |
要求本文
要求本文で、更新されたプロパティを使用して oneDriveForBusinessProtectionPolicy の JSON 表現を指定します。
ポリシーから driveProtectionUnit を削除するには、保護ユニットの要求本文に @removed
注釈を driveProtectionUnit の ID と共に指定します。
応答
成功した場合、このメソッドは 200 OK
応答コードと、応答本文で更新 された oneDriveForBusinessProtectionPolicy を返します。
考えられるエラー応答の一覧については、「 Backup Storage API エラー応答」を参照してください。
例
要求
次の例は要求を示しています。
PATCH https://graph.microsoft.com/v1.0/solutions/backupRestore/oneDriveForBusinessProtectionPolicies/845457dc-4bb2-4815-bef3-8628ebd1952e
{
"displayName": "One Drive Policy - Inadvertent data loss",
"driveProtectionUnits@delta": [
{
"directoryObjectId": "1b014d8c-71fe-4d00-a01a-31850bc5b32c"
},
{
"directoryObjectId": "2b014d8c-71fe-4d00-a01a-31850bc5b32c"
},
{
"@removed": {
"reason": "changed"
},
"id": "4267e382-71a9-4c07-bef7-bda97e09c0d2"
},
{
"@removed": {
"reason": "changed"
},
"id": "3667e382-71a9-4c07-bef7-bda97e09c0d2"
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
using Microsoft.Kiota.Abstractions.Serialization;
var requestBody = new OneDriveForBusinessProtectionPolicy
{
DisplayName = "One Drive Policy - Inadvertent data loss",
AdditionalData = new Dictionary<string, object>
{
{
"driveProtectionUnits@delta" , new List<object>
{
new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"directoryObjectId", new UntypedString("1b014d8c-71fe-4d00-a01a-31850bc5b32c")
},
}),
new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"directoryObjectId", new UntypedString("2b014d8c-71fe-4d00-a01a-31850bc5b32c")
},
}),
new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"@removed", new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"reason", new UntypedString("changed")
},
})
},
{
"id", new UntypedString("4267e382-71a9-4c07-bef7-bda97e09c0d2")
},
}),
new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"@removed", new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"reason", new UntypedString("changed")
},
})
},
{
"id", new UntypedString("3667e382-71a9-4c07-bef7-bda97e09c0d2")
},
}),
}
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Solutions.BackupRestore.OneDriveForBusinessProtectionPolicies["{oneDriveForBusinessProtectionPolicy-id}"].PatchAsync(requestBody);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
mgc solutions backup-restore one-drive-for-business-protection-policies patch --one-drive-for-business-protection-policy-id {oneDriveForBusinessProtectionPolicy-id}
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
OneDriveForBusinessProtectionPolicy oneDriveForBusinessProtectionPolicy = new OneDriveForBusinessProtectionPolicy();
oneDriveForBusinessProtectionPolicy.setDisplayName("One Drive Policy - Inadvertent data loss");
HashMap<String, Object> additionalData = new HashMap<String, Object>();
LinkedList<Object> driveProtectionUnitsDelta = new LinkedList<Object>();
property = new ();
property.setDirectoryObjectId("1b014d8c-71fe-4d00-a01a-31850bc5b32c");
driveProtectionUnitsDelta.add(property);
property1 = new ();
property1.setDirectoryObjectId("2b014d8c-71fe-4d00-a01a-31850bc5b32c");
driveProtectionUnitsDelta.add(property1);
property2 = new ();
removed = new ();
removed.setReason("changed");
property2.setRemoved(removed);
property2.setId("4267e382-71a9-4c07-bef7-bda97e09c0d2");
driveProtectionUnitsDelta.add(property2);
property3 = new ();
removed1 = new ();
removed1.setReason("changed");
property3.setRemoved(removed1);
property3.setId("3667e382-71a9-4c07-bef7-bda97e09c0d2");
driveProtectionUnitsDelta.add(property3);
additionalData.put("driveProtectionUnits@delta", driveProtectionUnitsDelta);
oneDriveForBusinessProtectionPolicy.setAdditionalData(additionalData);
OneDriveForBusinessProtectionPolicy result = graphClient.solutions().backupRestore().oneDriveForBusinessProtectionPolicies().byOneDriveForBusinessProtectionPolicyId("{oneDriveForBusinessProtectionPolicy-id}").patch(oneDriveForBusinessProtectionPolicy);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
const options = {
authProvider,
};
const client = Client.init(options);
const oneDriveForBusinessProtectionPolicy = {
displayName: 'One Drive Policy - Inadvertent data loss',
'driveProtectionUnits@delta': [
{
directoryObjectId: '1b014d8c-71fe-4d00-a01a-31850bc5b32c'
},
{
directoryObjectId: '2b014d8c-71fe-4d00-a01a-31850bc5b32c'
},
{
'@removed': {
reason: 'changed'
},
id: '4267e382-71a9-4c07-bef7-bda97e09c0d2'
},
{
'@removed': {
reason: 'changed'
},
id: '3667e382-71a9-4c07-bef7-bda97e09c0d2'
}
]
};
await client.api('/solutions/backupRestore/oneDriveForBusinessProtectionPolicies/845457dc-4bb2-4815-bef3-8628ebd1952e')
.update(oneDriveForBusinessProtectionPolicy);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\OneDriveForBusinessProtectionPolicy;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new OneDriveForBusinessProtectionPolicy();
$requestBody->setDisplayName('One Drive Policy - Inadvertent data loss');
$additionalData = [
'driveProtectionUnits@delta' => [
[
'directoryObjectId' => '1b014d8c-71fe-4d00-a01a-31850bc5b32c',
],
[
'directoryObjectId' => '2b014d8c-71fe-4d00-a01a-31850bc5b32c',
],
[
'@removed' => [
'reason' => 'changed',
],
'id' => '4267e382-71a9-4c07-bef7-bda97e09c0d2',
],
[
'@removed' => [
'reason' => 'changed',
],
'id' => '3667e382-71a9-4c07-bef7-bda97e09c0d2',
],
],
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->solutions()->backupRestore()->oneDriveForBusinessProtectionPolicies()->byOneDriveForBusinessProtectionPolicyId('oneDriveForBusinessProtectionPolicy-id')->patch($requestBody)->wait();
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
Import-Module Microsoft.Graph.BackupRestore
$params = @{
displayName = "One Drive Policy - Inadvertent data loss"
"driveProtectionUnits@delta" = @(
@{
directoryObjectId = "1b014d8c-71fe-4d00-a01a-31850bc5b32c"
}
@{
directoryObjectId = "2b014d8c-71fe-4d00-a01a-31850bc5b32c"
}
@{
"@removed" = @{
reason = "changed"
}
id = "4267e382-71a9-4c07-bef7-bda97e09c0d2"
}
@{
"@removed" = @{
reason = "changed"
}
id = "3667e382-71a9-4c07-bef7-bda97e09c0d2"
}
)
}
Update-MgSolutionBackupRestoreOneDriveForBusinessProtectionPolicy -OneDriveForBusinessProtectionPolicyId $oneDriveForBusinessProtectionPolicyId -BodyParameter $params
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.one_drive_for_business_protection_policy import OneDriveForBusinessProtectionPolicy
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = OneDriveForBusinessProtectionPolicy(
display_name = "One Drive Policy - Inadvertent data loss",
additional_data = {
"drive_protection_units@delta" : [
{
"directory_object_id" : "1b014d8c-71fe-4d00-a01a-31850bc5b32c",
},
{
"directory_object_id" : "2b014d8c-71fe-4d00-a01a-31850bc5b32c",
},
{
"@removed" : {
"reason" : "changed",
},
"id" : "4267e382-71a9-4c07-bef7-bda97e09c0d2",
},
{
"@removed" : {
"reason" : "changed",
},
"id" : "3667e382-71a9-4c07-bef7-bda97e09c0d2",
},
],
}
)
result = await graph_client.solutions.backup_restore.one_drive_for_business_protection_policies.by_one_drive_for_business_protection_policy_id('oneDriveForBusinessProtectionPolicy-id').patch(request_body)
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
応答
次の例は応答を示しています。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 200 OK
{
"displayName": "OneDrive Policy - Inadvertent data loss",
"driveProtectionUnits@delta": [
{
"id": "89014d8c-71fe-4d00-a01a-31850bc5b32c",
"policyId": "845457dc-4bb2-4815-bef3-8628ebd1952e",
"directoryObjectId": "1b014d8c-71fe-4d00-a01a-31850bc5b32c",
"status": "protectRequested",
"createdBy": {
"application": {
"id": "1fec8e78-bce4-4aaf-ab1b-5451cc387264",
"displayName": "Microsoft Enhanced Restore"
},
"user": {
"email": "User1@contoso.com",
"id": "845457dc-4bb2-4815-bef3-8628ebd1952e",
"displayName": "User1"
}
},
"createdDateTime": "2015-06-19T12:01:03.45Z",
"lastModifiedBy": {
"application": {
"id": "1fec8e78-bce4-4aaf-ab1b-5451cc387264",
"displayName": "Microsoft Enhanced Restore"
},
"user": {
"email": "User1@contoso.com",
"id": "845457dc-4bb2-4815-bef3-8628ebd1952e",
"displayName": "User1"
}
},
"lastModifiedDateTime": "2015-06-19T12:01:03.45Z"
},
{
"id": "67014d8c-71fe-4d00-a01a-31850bc5b32c",
"directoryObjectId": "2b014d8c-71fe-4d00-a01a-31850bc5b32c",
"policyId": "845457dc-4bb2-4815-bef3-8628ebd1952e",
"status": "protectRequested",
"createdBy": {
"application": {
"id": "1fec8e78-bce4-4aaf-ab1b-5451cc387264",
"displayName": "Microsoft Enhanced Restore"
},
"user": {
"email": "User1@contoso.com",
"id": "845457dc-4bb2-4815-bef3-8628ebd1952e",
"displayName": "User1"
}
},
"createdDateTime": "2015-06-19T12:01:03.45Z",
"lastModifiedBy": {
"application": {
"id": "1fec8e78-bce4-4aaf-ab1b-5451cc387264",
"displayName": "Microsoft Enhanced Restore"
},
"user": {
"email": "User1@contoso.com",
"id": "845457dc-4bb2-4815-bef3-8628ebd1952e",
"displayName": "User1"
}
},
"lastModifiedDateTime": "2015-06-19T12:01:03.45Z"
},
{
//Error scenario
"@contentId": "3467e382-71a9-4c07-bef7-bda97e09c0d2", // To add context and more traceability.
"@Core.DataModificationException": {
"info": {
"code": "Invalid",
"message": "The identifier to be removed from the Protection Policy does not exist"
},
"failedOperation": "remove",
"responseCode": 409
},
"id": "4267e382-71a9-4c07-bef7-bda97e09c0d2"
},
{
"id": "3667e382-71a9-4c07-bef7-bda97e09c0d2",
"directoryObjectId": "5767e382-71a9-4c07-bef7-bda97e09c0d2",
"policyId": "845457dc-4bb2-4815-bef3-8628ebd1952e",
"status": "removeRequested",
"createdBy": {
"application": {
"id": "1fec8e78-bce4-4aaf-ab1b-5451cc387264",
"displayName": "Microsoft Enhanced Restore"
},
"user": {
"email": "User1@contoso.com",
"id": "845457dc-4bb2-4815-bef3-8628ebd1952e",
"displayName": "User1"
}
},
"createdDateTime": "2015-06-19T12:01:03.45Z",
"lastModifiedBy": {
"application": {
"id": "1fec8e78-bce4-4aaf-ab1b-5451cc387264",
"displayName": "Microsoft Enhanced Restore"
},
"user": {
"email": "User1@contoso.com",
"id": "845457dc-4bb2-4815-bef3-8628ebd1952e",
"displayName": "User1"
}
},
"lastModifiedDateTime": "2015-06-19T12:01:03.45Z"
}
]
}