Microsoft Partner Center (Independent Publisher) (#1834)

* First commit

* docs

* added dome additional info to readme

* fix some readme issues

* fix some readme issues

* fix some readme issues

* fix some readme issues

* rename apidefinition

* remove Microsoft-Partner-Center.swagger.json

* Fixed some descriptions
This commit is contained in:
oleksii-innoware 2023-04-28 07:16:23 +03:00 коммит произвёл GitHub
Родитель 56bc929abe
Коммит 15056cbfcd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 944 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,50 @@
# Microsoft Partner Center
The Partner Center API helps Cloud Solution Provider (CSP) partners integrate their existing CRM or billing software with the Microsoft systems that manage customer accounts, place orders, manage subscriptions, and handle support requests.
## Publisher: Oleksii Skirko | Innoware
## Prerequisites
You will need the following to proceed:
- A Microsoft PowerApps or Microsoft Flow plan with custom connector feature
- Access to Microsoft Partner Center with appropriate permissions to call API functions
- The Power platform CLI tools
- AAD Application
Since the APIs used by the connector are secured by Azure Active Directory (AD), we first need to set up a few things in Azure AD for connector to securely access them. After this setup, you can create and test the connector.
### Azure AD Application
Since the connector uses OAuth as authentication type, we first need to register an application in Azure AD. This application will be used to get the authorization token required to invoke rest APIs used by the connector on user's behalf. You can read more about this [here](https://docs.microsoft.com/en-us/partner/develop/api-authentication#application-and-user-access). Please use **Application and user access section** in this link. For redirect URI, use "https://global.consent.azure-apim.net/redirect". For the credentials, use a client secret (and not certificates). **Remember to note the secret down**, you will need this later and it is shown only once.
### Install paconn
- Install Python 3.5+ from [https://www.python.org/downloads](Python downloads). Select the Download link on any version of Python greater than Python 3.5. For Linux and macOS X, follow the appropriate link on the page. You can also install using an OS-specific package manager of your choice.
- Run the installer to begin installation and be sure to check the box 'Add Python X.X to PATH'.
- Make sure the installation path is in the PATH variable by running:
`python --version`
- After python is installed, install `paconn` by running:
`pip install paconn`\
If you get errors saying 'Access is denied', consider using the `--user` option or running the command as an Administrator (Windows).
You can find more details regarding `paconn` by following this [link](https://docs.microsoft.com/en-us/connectors/custom-connectors/paconn-cli)
## Supported Operations
The connector currently supports the following operations:
### [Get Invoices](https://docs.microsoft.com/en-us/partner-center/develop/get-a-collection-of-invoices)
Retrieves a collection of the partner's invoices.
### [Get Customers](https://docs.microsoft.com/en-us/partner-center/develop/get-a-list-of-customers)
Gets a collection of resources that represents all of a partner's customers.
### [Get Subscriptions](https://docs.microsoft.com/en-us/partner-center/develop/get-all-of-a-customer-s-subscriptions)
Gets a collection of a customer's subscriptions.
### [Get customer orders](https://docs.microsoft.com/en-us/partner-center/develop/get-all-of-a-customer-s-orders)
Gets a collection of all the orders for a specified customer.
### [Get customer details](https://docs.microsoft.com/en-us/partner-center/develop/get-a-customer-by-id)
Gets customer's details from Business and Company profiles
## Deployment Instructions
Add your Application ID to clientId property of `apiProperties.json` file.\
Run the following commands and follow the prompts:\
`paconn create --api-def apiDefinition.swagger.json --api-prop apiProperties.json --secret <client_secret>`

Просмотреть файл

@ -0,0 +1,841 @@
{
"swagger": "2.0",
"info": {
"title": "Microsoft Partner Center",
"description": "This connector allows you to connect to MPC API and collect some information including customer details, orders and subscriptions.",
"version": "1.0",
"contact": {
"name": "Oleksii Skirko, Innoware Ukraine LLC",
"url": "https://innoware.com/",
"email": "oleksiiskirko@innoware.com"
}
},
"x-ms-connector-metadata": [
{
"propertyName": "Website",
"propertyValue": "https://docs.microsoft.com/en-us/partner-center/develop/"
},
{
"propertyName": "Privacy policy",
"propertyValue": "https://privacy.microsoft.com/en-us/privacystatement"
},
{
"propertyName": "Categories",
"propertyValue": "IT Operations;Business Management"
}
],
"host": "api.partnercenter.microsoft.com",
"basePath": "/",
"schemes": [
"https"
],
"consumes": [],
"produces": [],
"paths": {
"/v1/invoices": {
"get": {
"responses": {
"200": {
"description": "default",
"schema": {
"type": "object",
"properties": {
"totalCount": {
"type": "integer",
"format": "int32",
"description": "Total count of elements in the collection.",
"title": "Total Count"
},
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "The invoice identifier.",
"title": "ID",
"x-ms-visibility": "important"
},
"invoiceDate": {
"type": "string",
"description": "The date the invoice was generated.",
"title": "Invoice Date"
},
"billingPeriodStartDate": {
"type": "string",
"description": "Billing period start date in UTC.",
"title": "Billing Period Start Date"
},
"billingPeriodEndDate": {
"type": "string",
"description": "Billing period end date in UTC.",
"title": "Billing Period End Date"
},
"totalCharges": {
"type": "number",
"format": "float",
"description": "The total charges. Includes charges for transactions and any adjustments.",
"title": "Total Charges"
},
"paidAmount": {
"type": "number",
"format": "float",
"description": "The amount paid by the partner. Negative if a payment was received.",
"title": "Paid Amount"
},
"currencyCode": {
"type": "string",
"description": "A code that indicates the currency used for all invoice item amounts and totals.",
"title": "Currency Code"
},
"currencySymbol": {
"type": "string",
"description": "The currency symbol used for all invoice item amounts and totals.",
"title": "Currency Symbol"
},
"pdfDownloadLink": {
"type": "string",
"description": "A link to download the invoice in PDF format. This link isn't returned as part of the search results, and is populated only if the invoice is accessed by ID. This link auto-expires in 30 minutes.",
"title": "PDF Download Link"
},
"invoiceDetails": {
"type": "array",
"items": {
"type": "object",
"properties": {
"invoiceLineItemType": {
"type": "string",
"description": "The type of invoice detail: \"none\", \"usage_line_items\", \"billing_line_items\".",
"title": "Invoice Line Item Type"
},
"billingProvider": {
"type": "string",
"description": "The billing provider: \"none\", \"office\", \"azure\" or \"azure_data_market\".",
"title": "Billing Provider"
}
}
},
"description": "The invoice details."
},
"documentType": {
"type": "string",
"description": "The document type of the invoice: \"Credit Note\", \"Invoice\".",
"title": "Document Type"
},
"invoiceType": {
"type": "string",
"description": "The type of invoice: \"recurring\", \"one_time\".",
"title": "Invoice Type"
}
}
},
"description": "items"
}
}
}
}
},
"summary": "Get invoices",
"operationId": "GetInvoices",
"parameters": [
{
"name": "Size",
"in": "query",
"required": false,
"type": "integer",
"description": "The number of invoice resources to return in the response. This parameter is optional.",
"format": "int32",
"x-ms-summary": "Size"
},
{
"name": "Offset",
"in": "query",
"required": false,
"type": "string",
"description": "The zero-based index of the first invoice to return.",
"x-ms-summary": "Offset"
}
],
"description": "Get a collection of invoices."
}
},
"/v1/customers": {
"get": {
"responses": {
"200": {
"description": "default",
"schema": {
"type": "object",
"properties": {
"totalCount": {
"type": "integer",
"format": "int32",
"title": "Total Count",
"description": "Total count of elements in collection"
},
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "The customer ID.",
"title": "ID",
"x-ms-visibility": "important"
},
"companyProfile": {
"type": "object",
"properties": {
"tenantId": {
"type": "string",
"description": "The customer's tenant identifier for Azure AD. This is also called a MicrosoftID.",
"title": "Tenant ID",
"x-ms-visibility": "important"
},
"domain": {
"type": "string",
"description": "The customer's name, such as contoso.onmicrosoft.com.",
"title": "Domain"
},
"companyName": {
"type": "string",
"description": "The name of the company or organization.",
"title": "Company Name",
"x-ms-visibility": "important"
}
},
"description": "Company Profile",
"title": "Company Profile"
},
"relationshipToPartner": {
"type": "string",
"description": "Defines the licensing program that the partner uses for this customer: \"none\", \"reseller\", \"advisor\", \"syndication\" or \"microsoft_support\".",
"title": "Relationship To Partner"
}
}
},
"description": "items"
}
}
}
}
},
"summary": "Get All Customers",
"parameters": [
{
"name": "Size",
"in": "query",
"required": false,
"type": "string",
"x-ms-summary": "Size",
"description": "The number of results to be displayed at one time."
}
],
"description": "Get a list of customers.",
"operationId": "GetAllCustomers"
}
},
"/v1/customers/{CustomerTenantID}/subscriptions": {
"get": {
"responses": {
"200": {
"description": "default",
"schema": {
"type": "object",
"properties": {
"totalCount": {
"type": "integer",
"format": "int32",
"description": "Total count of subscriptions for customer.",
"title": "Total Count"
},
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "The subscription identifier.",
"title": "ID",
"x-ms-visibility": "important"
},
"offerId": {
"type": "string",
"description": "The offer identifier.",
"title": "Offer ID",
"x-ms-visibility": "important"
},
"offerName": {
"type": "string",
"description": "The offer name.",
"title": "Offer Name"
},
"friendlyName": {
"type": "string",
"description": "The friendly name for the subscription defined by the partner to help disambiguate.",
"title": "Friendly Name"
},
"productType": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "The subscription identifier.",
"title": "ID"
},
"displayName": {
"type": "string",
"description": "Display Name.",
"title": "Display Name"
}
},
"description": "productType"
},
"quantity": {
"type": "integer",
"format": "int32",
"description": "Provides the subscription quantity after provisioning.",
"title": "Quantity"
},
"unitType": {
"type": "string",
"description": "The units defining quantity for the subscription.",
"title": "Unit Type"
},
"hasPurchasableAddons": {
"type": "boolean",
"description": "A value indicating whether the subscription has purchasable add-ons.",
"title": "Has Purchasable Addons",
"enum": [
true,
false
]
},
"creationDate": {
"type": "string",
"description": "The creation date, in date-time format.",
"title": "Creation Date"
},
"effectiveStartDate": {
"type": "string",
"description": "The effective start date for this subscription, in date-time format.",
"title": "Effective Start Date"
},
"commitmentEndDate": {
"type": "string",
"description": "The commitment end date for this subscription, in date-time format.",
"title": "Commitment End Date"
},
"cancellationAllowedUntilDate": {
"type": "string",
"description": "The last date for cancellation.",
"title": "Cancellation Allowed Until Date"
},
"billingCycleEndDate": {
"type": "string",
"description": "The billing cycle end date for this subscription, in date-time format.",
"title": "Billing Cycle End Date"
},
"status": {
"type": "string",
"description": "Indicates the provisioning status: \"success\", \"pending\" or \"failed\".",
"title": "Status"
},
"autoRenewEnabled": {
"type": "boolean",
"description": "autoRenewEnabled",
"title": "Auto Renew Enabled",
"enum": [
true,
false
]
},
"isTrial": {
"type": "boolean",
"description": "A value indicating whether the subscription is a trial.",
"title": "Is Trial",
"enum": [
true,
false
]
},
"billingType": {
"type": "string",
"description": "Specifies how the subscription is billed: \"none\", \"usage\", or \"license\".",
"title": "Billing Type"
},
"billingCycle": {
"type": "string",
"description": "Indicates the frequency with which the partner is billed for this order.",
"title": "Billing Cycle"
},
"termDuration": {
"type": "string",
"description": "An ISO 8601 representation of the term's duration.",
"title": "Term Duration"
},
"renewalTermDuration": {
"type": "string",
"description": "An ISO 8601 representation of the term's duration.",
"title": "Renewal Term Duration"
},
"isMicrosoftProduct": {
"type": "boolean",
"description": "A value indicating whether the subscription is a Microsoft product.",
"title": "Is Microsoft Product",
"enum": [
true,
false
]
},
"partnerId": {
"type": "string",
"description": "The MPN ID of the reseller of record, used in the indirect partner model.",
"title": "Partner ID"
},
"attentionNeeded": {
"type": "boolean",
"description": "Is Attention Needed.",
"title": "Attention Needed"
},
"contractType": {
"type": "string",
"description": "The type of contract: \"subscription\", \"productKey\", or \"redemptionCode\".",
"title": "Contract Type"
},
"publisherName": {
"type": "string",
"description": "The publisher name.",
"title": "Publisher Name"
},
"promotionId": {
"type": "string",
"description": "The promotion identifier if applied to the subscription.",
"title": "Promotion ID"
},
"orderId": {
"type": "string",
"description": "The ID of the order that was placed to begin the subscription.",
"title": "Order ID"
}
}
},
"description": "items"
}
}
}
}
},
"summary": "Get customer subscriptions",
"description": "Gets a collection of all the subscriptions for a specified customer.",
"operationId": "GetCustomerSubscription",
"parameters": [
{
"name": "CustomerTenantID",
"in": "path",
"required": true,
"type": "string",
"x-ms-summary": "Customer tenant ID",
"description": "A customer's tenant ID.",
"x-ms-url-encoding": "single"
}
]
}
},
"/v1/customers/{CustomerTenantID}/orders": {
"get": {
"responses": {
"200": {
"description": "default",
"schema": {
"type": "object",
"properties": {
"totalCount": {
"type": "integer",
"format": "int32",
"description": "Total count of customer orders.",
"title": "Total Count"
},
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "An order identifier.",
"title": "ID",
"x-ms-visibility": "important"
},
"alternateId": {
"type": "string",
"description": "A friendly identifier for the order.",
"title": "Alternate ID"
},
"referenceCustomerId": {
"type": "string",
"description": "The customer identifier.",
"title": "Customer ID"
},
"billingCycle": {
"type": "string",
"description": "Indicates the frequency with which the partner is billed for this order.",
"title": "Billing Cycle"
},
"currencyCode": {
"type": "string",
"description": "The currency used when placing the order.",
"title": "Currency Code"
},
"currencySymbol": {
"type": "string",
"description": "The currency symbol associated with the currency code.",
"title": "Currency Symbol"
},
"lineItems": {
"type": "array",
"items": {
"type": "object",
"properties": {
"lineItemNumber": {
"type": "integer",
"format": "int32",
"description": "Line item number."
},
"offerId": {
"type": "string",
"description": "The ID of the offer.",
"title": "Offer ID"
},
"subscriptionId": {
"type": "string",
"description": "The ID of the subscription.",
"title": "Subscription ID"
},
"termDuration": {
"type": "string",
"description": "An ISO 8601 representation of the term's duration.",
"title": "Term Duration"
},
"promotionId": {
"type": "string",
"description": "Promotion ID.",
"title": "Promotion ID"
},
"customTermEndDate": {
"type": "string",
"description": "The end date of the first billing term of the new subscription.",
"title": "Custom Term End Date"
},
"transactionType": {
"type": "string",
"description": "The transaction type of the line item.",
"title": "Transaction Type"
},
"friendlyName": {
"type": "string",
"description": "The friendly name for the subscription defined by the partner to help disambiguate.",
"title": "Friendly Name"
},
"quantity": {
"type": "integer",
"format": "int32",
"description": "Quantity"
}
}
},
"description": "lineItems"
},
"creationDate": {
"type": "string",
"description": "The date the order was created, in date-time format.",
"title": "Creation Date"
},
"status": {
"type": "string",
"description": "The status of the order.",
"title": "Status"
},
"transactionType": {
"type": "string",
"description": "The transaction type of the order. Supported values are 'UserPurchase', 'SystemPurchase', or 'SystemBilling'",
"title": "Transaction Type"
}
}
},
"description": "items"
}
}
}
}
},
"description": "Gets a collection of all the orders for a specified customer.",
"summary": "Get customer orders",
"operationId": "GetCustomerOrders",
"parameters": [
{
"name": "CustomerTenantID",
"in": "path",
"required": true,
"type": "string",
"x-ms-summary": "Customer tenant ID",
"description": "A customer tenant ID.",
"x-ms-url-encoding": "single"
}
]
}
},
"/v1/customers/{CustomerTenantID}": {
"get": {
"responses": {
"200": {
"description": "default",
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "The customer ID.",
"title": "ID",
"x-ms-visibility": "important"
},
"commerceId": {
"type": "string",
"description": "The commerce ID.",
"title": "The commerce ID."
},
"companyProfile": {
"type": "object",
"properties": {
"tenantId": {
"type": "string",
"description": "The customer's tenant identifier for Azure AD. This is also called a MicrosoftID.",
"title": "Tenant ID",
"x-ms-visibility": "important"
},
"companyName": {
"type": "string",
"description": "The name of the company or organization.",
"title": "Company Name (Company Profile).",
"x-ms-visibility": "important"
},
"domain": {
"type": "string",
"description": "The customer's name, such as contoso.onmicrosoft.com.",
"title": "Domain",
"x-ms-visibility": "important"
},
"address": {
"type": "object",
"properties": {
"country": {
"type": "string",
"description": "The country.",
"title": "Country (Company Profile)"
},
"region": {
"type": "string",
"description": "The region.",
"title": "Region (Company Profile)."
},
"city": {
"type": "string",
"description": "The city.",
"title": "City (Company Profile)"
},
"state": {
"type": "string",
"description": "The state.",
"title": "State (Company Profile)"
},
"addressLine1": {
"type": "string",
"description": "The first line of the address.",
"title": "Address Line1 (Company Profile)"
},
"postalCode": {
"type": "string",
"description": "The ZIP code or postal code.",
"title": "Postal Code (Company Profile)"
},
"phoneNumber": {
"type": "string",
"description": "The phone number of a contact at the customer's company/organization.",
"title": "Phone Number (Company Profile)"
}
},
"description": "Address",
"title": "Address (Company Profile)"
},
"email": {
"type": "string",
"description": "Email.",
"title": "Email (Company Profile)"
}
},
"description": "Company Profile",
"title": "Company Profile"
},
"billingProfile": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "The profile identifier.",
"title": "Profile ID"
},
"firstName": {
"type": "string",
"description": "The first name of the billing contact at the customer's company.",
"title": "First Name (Billing Profile)"
},
"lastName": {
"type": "string",
"description": "The last name of the billing contact.",
"title": "Last Name (Billing Profile)"
},
"email": {
"type": "string",
"description": "The billing contact's email address",
"title": "Email (Billing Profile)"
},
"culture": {
"type": "string",
"description": "Their preferred culture for communication and currency, such as \"en-us\".",
"title": "Culture (Billing Profile)"
},
"language": {
"type": "string",
"description": "Their preferred language for communication.",
"title": "Language (Billing Profile)"
},
"companyName": {
"type": "string",
"description": "The name of the company or organization.",
"title": "Company Name (Billing Profile)"
},
"defaultAddress": {
"type": "object",
"properties": {
"country": {
"type": "string",
"description": "The country/region in ISO country code format.",
"title": "Country (Billing Profile)"
},
"region": {
"type": "string",
"description": "The region.",
"title": "Region (Billing Profile)"
},
"city": {
"type": "string",
"description": "The city.",
"title": "City (Billing Profile)"
},
"state": {
"type": "string",
"description": "The state.",
"title": "State (Billing Profile)"
},
"addressLine1": {
"type": "string",
"description": "The first line of the address.",
"title": "AddressLine1 (Billing Profile)"
},
"postalCode": {
"type": "string",
"description": "The ZIP code or postal code.",
"title": "Postal Code (Billing Profile)"
},
"firstName": {
"type": "string",
"description": "The first name of a contact at the customer's company/organization.",
"title": "First Name (Billing Profile)"
},
"lastName": {
"type": "string",
"description": "The last name of a contact at the customer's company/organization.",
"title": "Last Name (Billing Profile)"
},
"phoneNumber": {
"type": "string",
"description": "The phone number of a contact at the customer's company/organization.",
"title": "Phone Number (Billing Profile)"
}
},
"description": "Billing profile default address",
"title": "Billing Profile Address"
}
},
"description": "Billing Profile",
"title": "Billing Profile"
},
"relationshipToPartner": {
"type": "string",
"description": "Defines the licensing program that the partner uses for this customer: \"none\", \"reseller\", \"advisor\", \"syndication\" or \"microsoft_support\".",
"title": "Relationship To Partner"
},
"allowDelegatedAccess": {
"type": "boolean",
"description": "Indicates whether the partner has been granted delegated admin privileges by this customer.",
"title": "Allow Delegated Access",
"enum": [
true,
false
]
},
"customDomains": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of custom domains of a customer.",
"title": "Custom Domains"
}
}
}
}
},
"summary": "Get customer details",
"operationId": "GetCustomerDetails",
"parameters": [
{
"name": "CustomerTenantID",
"in": "path",
"required": true,
"type": "string",
"x-ms-summary": "Customer tenant ID",
"description": "A customer tenant ID",
"x-ms-url-encoding": "single"
}
],
"description": "Gets a Customer resource that corresponds to a customer ID."
}
}
},
"definitions": {},
"parameters": {},
"responses": {},
"securityDefinitions": {
"oauth2_auth": {
"type": "oauth2",
"flow": "accessCode",
"authorizationUrl": "https://login.windows.net/common/oauth2/authorize",
"tokenUrl": "https://login.windows.net/common/oauth2/authorize",
"scopes": {
"client_credentials": "client_credentials"
}
}
},
"security": [
{
"oauth2_auth": [
"client_credentials"
]
}
],
"tags": []
}

Просмотреть файл

@ -0,0 +1,53 @@
{
"properties": {
"connectionParameters": {
"token": {
"type": "oauthSetting",
"oAuthSettings": {
"identityProvider": "aad",
"clientId": "<AAD Application ID>",
"scopes": [
"client_credentials"
],
"redirectMode": "Global",
"redirectUrl": "https://global.consent.azure-apim.net/redirect",
"properties": {
"IsFirstParty": "False",
"AzureActiveDirectoryResourceId": "https://api.partnercenter.microsoft.com",
"IsOnbehalfofLoginSupported": true
},
"customParameters": {
"loginUri": {
"value": "https://login.windows.net"
},
"tenantId": {
"value": "common"
},
"resourceUri": {
"value": "https://api.partnercenter.microsoft.com"
},
"enableOnbehalfOfLogin": {
"value": "false"
}
}
}
},
"token:TenantId": {
"type": "string",
"metadata": {
"sourceType": "AzureActiveDirectoryTenant"
},
"uiDefinition": {
"constraints": {
"required": "false",
"hidden": "true"
}
}
}
},
"iconBrandColor": "#da3b01",
"capabilities": [],
"publisher": "Oleksii Skirko, Innoware Ukraine LLC",
"stackOwner": "Microsoft Corporation"
}
}