שתף באמצעות


Get a list of self-serve policies

Gets a collection of resources that represents self-serve policies for an entity.

Prerequisites

C#

To get a list of all self-serve policies:

  1. Call the IAggregatePartner.With(IRequestContext) method with the entity identifier to retrieve an interface to operations on the policies.
// 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);

For an example, see the following:

  • Sample: Console test app
  • Project: PartnerSDK.FeatureSamples
  • Class: GetSelfServePolicies.cs

REST request

Request syntax

Method Request URI
GET {baseURL}/v1/SelfServePolicy?entity_id={entity_id} HTTP/1.1

URI parameter

Use the following query parameter to get a list of customers.

Name Type Required Description
entity_id string Y The entity identifier requesting access for. This will be the customer's tenant ID.

Request headers

For more information, see Headers.

Request body

None.

Request example

GET https://api.partnercenter.microsoft.com/v1/SelfServePolicy?entity_id=00aa00aa-bb11-cc22-dd33-44ee44ee44ee HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 3705fc6d-4127-4a87-bdba-9658f73fe019
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd

REST response

If successful, this method returns a collection of SelfServePolicy resources in the response body.

Response success and error codes

Each response comes with an HTTP status code that indicates success or failure and additional debugging information. Use a network trace tool to read this code, error type, and additional parameters. For a full list, see Error Codes.

Response example

HTTP/1.1 200 OK
Content-Length: 15650
Content-Type: application/json
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
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": "aaaabbbb-0000-cccc-1111-dddd2222eeee"
        },
        "grantor": {
            "grantorType": "billToPartner",
            "tenantID": "bbbbcccc-1111-dddd-2222-eeee3333ffff"
        },
        "permissions": [
            {
                "resource": "AzureReservedInstances",
                "action": "Purchase"
            },
            {
                "resource": "AzureSavingsPlan",
                "action": "Purchase"
            }
        ],
        "attributes": {
            "etag": "\"933523d1-3f63-4fc3-8789-5e21c02cdaed\"",
            "objectType": "SelfServePolicy"
        }
    }],
    "attributes": {
        "objectType": "Collection"
    }
}