创建 sharePointProtectionPolicy

命名空间:microsoft.graph

为 M365 服务 SharePoint 创建保护策略。 将在状态中 inactive 创建策略。 用户还可以在政策下提供保护单位列表。

API 可用性

此 API 可用于以下国家级云部署。

全局服务 美国政府 L4 美国政府 L5 (DOD) 由世纪互联运营的中国
✅ ❌ ❌ ❌

权限

为此 API 选择标记为最低特权的权限。 只有在应用需要它时,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考。

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

HTTP 请求

POST /solutions/backupRestore/sharePointProtectionPolicies/

请求标头

名称 说明
Authorization 持有者 {token}。 必填。 详细了解 身份验证和授权。
Content-Type application/json. 必需。

请求正文

创建 sharePointProtectionPolicy 对象时,可以指定以下属性。

属性 类型 说明
displayName String SharePoint 保护策略的名称。 可选。
retentionSettings retentionSetting 集合 策略的保留设置。 可选。 如果省略,则默认保留期为 365 天。
siteProtectionUnits siteProtectionUnit 集合 要添加到 sharePointProtectionPolicy 对象的 siteProtectionUnits 的集合。 必填。 有关 siteId 的格式,请参阅 站点 。

响应

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

该服务返回完整的 retentionSettings 集合,而不是回显请求集合。 响应包括该间隔的R/PT10M固定 14 天 (P14D) 和该R/P1W间隔配置的策略保留期。 14 天是服务定义的备份层,不是创建或更新请求支持的策略保留期。

有关可能的错误响应列表,请参阅 备份存储 API 错误响应。

示例

请求

以下示例显示了如何创建保留期为 180 天的策略。

POST https://graph.microsoft.com/v1.0/solutions/backupRestore/sharePointProtectionPolicies
Content-Type: application/json

{
  "displayName": "SharePoint Protection Policy",
  "retentionSettings": [
    {
      "interval": "R/P1W",
      "period": "P180D"
    }
  ],
  "siteProtectionUnits": [
    {
      "siteId": "contoso.sharepoint.com,febad3c2-a7b2-454c-8910-272c7bcf78fc,ba7b70d0-8ba0-4cae-b19a-7cb8c739512f"
    },
    {
      "siteId": "contoso.sharepoint.com/sites/marketing,da60e844-ba1d-49bc-b4d4-d5e36bae9019,712a596e-90a1-49e3-9b48-bfa80bee8740"
    },
    {
      "siteId": "contoso.sharepoint.com/sites/hr,3bfc861e-9a17-4a27-9562-3d8b26c81bb5,0271110f-634f-4300-a841-3a8a2e851851"
    }
  ]
}

响应

下面的示例显示了两个备份间隔的保留设置的响应,包括请求的 180 天保留期。

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

HTTP/1.1 201 Created
Content-Location: https://graph.microsoft.com/v1.0/solutions/backupRestore/protectionPolicies/b218eb4a-ea72-42bd-8f0b-d0bbf794bec7

{
  "@odata.context": " /solutions/backupRestore/$metadata#sharePointProtectionPolicies/$entity",
  "id": "b218eb4a-ea72-42bd-8f0b-d0bbf794bec7",
  "displayName": "SharePoint Protection Policy",
  "status": "inactive",
  "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": "User2@constoso.com",
      "id": "845457dc-4bb2-4815-bef3-8628ebd1952e",
      "displayName": "User2"
    }
  },
  "lastModifiedDateTime": "2015-06-19T12:01:03.45Z",
  "retentionSettings": [
    {
      "interval": "R/PT10M",
      "period": "P14D"
    },
    {
      "interval": "R/P1W",
      "period": "P180D"
    }
  ]
}