获取某位客户的策略的列表

适用于:合作伙伴中心

本文介绍如何检索指定客户的配置策略的集合。

必备条件

  • 合作伙伴中心身份验证中所述的凭据。 此方案支持使用独立应用和应用+用户凭据进行身份验证。

  • 客户 ID (customer-tenant-id)。 如果不知道客户的 ID,可以在 合作伙伴中心进行查找。 从合作伙伴中心主页中选择 “客户 ”工作区。 从“客户 ”列表中选择客户,然后选择“ 帐户”。 在客户的“帐户”页上,在“ 客户帐户详细信息”部分查找 Microsoft ID。 Microsoft ID 与客户 ID (customer-tenant-id) 相同。

C#

若要获取客户的所有策略的列表,请执行以下操作:

  1. 使用客户 ID 调用 IAggregatePartner.Customers.ById 方法,以检索针对指定客户的操作的接口。

  2. 检索 ConfigurationPolicies 属性以获取配置策略收集操作的接口。

  3. 调用 GetGetAsync 方法来检索策略集合。

IAggregatePartner partnerOperations;
string selectedCustomerId;

var configPolicies = partnerOperations.Customers.ById(selectedCustomerId).ConfigurationPolicies.Get();

有关示例,请参阅以下内容:

  • 示例: 控制台测试应用
  • 项目: 合作伙伴中心 SDK 示例
  • 类: GetAllConfigurationPolicies.cs

REST 请求

请求语法

方法 请求 URI
GET {baseURL}/v1/customers/{customer-id}/policies HTTP/1.1

URI 参数

创建请求时使用以下路径参数:

名称 类型 必须 说明
customer-id string 一个 GUID 格式的字符串,用于标识客户。

请求标头

有关详细信息,请参阅合作伙伴中心 REST 标头

请求正文

请求示例

GET https://api.partnercenter.microsoft.com/v1/customers/47021739-3426-40bf-9601-61b4b6d7c793/policies HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: e88d014d-ab70-41de-90a0-f7fd1797267d
MS-CorrelationId: de894e18-f027-4ac0-8b5a-34f0c222af0c
Content-Length:0
X-Locale: en-US
Host: api.partnercenter.microsoft.com

REST 响应

如果成功,响应正文将包含 ConfigurationPolicy 资源的集合。

响应的成功和错误代码

每个响应都带有一个 HTTP 状态代码,用于指示成功或失败以及其他调试信息。 请使用网络跟踪工具来读取此代码、错误类型和其他参数。 有关完整列表,请参阅 合作伙伴中心 REST 错误代码

响应示例

HTTP/1.1 200 OK
Content-Length: 1221
Content-Type: application/json; charset=utf-8
MS-CorrelationId: d5ff2573-3ef8-4553-aac4-4b73d97dce1b
MS-RequestId: 6eb7383d-eeb5-44d7-8570-e0ed12c0547a
MS-CV: YrLe3w6BbUSMt1fi.0
MS-ServerId: 030020344
Date: Tue, 25 Jul 2017 18:07:49 GMT

{
    "totalCount": 3,
    "items": [{
            "id": "8c7d25aa-2dbb-409c-a1f0-f55bd9108fa9",
            "name": "Windows 10 Enterprise E3",
            "category": "o_o_b_e",
            "description": "P462017 description",
            "devicesAssigned": 0,
            "policySettings": ["oobe_user_not_local_admin", "skip_express_settings"],
            "createdDate": "2017-04-27T11:30:34.1944704-07:00",
            "lastModifiedDate": "2017-04-27T11:30:34.1944704-07:00",
            "attributes": {
                "objectType": "ConfigurationPolicy"
            }
        }, {
            "id": "56edf752-ee77-4fd8-b7f5-df1f74a3a9ac",
            "name": "Test policy",
            "category": "o_o_b_e",
            "description": "Test policy creation from API 1",
            "devicesAssigned": 0,
            "policySettings": ["skip_express_settings"],
            "createdDate": "2017-07-25T11:03:03.8457088-07:00",
            "lastModifiedDate": "2017-07-25T11:04:00.8150016-07:00",
            "attributes": {
                "objectType": "ConfigurationPolicy"
            }
        }, {
            "id": "a96b5fd9-0f3a-419a-b55c-a8aecd6b1f00",
            "name": "Windows 10 Enterprise E5",
            "category": "o_o_b_e",
            "description": "test policy creation from API",
            "devicesAssigned": 0,
            "policySettings": ["oobe_user_not_local_admin", "skip_express_settings"],
            "createdDate": "2017-07-25T11:07:36.1501184-07:00",
            "lastModifiedDate": "2017-07-25T11:07:36.1501184-07:00",
            "attributes": {
                "objectType": "ConfigurationPolicy"
            }
        }
    ],
    "attributes": {
        "objectType": "Collection"
    }
}