获取自助服务策略的列表

获取表示实体的自助服务策略的资源集合。

必备条件

C#

若要获取所有自助服务策略的列表,请执行以下操作:

  1. 使用实体标识符调用 IAggregatePartner.With (IRequestContext) 方法,以检索策略操作的接口。
// IAggregatePartner partnerOperations;

// All the operations executed on this partner operation instance will share the same correlation Id but will differ in request Id
IPartner scopedPartnerOperations = partnerOperations.With(RequestContextFactory.Instance.Create(Guid.NewGuid()));

// gets the self-serve policies
var SelfServePolicies = scopedPartnerOperations.SelfServePolicies.Get(customerIdAsEntity);

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

REST 请求

请求语法

方法 请求 URI
GET {baseURL}/v1/SelfServePolicy?entity_id={entity_id} HTTP/1.1

URI 参数

使用以下查询参数获取客户列表。

名称 类型 必须 说明
entity_id string Y 请求访问的实体标识符。 这是客户的租户 ID。

请求标头

有关详细信息,请参阅 标头

请求正文

无。

请求示例

GET https://api.partnercenter.microsoft.com/v1/SelfServePolicy?entity_id=0431a72c-7d8a-4393-b25e-ef63f5efb415 HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 3705fc6d-4127-4a87-bdba-9658f73fe019
MS-CorrelationId: b12260fb-82de-4701-a25f-dcd367690645

REST 响应

如果成功,此方法在响应正文中返回 SelfServePolicy 资源的集合。

响应的成功和错误代码

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

响应示例

HTTP/1.1 200 OK
Content-Length: 15650
Content-Type: application/json
MS-CorrelationId: b12260fb-82de-4701-a25f-dcd367690645
MS-RequestId: 3705fc6d-4127-4a87-bdba-9658f73fe019
Date: Fri, 20 Nov 2015 01:08:23 GMT

{
    "totalCount": 1,
    "items": [{
        "id": "634f6379-ad54-449b-9821-564f737158ab_0431a72c-7d8a-4393-b25e-ef63f5efb415",
        "selfServeEntity": {
            "selfServeEntityType": "customer",
            "tenantID": "0431a72c-7d8a-4393-b25e-ef63f5efb415"
        },
        "grantor": {
            "grantorType": "billToPartner",
            "tenantID": "634f6379-ad54-449b-9821-564f737158ab"
        },
        "permissions": [
            {
                "resource": "AzureReservedInstances",
                "action": "Purchase"
            },
            {
                "resource": "AzureSavingsPlan",
                "action": "Purchase"
            }
        ],
        "attributes": {
            "etag": "\"933523d1-3f63-4fc3-8789-5e21c02cdaed\"",
            "objectType": "SelfServePolicy"
        }
    }],
    "attributes": {
        "objectType": "Collection"
    }
}