SelfServePolicy 만들기

이 문서에서는 새 셀프 서비스 정책을 만드는 방법을 설명합니다.

필수 구성 요소

  • 자격 증명(파트너 센터 인증에서 설명). 이 시나리오에서는 Application+User 자격 증명을 사용한 인증을 지원합니다.

C#

셀프 서비스 정책을 만듭니다.

  1. 셀프 서비스 정책 정보를 사용하여 IAggregatePartner.SelfServePolicies.Create 또는 IAggregatePartner.SelfServePolicies.CreateAsync 메서드를 호출합니다.
// IAggregatePartner partnerOperations;
string customerIdAsEntity;

var selfServePolicy = new SelfServePolicy
{
    SelfServeEntity = new SelfServeEntity
    {
        SelfServeEntityType = "customer",
        TenantID = customerIdAsEntity,
    },
    Grantor = new Grantor
    {
        GrantorType = "billToPartner",
        TenantID = partnerIdAsGrantor,
    },
    Permissions = new Permission[]
    {
        new Permission
        {
        Action = "Purchase",
        Resource = "AzureReservedInstances",
        },
    },
    {
        new Permission
        {
        Action = "Purchase",
        Resource = "AzureSavingsPlan",
        },
    },
};

// 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()));

// creates the self-serve policy
SelfServePolicy createdSelfServePolicy = scopedPartnerOperations.selfServePolicies.Create(selfServePolicy);

예제는 다음을 참조하세요.

  • 샘플: 콘솔 테스트 앱
  • 프로젝트: PartnerSDK.FeatureSamples
  • 클래스: CreateSelfServePolicies.cs

REST 요청

요청 구문

방법 요청 URI
POST {baseURL}/v1/SelfServePolicy HTTP/1.1

요청 헤더

요청 본문

이 표에서는 요청 본문의 필수 속성에 대해 설명합니다.

Name 형식 Description
SelfServePolicy object 셀프 서비스 정책 정보입니다.

SelfServePolicy

이 표에서는 새 셀프 서비스 정책을 만드는 데 필요한 SelfServePolicy 리소스의 최소 필수 필드를 설명합니다.

속성 형식 Description
SelfServeEntity SelfServeEntity 액세스 권한이 부여되는 셀프 서비스 엔터티입니다.
Grantor Grantor 액세스 권한을 부여하는 피부여자입니다.
사용 권한 권한 배열 권한 리소스의 배열입니다.

요청 예제

POST https://api.partnercenter.microsoft.com/v1/SelfServePolicy HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 94e4e214-6b06-4fb7-96d1-94d559f9b47f
MS-CorrelationId: ab993325-1605-4cf4-bac4-fb584142a31b
X-Locale: en-US
Content-Type: application/json
Host: api.partnercenter.microsoft.com
Content-Length: 789
Expect: 100-continue
Connection: Keep-Alive

{
    "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"
        }
    ]
}

REST 응답

성공하면 이 API는 새 셀프 서비스 정책에 대한 SelfServePolicy 리소스를 반환합니다.

응답 성공 및 오류 코드

각 응답에는 성공 또는 실패와 추가 디버깅 정보를 나타내는 HTTP 상태 코드가 함께 제공됩니다. 네트워크 추적 도구를 사용하여 이 코드, 오류 유형 및 추가 매개 변수를 읽을 수 있습니다. 전체 목록은 파트너 센터 REST 오류 코드를 참조하세요.

이 메서드는 다음 오류 코드를 반환합니다.

HTTP 상태 코드 오류 코드 Description
409 600041 셀프 서비스 정책이 이미 있습니다.

응답 예제

HTTP/1.1 201 Created
Content-Length: 834
Content-Type: application/json; charset=utf-8
MS-CorrelationId: ab993325-1605-4cf4-bac4-fb584142a31b
MS-RequestId: 94e4e214-6b06-4fb7-96d1-94d559f9b47f
Date: Tue, 14 Feb 2017 20:06:02 GMT

{
    "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"
    }
}