npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@compusoluciones/microsoft-sdk

v0.2.4

Published

*** ## Tabla de contenidos * Estructura de las credenciales. * Creación del objeto. * Consumption Azure * Obtener el consumo de cada cliente o UF del reseller (no incluida para Azure Plan). * Obtener el costo de todas las suscripciones de un cli

Downloads

15

Readme

SDK Microsoft CSP


Tabla de contenidos

  • Estructura de las credenciales.
  • Creación del objeto.
  • Consumption Azure
    • Obtener el consumo de cada cliente o UF del reseller (no incluida para Azure Plan).
    • Obtener el costo de todas las suscripciones de un cliente.
    • Obtener el costo por suscripción.
    • Obtener los registros de uso por suscripción. (no incluida para Azure Plan).
    • Obtener el registro de uso de cada cliente o UF del reseller.
    • Obtener el registro de uso por cliente.
    • Obtener el registro de uso por 'meter' por suscripción.
    • Obtener los registros de uso por suscripción. (solo para Azure Plan).
  • Customer
    • (Doc pendiente)
  • Offers
    • (Doc pendiente)
  • Utilities
    • (Doc pendiente)
  • Billing
    • (Doc Pendiente)
  • Agreements
    • (Doc pendiente)
  • Products
    • Obtener lista de productos por
    • Upgrade Azure
    • Revisar eligibilidad para upgrade Azure
    • Revisar estatus del upgrade.
  • Budget
    • Actualizar el budget de un UF.
    • Obtener el budget de un UF.
  • Invoices *Obtener todos los invoices
    • Obtener invoices por size.
    • Obtener invoices por offset.
    • Obtener invoices por offset y size.

Credentials.

Es importante usar las credenciales de la cuenta de CSP a la cual vamos a acceder de la siguiente manera:

const credentials = {
  clientId: 'client_id',
  domain: 'partner_tenant_id',
  client_secret: 'client_secret',
  refresh_token: 'refresh_token',
};

Debemos crear un nuevo objeto para poder llamar a las funciones de nuestro SDK.

const UserPartnerOperations = require('./dist');
const userPartnerOperations = new UserPartnerOperations(credentials);

Azure Consumption.


1. UsageSummaryAzure

Como llamar esta función:

userPartnerOperations.azure.getTotalSummary()

Ejemplo de respuesta:

{
  "customersOverBudget": 2,
  "customersTrendingOver": 1,
  "customersWithUsageBasedSubscription": 151,
  "resourceId": "9e09e971-5b2c-47d3-acec-be60c2665bae",
  "id": "9e09e971-5b2c-47d3-acec-be60c2665bae",
  "resourceName": "COMPUSOLUCIONES Y ASOCIADOS SA DE CV ",
  "name": "COMPUSOLUCIONES Y ASOCIADOS SA DE CV ",
  "billingStartDate": "2020-01-22T00:00:00+00:00",
  "billingEndDate": "2020-02-21T00:00:00+00:00",
  "totalCost": 2581.449771,
  "currencyLocale": "en-US",
  "lastModifiedDate": "2020-02-04T12:03:27.833+00:00",
  "links": {
    "self": {
      "uri": "/usagesummary",
      "method": "GET",
      "headers": []
    }
  },
  "attributes": {
    "objectType": "PartnerUsageSummary"
  }
}

2. UsageSummaryByCustomer

Como llamar esta función:

userPartnerOperations.customer.byId('customer_id').azure.usageSummaryByCustomer();

Ejemplo de respuesta:

{
  "customerSpendingBudget": {
    "attributes": {
      "objectType": "SpendingBudget"
    }
  },
  "budget": {
    "attributes": {
      "objectType": "SpendingBudget"
    }
  },
  "resourceId": "b0631ce6-abcc-48b3-a607-20bd8e577c99",
  "id": "b0631ce6-abcc-48b3-a607-20bd8e577c99",
  "resourceName": "Preventa MS",
  "name": "Preventa MS",
  "billingStartDate": "2020-02-01T00:00:00+00:00",
  "billingEndDate": "2020-03-01T00:00:00+00:00",
  "totalCost": 4.55,
  "currencyCode": "USD",
  "usdTotalCost": 4.55,
  "lastModifiedDate": "2020-02-04T16:49:30.7033333+00:00",
  "links": {
    "self": {
      "uri": "/customers/b0631ce6-abcc-48b3-a607-20bd8e577c99/usagesummary",
      "method": "GET",
      "headers": []
    }
  },
  "attributes": {
    "objectType": "CustomerUsageSummary"
  }
}

3. UsageSummaryBySubscription

Como llamar esta función:

userPartnerOperations.customer.byId('customer_id').subscriptions.byId('subs_id').azure.usageSummaryById();

Ejemplo de respuesta:

{
  "resourceId": "42aebd04-b134-30a7-9c32-00705a5cc72e",
  "id": "42aebd04-b134-30a7-9c32-00705a5cc72e",
  "resourceName": "Azure plan",
  "name": "Azure plan",
  "billingStartDate": "2020-02-01T00:00:00+00:00",
  "billingEndDate": "2020-03-01T00:00:00+00:00",
  "totalCost": 4.55,
  "currencyCode": "USD",
  "usdTotalCost": 4.55,
  "lastModifiedDate": "2020-02-04T16:49:30.7033333+00:00",
  "links": {
    "self": {
      "uri": "/customers/b0631ce6-abcc-48b3-a607-20bd8e577c99/subscriptions/42aebd04-b134-30a7-9c32-00705a5cc72e/usagesummary",
      "method": "GET",
      "headers": []
    }
  },
  "attributes": {
    "objectType": "SubscriptionUsageSummary"
  }
}

4. GetCustomerUsageRecords

Como llamar esta función:

userPartnerOperations.customer.byId('customer_id').subscriptions.byId('subs_id').usage.records();

Ejemplo de respuesta:

{
  "totalCount": 3,
  "items": [
    {
      "category": "Storage",
      "subcategory": "General Block Blob",
      "quantityUsed": 0.761,
      "unit": "10K",
      "resourceId": "211E620C-EBCF-4DB5-A7FD-996ABEBE9546",
      "id": "211E620C-EBCF-4DB5-A7FD-996ABEBE9546",
      "resourceName": "Write Operations",
      "name": "Write Operations",
      "totalCost": 0.000233,
      "currencyLocale": "en-US",
      "lastModifiedDate": "2020-02-05T12:03:05.393+00:00",
      "attributes": {
        "objectType": "AzureResourceMonthlyUsageRecord"
      }
    },
    {
      "category": "Bandwidth",
      "subcategory": "",
      "quantityUsed": 0.41978,
      "unit": "1 GB",
      "resourceId": "32C3EBEC-1646-49E3-8127-2CAFBD3A04D8",
      "id": "32C3EBEC-1646-49E3-8127-2CAFBD3A04D8",
      "resourceName": "Data Transfer In",
      "name": "Data Transfer In",
      "totalCost": 0,
      "currencyLocale": "en-US",
      "lastModifiedDate": "2020-02-05T12:03:05.393+00:00",
      "attributes": {
        "objectType": "AzureResourceMonthlyUsageRecord"
      }
    },
    {
      "category": "Storage",
      "subcategory": "Tables",
      "quantityUsed": 0.001854,
      "unit": "1 GB/Month",
      "resourceId": "3F2B1E1C-C886-4EC6-AD6F-DD0EF38819C9",
      "id": "3F2B1E1C-C886-4EC6-AD6F-DD0EF38819C9",
      "resourceName": "LRS Data Stored",
      "name": "LRS Data Stored",
      "totalCost": 0.000071,
      "currencyLocale": "en-US",
      "lastModifiedDate": "2020-02-05T12:03:05.393+00:00",
      "attributes": {
        "objectType": "AzureResourceMonthlyUsageRecord"
      }
    }
  ],
  "links": {
    "self": {
      "uri": "/customers/fd442951-aef5-463c-8767-b21df61ee1f2/subscriptions/18441852-b6e0-4a18-b42f-57f808ac3e5e/usagerecords/resources",
      "method": "GET",
      "headers": []
    }
  },
  "attributes": {
    "objectType": "Collection"
  }
}

5. UsageRecordsAzure

Como llamar esta función:

userPartnerOperations.usage.usageRecords()

Ejemplo de respuesta:

{
  "totalCount": 3,
  "items": [
    {
      "budget": {
        "amount": 200,
        "usageSpendingBudget": 200,
        "attributes": {
          "objectType": "SpendingBudget"
        }
      },
      "customerSpendingBudget": {
        "amount": 200,
        "usageSpendingBudget": 200,
        "attributes": {
          "objectType": "SpendingBudget"
        }
      },
      "percentUsed": 28.66681,
      "isUpgraded": false,
      "resourceId": "91dc87b2-7c82-460d-90cb-c29fae973f17",
      "id": "91dc87b2-7c82-460d-90cb-c29fae973f17",
      "resourceName": "RAMIREZ VALLE MATRIZ SC",
      "name": "RAMIREZ VALLE MATRIZ SC",
      "totalCost": 57.33362,
      "currencyLocale": "en-US",
      "lastModifiedDate": "2020-02-05T12:03:05.393+00:00",
      "attributes": {
        "objectType": "CustomerMonthlyUsageRecord"
      }
    },
    {
      "budget": {
        "attributes": {
          "objectType": "SpendingBudget"
        }
      },
      "customerSpendingBudget": {
        "attributes": {
          "objectType": "SpendingBudget"
        }
      },
      "percentUsed": 0,
      "isUpgraded": false,
      "resourceId": "d1eb2226-a0da-4062-9f29-61be3cffd910",
      "id": "d1eb2226-a0da-4062-9f29-61be3cffd910",
      "resourceName": "Antar Global Services S A de C V",
      "name": "Antar Global Services S A de C V",
      "totalCost": 0.000288,
      "currencyLocale": "en-US",
      "lastModifiedDate": "2020-02-05T12:03:05.393+00:00",
      "attributes": {
        "objectType": "CustomerMonthlyUsageRecord"
      }
    },
    {
      "budget": {
        "amount": 1000,
        "usageSpendingBudget": 1000,
        "attributes": {
          "objectType": "SpendingBudget"
        }
      },
      "customerSpendingBudget": {
        "amount": 1000,
        "usageSpendingBudget": 1000,
        "attributes": {
          "objectType": "SpendingBudget"
        }
      },
      "percentUsed": 102.3889401,
      "isUpgraded": false,
      "resourceId": "cb27b3b8-2d09-4ab3-9804-d05fed519ceb",
      "id": "cb27b3b8-2d09-4ab3-9804-d05fed519ceb",
      "resourceName": "OCEAN NETWORK EXPRESS MEXICO",
      "name": "OCEAN NETWORK EXPRESS MEXICO",
      "totalCost": 1023.889401,
      "currencyLocale": "en-US",
      "lastModifiedDate": "2020-02-05T12:03:05.393+00:00",
      "attributes": {
        "objectType": "CustomerMonthlyUsageRecord"
      }
    }
  ],
  "links": {
    "self": {
      "uri": "/customers/usagerecords",
      "method": "GET",
      "headers": []
    }
  },
  "attributes": {
    "objectType": "Collection"
  }
}

6. GetUsageRecordsByCustomer.

Como llamar esta función:

userPartnerOperations.customer.byId('customer_id').usage.getUsageRecordsByCustomer();

Ejemplo de respuesta:

{
    "totalCount":3,
    "items":
    [
        {
            "status":"active",
            "partnerOnRecord":"4847274",
            "offerId":"MS-AZR-0145P",
            "resourceId":"346D8DC1-067A-4416-BC03-18F558623178",
            "id":"346D8DC1-067A-4416-BC03-18F558623178",
            "resourceName":"sierranorte",
            "name":"sierranorte",
            "totalCost":666.807481,
            "currencyLocale":"en-US",
            "lastModifiedDate":"2020-01-28T12:06:58.937+00:00",
            "attributes":{
                "objectType":"SubscriptionMonthlyUsageRecord"
            }
        },
        {
            "status":"active",
            "partnerOnRecord":"4847274",
            "offerId":"MS-AZR-0145P",
            "resourceId":"3FCC7AAD-45AA-45D9-BE1C-C8DEF0A97251",
            "id":"3FCC7AAD-45AA-45D9-BE1C-C8DEF0A97251",
            "resourceName":"promare",
            "name":"promare",
            "totalCost":512.546161,
            "currencyLocale":"en-US",
            "lastModifiedDate":"2020-01-28T12:06:58.937+00:00",
            "attributes":{
                "objectType":"SubscriptionMonthlyUsageRecord"
            }
        },
        {
            "status":"active",
            "partnerOnRecord":"4847274",
            "offerId":"MS-AZR-0145P",
            "resourceId":"E4917F1E-A809-4CE2-9A4F-E4980E98997F",
            "id":"E4917F1E-A809-4CE2-9A4F-E4980E98997F",
            "resourceName":"fultra",
            "name":"fultra",
            "totalCost":0.000000,
            "currencyLocale":"en-US",
            "lastModifiedDate":"2020-01-23T00:07:35.59+00:00",
            "attributes":{
                "objectType":"SubscriptionMonthlyUsageRecord"
            }
        }
    ],
    "links":{
        "self":{
            "uri":"/customers/f03d1b0e-7bde-48a4-a386-abbbf42d9a52/subscriptions/usagerecords/",
            "method":"GET",
            "headers":[]
        }
    },
    "attributes":{
        "objectType":"Collection"
    }
}

7. GetMeterUsageRecordsBySubs

Como llamar esta función:

userPartnerOperations.customer.byId(customerId).subscriptions.byId(subscriptionId).usage.getMeterUsageRecordsBySubs();

Ejemplo de respuesta:

{
  "totalCount": 3,
  "items": [
    {
      "meterId": "0D239466-777A-4271-B703-5F9AE34743AA",
      "meterName": "E8 v3/E8s v3",
      "category": "Virtual Machines",
      "subcategory": "Ev3/ESv3 Series Windows",
      "quantityUsed": 304,
      "unit": "1 Hour",
      "resourceId": "0D239466-777A-4271-B703-5F9AE34743AA",
      "resourceName": "E8 v3/E8s v3",
      "totalCost": 251.1648,
      "currencyLocale": "en-US",
      "lastModifiedDate": "2020-01-28T12:06:58.937+00:00",
      "attributes": {
        "objectType": "MeterUsageRecord"
      }
    },
    {
      "meterId": "10BFCC7B-397C-4216-AF83-8708FC2DFA1F",
      "meterName": "S15 Disks",
      "category": "Storage",
      "subcategory": "Standard HDD Managed Disks",
      "quantityUsed": 0.608832,
      "unit": "1/Month",
      "resourceId": "10BFCC7B-397C-4216-AF83-8708FC2DFA1F",
      "resourceName": "S15 Disks",
      "totalCost": 5.862322,
      "currencyLocale": "en-US",
      "lastModifiedDate": "2020-01-28T12:06:58.937+00:00",
      "attributes": {
        "objectType": "MeterUsageRecord"
      }
    },
    {
      "meterId": "211E620C-EBCF-4DB5-A7FD-996ABEBE9546",
      "meterName": "Write Operations",
      "category": "Storage",
      "subcategory": "General Block Blob",
      "quantityUsed": 3.6239,
      "unit": "10K",
      "resourceId": "211E620C-EBCF-4DB5-A7FD-996ABEBE9546",
      "resourceName": "Write Operations",
      "totalCost": 0.001109,
      "currencyLocale": "en-US",
      "lastModifiedDate": "2020-01-28T12:06:58.937+00:00",
      "attributes": {
        "objectType": "MeterUsageRecord"
      }
    },
  ],
  "links": {
    "self": {
      "uri": "/customers/f03d1b0e-7bde-48a4-a386-abbbf42d9a52/subscriptions/346D8DC1-067A-4416-BC03-18F558623178//meterusagerecords",
      "method": "GET",
      "headers": []
    }
  },
  "attributes": {
    "objectType": "Collection"
  }
}

8. GetResourceUsageRecordsBySubs

Como llamar esta función:

userPartnerOperations.customer.byId(customerId).subscriptions.byId(subscriptionId).usage.getResourceUsageRecordsBySubs()

Ejemplo de respuesta:

{
  "totalCount": 3,
  "items": [
    {
      "subscriptionId": "42aebd04-b134-30a7-9c32-00705a5cc72e",
      "resourceUri": "/subscriptions/ade3dc7a-74bd-46b7-8951-1b8d9aa47a43/resourceGroups/EM_CloudBank/providers/Microsoft.Storage/storageAccounts/cloudbankcs",
      "resourceType": "Microsoft.Storage",
      "entitlementId": "ade3dc7a-74bd-46b7-8951-1b8d9aa47a43",
      "entitlementName": "Microsoft Azure",
      "resourceGroupName": "EM_CloudBank",
      "name": "cloudbankcs",
      "resourceName": "cloudbankcs",
      "totalCost": 0.04,
      "currencyCode": "USD",
      "usdTotalCost": 0.04,
      "lastModifiedDate": "2020-02-05T00:54:07.1166667+00:00",
      "attributes": {
        "objectType": "ResourceUsageRecord"
      }
    },
    {
      "subscriptionId": "42aebd04-b134-30a7-9c32-00705a5cc72e",
      "resourceUri": "/subscriptions/ade3dc7a-74bd-46b7-8951-1b8d9aa47a43/resourceGroups/emoralescs/providers/Microsoft.Automation/automationAccounts/StrtStp-atm",
      "resourceType": "Microsoft.Automation",
      "entitlementId": "ade3dc7a-74bd-46b7-8951-1b8d9aa47a43",
      "entitlementName": "Microsoft Azure",
      "resourceGroupName": "emoralescs",
      "name": "StrtStp-atm",
      "resourceName": "StrtStp-atm",
      "totalCost": 0,
      "currencyCode": "USD",
      "usdTotalCost": 0,
      "lastModifiedDate": "2020-02-05T00:54:07.1166667+00:00",
      "attributes": {
        "objectType": "ResourceUsageRecord"
      }
    },
    {
      "subscriptionId": "42aebd04-b134-30a7-9c32-00705a5cc72e",
      "resourceUri": "/subscriptions/ade3dc7a-74bd-46b7-8951-1b8d9aa47a43/resourceGroups/EMORALESCS/providers/Microsoft.Compute/disks/WS16-vm1_DataDisk_0",
      "resourceType": "Microsoft.Compute",
      "entitlementId": "ade3dc7a-74bd-46b7-8951-1b8d9aa47a43",
      "entitlementName": "Microsoft Azure",
      "resourceGroupName": "EMORALESCS",
      "name": "WS16-vm1_DataDisk_0",
      "resourceName": "WS16-vm1_DataDisk_0",
      "totalCost": 0.58,
      "currencyCode": "USD",
      "usdTotalCost": 0.58,
      "lastModifiedDate": "2020-02-05T00:54:07.1166667+00:00",
      "attributes": {
        "objectType": "ResourceUsageRecord"
      }
    }
  ],
  "links": {
    "self": {
      "uri": "/customers/b0631ce6-abcc-48b3-a607-20bd8e577c99/subscriptions/42aebd04-b134-30a7-9c32-00705a5cc72e/resourceusagerecords",
      "method": "GET",
      "headers": []
    }
  },
  "attributes": {
    "objectType": "Collection"
  }
}

Products

1. Get a list of products (by country)

Parámetros: | Name | Type | Required | Description | |------------|--------|----------|----------------------------------------------------------------------| | country | string | Yes | The country/region ID. | | targetView | string | Yes | Identifies the target view of the catalog. The supported values are: | | | | | AzureReservations which includes all Azure reservation items. | | | | | AzureReservationsVM which includes all virtual machine (VM) | | | | | reservation items. | | | | | AzureReservationsSQL which includes all SQL reservation items | | | | | AzureReservationsCosmosDb which includes all Cosmos database | | | | | reservation items. | | | | | MicrosoftAzure which includes items for Microsoft Azure | | | | | subscriptions (MS-AZR-0145P) and Azure plans. | | | | | OnlineServices which includes all online service items (including| | | | | commercial marketplace products). | | | | | Software which includes all software items. | | | | | SoftwareSUSELinux which includes all software SUSE Linux items. | | | | | SoftwarePerpetual which includes all perpetual software items. | | | | | SoftwareSubscriptions which includes all software subscription. | | | | | items. | Cómo llamar a esta función.

userPartnerOperations.products.byCountryCode('MX').byTargetView('targetView').get();

Ejemplo de respuesta:

{
    "totalCount": 19,
    "items": [
        {
            "id": "DZH318Z0BQ3Q",
            "title": "Virtual Machines DSv2 Series",
            "description": "Dsv2-series instances are the latest generation of D-series instances that will carry more powerful CPUs which are on average about 35% faster than D-series instances, and carry the same memory and disk configurations as the D-series. Dsv2-series instances are based on the latest generation 2.4 GHz Intel Xeon® E5-2673 v3 (Haswell) processor, and with Intel Turbo Boost Technology 2.0 can go to 3.2 GHz.",
            "productType": {
                "id": "Azure",
                "displayName": "Azure",
                "subType": {
                "id": "VirtualMachines",
                "displayName": "VirtualMachines"
                }
            },
            "isMicrosoftProduct": true,
            "publisherName": "Microsoft",
            "links": {
                "skus": {
                    "uri": "/products/DZH318Z0BQ3Q/skus?country=US",
                    "method": "GET",
                    "headers": []
                },
                "self": {
                    "uri": "/products/DZH318Z0BQ3Q?country=US",
                    "method": "GET",
                    "headers": []
                }
            }
        },
        ...
    ],
    "links": {
        "self": {
            "uri": "/products?country=US&targetView=Azure",
            "method": "GET",
            "headers": []
        }
    },
    "attributes": {
        "objectType": "Collection"
    }
}

Upgrade Azure.

Como llamar esta función:

const body = {
  "customerId":"101ab4f6-d96c-4902-866a-4fd31d89a181",
  "productFamily":"azure",
};

userPartnerOperations.products.productUpgrade(body);

Ejemplo de respuesta:

{
   "debugId":2,
   "headers":{
      "content-length":"0",
      "location":"productUpgrades/5324c00d-67ff-477e-aff5-86484bf20deb/status",
      "ms-correlationid":"606bbe34-b9f1-4709-bf17-59b42c7c6ea4",
      "ms-requestid":"bcd618c2-c77e-4172-8728-3175a70ca7ff",
      "x-locale":"en-US",
      "request-context":"appId=cid-v1:03ce8ca8-8373-4021-8f25-d5dd45c7b12f",
      "date":"Thu, 19 Mar 2020 20:57:56 GMT",
      "connection":"close"
   },
   "statusCode":202
}

Elegibilidad de un producto.

Como llamar esta función:

const body = {
  "customerId":"101ab4f6-d96c-4902-866a-4fd31d89a181",
  "productFamily":"azure",
};

userPartnerOperations.products.productUpgradeEligibility(body);

Ejemplo de respuesta:

{
   "debugId":2,
   "headers":{
      "content-length":"98",
      "content-type":"application/json; charset=utf-8",
      "ms-correlationid":"02408040-a9ef-4f49-a201-e2b9ea805bc7",
      "ms-requestid":"29095590-e702-441b-8add-ed19fe40c012",
      "x-locale":"en-US",
      "request-context":"appId=cid-v1:03ce8ca8-8373-4021-8f25-d5dd45c7b12f",
      "date":"Thu, 19 Mar 2020 22:01:00 GMT",
      "connection":"close"
   },
   "statusCode":200,
    "body":
    {
        "customerId":"8baf0911-69cd-4f7c-b899-cbf9f2f49ac9",
        "isEligible":true,
        "productFamily":"azure"
    }
}

Estatus de un upgrade.

Para poder correr esta ruta, se debió guardar el dato 'location' de la respuesta de la ruta productUpgrade, el cual tiene el id del upgrade solicitado.

{
   "debugId":2,
   "headers":{
      "content-length":"0",

      `"location":"productUpgrades/5324c00d-67ff-477e-aff5-86484bf20deb/status",`

      "ms-correlationid":"606bbe34-b9f1-4709-bf17-59b42c7c6ea4",
      "ms-requestid":"bcd618c2-c77e-4172-8728-3175a70ca7ff",
      "x-locale":"en-US",
      "request-context":"appId=cid-v1:03ce8ca8-8373-4021-8f25-d5dd45c7b12f",
      "date":"Thu, 19 Mar 2020 20:57:56 GMT",
      "connection":"close"
   },
   "statusCode":202
}

Como llamar esta función:

const body = {
  "customerId":"101ab4f6-d96c-4902-866a-4fd31d89a181",
  "productFamily":"azure",
};

const upgradeId = '5324c00d-67ff-477e-aff5-86484bf20deb';

userPartnerOperations.products.productUpgradeStatus(body, upgradeId);

Ejemplo de respuesta:

{
   "debugId":2,
   "headers":{
      "content-length":"355",
      "content-type":"application/json; charset=utf-8",
      "ms-correlationid":"08227cf0-34d6-49c2-ad4a-a276139ffee7",
      "ms-requestid":"49b1eb3a-4d71-4e9e-a656-eb7b39a6a7ee",
      "x-locale":"en-US",
      "request-context":"appId=cid-v1:03ce8ca8-8373-4021-8f25-d5dd45c7b12f",
      "date":"Thu, 19 Mar 2020 21:22:18 GMT",
      "connection":"close"
   },
   "statusCode":200,
    body:"
    {
    "id":"5324c00d-67ff-477e-aff5-86484bf20deb",
    "status":"Completed",
    "productFamily":"Azure",
    "lineItems":[
        {
            "sourceProduct":{
                "id":"F7576574-52BD-4B2A-A2ED-139A7B87F8F1",
                "name":"Microsoft Azure"
            },
            "targetProduct":{
                "id":"8e363daa-172f-5aed-f7ff-968a8f09f82d",
                "name":"Microsoft Azure Plan"
            },
            "upgradedDate":"2020-03-19T21:05:48.4704556Z",
            "status":"Completed"
        }
    ]
    }"
}

Budget

1. Update customer usage spending budget.

Como llamar esta función:

const budget = {
  "Amount": 1000,
  "Attributes": {
       "ObjectType": "SpendingBudget"
  }
};
userPartnerOperations.customer.byId('customerId').budget.update(budget);

Ejemplo de respuesta:

{
    {
        "amount": 100,
        "usageSpendingBudget": 100,
        "attributes":{
            "objectType":"SpendingBudget"
        }
    },
    "links":{
        "self":{
            "uri":"/v1/customers/<customer-tenant-id>/usagebudget",
            "method":"PATCH",
            "headers":[]
        }
    }
}

2. Get a customer´s usage spending budget.

Como llamar esta función:

userPartnerOperations.customer.byId('customerId').budget.get();

Ejemplo de respuesta:

{
    {
        "amount": 100,
        "usageSpendingBudget": 100,
        "attributes":{
            "objectType":"SpendingBudget"
        }
    }
}

Invoices

Obtener todos los invoices

Como llamar esta función:

userPartnerOperations.invoices.get();

Ejemplo de respuesta:

{
    "totalCount": 2,
    "items": [
        {
            "id": "D02005YFHI",
            "invoiceDate": "2017-01-21T00:00:00Z",
            "totalCharges": 24606.35,
            "paidAmount": 1000,
            "currencyCode": "GBP",
            "currencySymbol": "£",
            "pdfDownloadLink": "/invoices/D02005YFHI/documents/statement",
            "taxReceipts": [
                {
                    "id": "123456",
                    "taxReceiptPdfDownloadLink": "/invoices/D02005YFHI/receipts/123456/documents/statement"
                }
            ],
            "invoiceDetails": [
                {
                    "invoiceLineItemType": "billing_line_items",
                    "billingProvider": "office",
                    "links": {
                        "self": {
                            "uri": "/invoices/Recurring-D02005YFHI/lineitems/Office/BillingLineItems",
                            "method": "GET",
                            "headers": []
                        }
                    },
                    "attributes": {
                        "objectType": "InvoiceDetail"
                    }
                }
            ],
            "documentType": "invoice",
            "invoiceType": "Recurring",
            "links": {
                "self": {
                    "uri": "/invoices/Recurring-D02005YFHI",
                    "method": "GET",
                    "headers": []
                }
            },
            "attributes": {
                "objectType": "Invoice"
            }
        },
        {
            "id": "G000024130",
            "invoiceDate": "2018-02-08T01:22:47.603895Z",
            "totalCharges": 586366,
            "paidAmount": 0,
            "currencyCode": "CHF",
            "currencySymbol": "CHF",
            "pdfDownloadLink": "/invoices/G000024130/documents/statement",
            "taxReceipts": [
                {
                    "id": "234567",
                    "taxReceiptPdfDownloadLink": "/invoices/G000024130/receipts/234567/documents/statement"
                }
            ],
            "invoiceDetails": [
                {
                    "invoiceLineItemType": "billing_line_items",
                    "billingProvider": "one_time",
                    "links": {
                        "self": {
                            "uri": "/invoices/OneTime-G000024130/lineitems/OneTime/BillingLineItems",
                            "method": "GET",
                            "headers": []
                        }
                    },
                    "attributes": {
                        "objectType": "InvoiceDetail"
                    }
                }
            ],
            "amendments": [
                {
                    "id": "G000024131",
                    "invoiceDate": "2018-02-08T18:44:37.5381456Z",
                    "totalCharges": 107661.12,
                    "paidAmount": 0,
                    "currencyCode": "CHF",
                    "currencySymbol": "CHF",
                    "invoiceDetails": [
                        {
                            "invoiceLineItemType": "billing_line_items",
                            "billingProvider": "one_time",
                            "attributes": {
                                "objectType": "InvoiceDetail"
                            }
                        }
                    ],
                    "documentType": "adjustment_note",
                    "amendsOf": "G000024130",
                    "invoiceType": "OneTime",
                    "attributes": {
                        "objectType": "Invoice"
                    }
                }
            ],
            "documentType": "void_note",
            "invoiceType": "OneTime",
            "links": {
                "self": {
                    "uri": "/invoices/OneTime-G000024130",
                    "method": "GET",
                    "headers": []
                }
            },
            "attributes": {
                "objectType": "Invoice"
            }
        }
    ],
    "links": {
        "self": {
            "uri": "/invoices?size=2&offset=0",
            "method": "GET",
            "headers": []
        },
        "next": {
            "uri": "/invoices?size=2&offset=2",
            "method": "GET",
            "headers": []
        }
    },
    "attributes": {
        "objectType": "Collection"
    }
}

Obtener los invoices por size u offset o ambos.

Como llamar estas funciones:

* Por offset:
userPartnerOperations.invoices.byOffset('0').get();
* Por size:
userPartnerOperations.invoices.bysSize('1').get();
* Por ambas:
userPartnerOperations.invoices.bySize('1').byOffset('0').get();

Ejemplo de respuesta, identico al punto anterior.