From c2d7cf66d0ca276a0998408ae00807356e241822 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Fri, 6 Apr 2018 14:50:18 -0700 Subject: [PATCH 1/5] [AutoPR consumption/resource-manager] Added schema spec for cost allocation tags (#2536) * Generated from a8d47d1078b0a4071a209a7fe2ff43eec4461243 Merge remote-tracking branch 'upstream/master' * Generated from 3ccf1b464815326349f015f17a600df4ab5e35ab Updated Get Operation Updated Get Operation * Generated from 884aabe8882d794b987236ad2b0927a98317d28f Incorporated review comments Incorporated review comments * Generated from 3d1c7c16a7266814f1e4bd997169df1ebd1d2bce Review comments incorporated Review comments incorporated * Generated from def63250017ef0071aadd68a751623913f788af3 Updated path Updated path * Generated from def63250017ef0071aadd68a751623913f788af3 Updated path Updated path --- .../consumptionManagement/lib/LICENSE.txt | 21 + .../lib/consumptionManagementClient.d.ts | 7 +- .../lib/consumptionManagementClient.js | 7 +- .../lib/lib/consumptionManagementClient.d.ts | 70 + .../lib/lib/consumptionManagementClient.js | 93 + .../lib/lib/models/budget.js | 171 ++ .../lib/lib/models/budgetTimePeriod.js | 61 + .../lib/lib/models/budgetsListResult.js | 70 + .../lib/lib/models/costAllocationTag.js | 52 + .../lib/lib/models/costAllocationTags.js | 95 + .../lib/lib/models/currentSpend.js | 63 + .../lib/lib/models/errorDetails.js | 63 + .../lib/lib/models/errorResponse.js | 59 + .../lib/lib/models/filters.js | 125 + .../lib/lib/models/index.d.ts | 745 +++++ .../lib/lib/models/index.js | 50 + .../lib/lib/models/marketplace.js | 311 ++ .../lib/lib/models/marketplacesListResult.js | 70 + .../lib/lib/models/meterDetails.js | 113 + .../lib/lib/models/notification.js | 127 + .../lib/lib/models/operation.js | 70 + .../lib/lib/models/operationDisplay.js | 72 + .../lib/lib/models/operationListResult.js | 71 + .../lib/lib/models/priceSheetProperties.js | 135 + .../lib/lib/models/priceSheetResult.js | 113 + .../lib/lib/models/proxyResource.js | 85 + .../lib/lib/models/queryOptions.js | 52 + .../lib/lib/models/reservationDetails.js | 171 ++ .../models/reservationDetailsListResult.js | 69 + .../lib/models/reservationRecommendations.js | 191 ++ .../reservationRecommendationsListResult.js | 69 + .../lib/lib/models/reservationSummaries.js | 186 ++ .../models/reservationSummariesListResult.js | 69 + .../lib/lib/models/resource.js | 91 + .../lib/lib/models/resourceAttributes.js | 62 + .../lib/lib/models/usageDetail.js | 311 ++ .../lib/lib/models/usageDetailsListResult.js | 70 + .../lib/lib/operations/budgets.js | 2571 +++++++++++++++++ .../costAllocationTagsOperations.js | 537 ++++ .../lib/lib/operations/index.d.ts | 2492 ++++++++++++++++ .../lib/lib/operations/index.js | 25 + .../lib/lib/operations/marketplaces.js | 1057 +++++++ .../lib/lib/operations/operations.js | 451 +++ .../lib/lib/operations/priceSheet.js | 605 ++++ .../reservationRecommendationsOperations.js | 478 +++ .../lib/lib/operations/reservationsDetails.js | 943 ++++++ .../lib/operations/reservationsSummaries.js | 975 +++++++ .../lib/lib/operations/usageDetails.js | 1175 ++++++++ .../lib/models/budget.js | 5 +- .../lib/models/costAllocationTag.js | 52 + .../lib/models/costAllocationTags.js | 95 + .../lib/models/filters.js | 28 +- .../lib/models/index.d.ts | 128 +- .../consumptionManagement/lib/models/index.js | 6 + .../lib/models/marketplace.js | 4 +- .../lib/models/priceSheetProperties.js | 2 +- .../lib/models/queryOptions.js | 52 + .../lib/models/reservationRecommendations.js | 191 ++ .../reservationRecommendationsListResult.js | 69 + .../lib/models/resourceAttributes.js | 62 + .../lib/models/usageDetail.js | 4 +- .../lib/operations/budgets.js | 36 +- .../costAllocationTagsOperations.js | 537 ++++ .../lib/operations/index.d.ts | 374 ++- .../lib/operations/index.js | 2 + .../lib/operations/priceSheet.js | 52 + .../reservationRecommendationsOperations.js | 478 +++ .../lib/operations/usageDetails.js | 98 +- .../consumptionManagement/lib/package.json | 22 + 69 files changed, 17793 insertions(+), 73 deletions(-) create mode 100644 lib/services/consumptionManagement/lib/LICENSE.txt create mode 100644 lib/services/consumptionManagement/lib/lib/consumptionManagementClient.d.ts create mode 100644 lib/services/consumptionManagement/lib/lib/consumptionManagementClient.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/budget.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/budgetTimePeriod.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/budgetsListResult.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/costAllocationTag.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/costAllocationTags.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/currentSpend.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/errorDetails.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/errorResponse.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/filters.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/index.d.ts create mode 100644 lib/services/consumptionManagement/lib/lib/models/index.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/marketplace.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/marketplacesListResult.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/meterDetails.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/notification.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/operation.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/operationDisplay.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/operationListResult.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/priceSheetProperties.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/priceSheetResult.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/proxyResource.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/queryOptions.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/reservationDetails.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/reservationDetailsListResult.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/reservationRecommendations.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/reservationRecommendationsListResult.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/reservationSummaries.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/reservationSummariesListResult.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/resource.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/resourceAttributes.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/usageDetail.js create mode 100644 lib/services/consumptionManagement/lib/lib/models/usageDetailsListResult.js create mode 100644 lib/services/consumptionManagement/lib/lib/operations/budgets.js create mode 100644 lib/services/consumptionManagement/lib/lib/operations/costAllocationTagsOperations.js create mode 100644 lib/services/consumptionManagement/lib/lib/operations/index.d.ts create mode 100644 lib/services/consumptionManagement/lib/lib/operations/index.js create mode 100644 lib/services/consumptionManagement/lib/lib/operations/marketplaces.js create mode 100644 lib/services/consumptionManagement/lib/lib/operations/operations.js create mode 100644 lib/services/consumptionManagement/lib/lib/operations/priceSheet.js create mode 100644 lib/services/consumptionManagement/lib/lib/operations/reservationRecommendationsOperations.js create mode 100644 lib/services/consumptionManagement/lib/lib/operations/reservationsDetails.js create mode 100644 lib/services/consumptionManagement/lib/lib/operations/reservationsSummaries.js create mode 100644 lib/services/consumptionManagement/lib/lib/operations/usageDetails.js create mode 100644 lib/services/consumptionManagement/lib/models/costAllocationTag.js create mode 100644 lib/services/consumptionManagement/lib/models/costAllocationTags.js create mode 100644 lib/services/consumptionManagement/lib/models/queryOptions.js create mode 100644 lib/services/consumptionManagement/lib/models/reservationRecommendations.js create mode 100644 lib/services/consumptionManagement/lib/models/reservationRecommendationsListResult.js create mode 100644 lib/services/consumptionManagement/lib/models/resourceAttributes.js create mode 100644 lib/services/consumptionManagement/lib/operations/costAllocationTagsOperations.js create mode 100644 lib/services/consumptionManagement/lib/operations/reservationRecommendationsOperations.js create mode 100644 lib/services/consumptionManagement/lib/package.json diff --git a/lib/services/consumptionManagement/lib/LICENSE.txt b/lib/services/consumptionManagement/lib/LICENSE.txt new file mode 100644 index 0000000000..5431ba98b9 --- /dev/null +++ b/lib/services/consumptionManagement/lib/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2018 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/lib/services/consumptionManagement/lib/consumptionManagementClient.d.ts b/lib/services/consumptionManagement/lib/consumptionManagementClient.d.ts index dae38ddded..507a6fc1b0 100644 --- a/lib/services/consumptionManagement/lib/consumptionManagementClient.d.ts +++ b/lib/services/consumptionManagement/lib/consumptionManagementClient.d.ts @@ -10,9 +10,10 @@ import { ServiceClientCredentials } from 'ms-rest'; import { AzureServiceClient, AzureServiceClientOptions } from 'ms-rest-azure'; +import * as models from "./models"; import * as operations from "./operations"; -declare class ConsumptionManagementClient extends AzureServiceClient { +export default class ConsumptionManagementClient extends AzureServiceClient { /** * Initializes a new instance of the ConsumptionManagementClient class. * @constructor @@ -59,9 +60,11 @@ declare class ConsumptionManagementClient extends AzureServiceClient { marketplaces: operations.Marketplaces; reservationsSummaries: operations.ReservationsSummaries; reservationsDetails: operations.ReservationsDetails; + reservationRecommendationsOperations: operations.ReservationRecommendationsOperations; budgets: operations.Budgets; operations: operations.Operations; priceSheet: operations.PriceSheet; + costAllocationTagsOperations: operations.CostAllocationTagsOperations; } -export = ConsumptionManagementClient; +export { ConsumptionManagementClient, models as ConsumptionManagementModels }; diff --git a/lib/services/consumptionManagement/lib/consumptionManagementClient.js b/lib/services/consumptionManagement/lib/consumptionManagementClient.js index 2c736d5d5a..7174ea58fc 100644 --- a/lib/services/consumptionManagement/lib/consumptionManagementClient.js +++ b/lib/services/consumptionManagement/lib/consumptionManagementClient.js @@ -50,7 +50,7 @@ class ConsumptionManagementClient extends ServiceClient { super(credentials, options); - this.apiVersion = '2018-01-31'; + this.apiVersion = '2018-03-31'; this.acceptLanguage = 'en-US'; this.longRunningOperationRetryTimeout = 30; this.generateClientRequestId = true; @@ -76,9 +76,11 @@ class ConsumptionManagementClient extends ServiceClient { this.marketplaces = new operations.Marketplaces(this); this.reservationsSummaries = new operations.ReservationsSummaries(this); this.reservationsDetails = new operations.ReservationsDetails(this); + this.reservationRecommendationsOperations = new operations.ReservationRecommendationsOperations(this); this.budgets = new operations.Budgets(this); this.operations = new operations.Operations(this); this.priceSheet = new operations.PriceSheet(this); + this.costAllocationTagsOperations = new operations.CostAllocationTagsOperations(this); this.models = models; msRest.addSerializationMixin(this); } @@ -86,3 +88,6 @@ class ConsumptionManagementClient extends ServiceClient { } module.exports = ConsumptionManagementClient; +module.exports['default'] = ConsumptionManagementClient; +module.exports.ConsumptionManagementClient = ConsumptionManagementClient; +module.exports.ConsumptionManagementModels = models; diff --git a/lib/services/consumptionManagement/lib/lib/consumptionManagementClient.d.ts b/lib/services/consumptionManagement/lib/lib/consumptionManagementClient.d.ts new file mode 100644 index 0000000000..507a6fc1b0 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/consumptionManagementClient.d.ts @@ -0,0 +1,70 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import { ServiceClientCredentials } from 'ms-rest'; +import { AzureServiceClient, AzureServiceClientOptions } from 'ms-rest-azure'; +import * as models from "./models"; +import * as operations from "./operations"; + +export default class ConsumptionManagementClient extends AzureServiceClient { + /** + * Initializes a new instance of the ConsumptionManagementClient class. + * @constructor + * + * @class + * @param {credentials} credentials - Credentials needed for the client to connect to Azure. + * + * @param {string} subscriptionId - Azure Subscription ID. + * + * @param {string} [baseUri] - The base URI of the service. + * + * @param {object} [options] - The parameter options + * + * @param {Array} [options.filters] - Filters to be added to the request pipeline + * + * @param {object} [options.requestOptions] - Options for the underlying request object + * {@link https://github.com/request/request#requestoptions-callback Options doc} + * + * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy + * + * @param {string} [options.acceptLanguage] - Gets or sets the preferred language for the response. + * + * @param {number} [options.longRunningOperationRetryTimeout] - Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @param {boolean} [options.generateClientRequestId] - When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + */ + constructor(credentials: ServiceClientCredentials, subscriptionId: string, baseUri?: string, options?: AzureServiceClientOptions); + + credentials: ServiceClientCredentials; + + apiVersion: string; + + subscriptionId: string; + + acceptLanguage: string; + + longRunningOperationRetryTimeout: number; + + generateClientRequestId: boolean; + + // Operation groups + usageDetails: operations.UsageDetails; + marketplaces: operations.Marketplaces; + reservationsSummaries: operations.ReservationsSummaries; + reservationsDetails: operations.ReservationsDetails; + reservationRecommendationsOperations: operations.ReservationRecommendationsOperations; + budgets: operations.Budgets; + operations: operations.Operations; + priceSheet: operations.PriceSheet; + costAllocationTagsOperations: operations.CostAllocationTagsOperations; +} + +export { ConsumptionManagementClient, models as ConsumptionManagementModels }; diff --git a/lib/services/consumptionManagement/lib/lib/consumptionManagementClient.js b/lib/services/consumptionManagement/lib/lib/consumptionManagementClient.js new file mode 100644 index 0000000000..7174ea58fc --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/consumptionManagementClient.js @@ -0,0 +1,93 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const ServiceClient = msRestAzure.AzureServiceClient; + +const models = require('./models'); +const operations = require('./operations'); + + +/** Class representing a ConsumptionManagementClient. */ +class ConsumptionManagementClient extends ServiceClient { + /** + * Create a ConsumptionManagementClient. + * @param {credentials} credentials - Credentials needed for the client to connect to Azure. + * @param {string} subscriptionId - Azure Subscription ID. + * @param {string} [baseUri] - The base URI of the service. + * @param {object} [options] - The parameter options + * @param {Array} [options.filters] - Filters to be added to the request pipeline + * @param {object} [options.requestOptions] - Options for the underlying request object + * {@link https://github.com/request/request#requestoptions-callback Options doc} + * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy + * @param {string} [options.acceptLanguage] - Gets or sets the preferred language for the response. + * @param {number} [options.longRunningOperationRetryTimeout] - Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * @param {boolean} [options.generateClientRequestId] - When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + */ + constructor(credentials, subscriptionId, baseUri, options) { + if (credentials === null || credentials === undefined) { + throw new Error('\'credentials\' cannot be null.'); + } + if (subscriptionId === null || subscriptionId === undefined) { + throw new Error('\'subscriptionId\' cannot be null.'); + } + + if (!options) options = {}; + + super(credentials, options); + + this.apiVersion = '2018-03-31'; + this.acceptLanguage = 'en-US'; + this.longRunningOperationRetryTimeout = 30; + this.generateClientRequestId = true; + this.baseUri = baseUri; + if (!this.baseUri) { + this.baseUri = 'https://management.azure.com'; + } + this.credentials = credentials; + this.subscriptionId = subscriptionId; + + let packageInfo = this.getPackageJsonInfo(__dirname); + this.addUserAgentInfo(`${packageInfo.name}/${packageInfo.version}`); + if(options.acceptLanguage !== null && options.acceptLanguage !== undefined) { + this.acceptLanguage = options.acceptLanguage; + } + if(options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) { + this.longRunningOperationRetryTimeout = options.longRunningOperationRetryTimeout; + } + if(options.generateClientRequestId !== null && options.generateClientRequestId !== undefined) { + this.generateClientRequestId = options.generateClientRequestId; + } + this.usageDetails = new operations.UsageDetails(this); + this.marketplaces = new operations.Marketplaces(this); + this.reservationsSummaries = new operations.ReservationsSummaries(this); + this.reservationsDetails = new operations.ReservationsDetails(this); + this.reservationRecommendationsOperations = new operations.ReservationRecommendationsOperations(this); + this.budgets = new operations.Budgets(this); + this.operations = new operations.Operations(this); + this.priceSheet = new operations.PriceSheet(this); + this.costAllocationTagsOperations = new operations.CostAllocationTagsOperations(this); + this.models = models; + msRest.addSerializationMixin(this); + } + +} + +module.exports = ConsumptionManagementClient; +module.exports['default'] = ConsumptionManagementClient; +module.exports.ConsumptionManagementClient = ConsumptionManagementClient; +module.exports.ConsumptionManagementModels = models; diff --git a/lib/services/consumptionManagement/lib/lib/models/budget.js b/lib/services/consumptionManagement/lib/lib/models/budget.js new file mode 100644 index 0000000000..7d80ffe881 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/budget.js @@ -0,0 +1,171 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * A budget resource. + * + * @extends models['ProxyResource'] + */ +class Budget extends models['ProxyResource'] { + /** + * Create a Budget. + * @member {string} category The category of the budget, whether the budget + * tracks cost or usage. Possible values include: 'Cost', 'Usage' + * @member {number} amount The total amount of cost to track with the budget + * @member {string} timeGrain The time covered by a budget. Tracking of the + * amount will be reset based on the time grain. Possible values include: + * 'Monthly', 'Quarterly', 'Annually' + * @member {object} timePeriod Has start and end date of the budget. The + * start date must be first of the month and should be less than the end + * date. Budget start date must be on or after June 1, 2017. Future start + * date should not be more than three months. Past start date should be + * selected within the timegrain preiod. There are no restrictions on the end + * date. + * @member {date} [timePeriod.startDate] The start date for the budget. + * @member {date} [timePeriod.endDate] The end date for the budget. If not + * provided, we default this to 10 years from the start date. + * @member {object} [filters] May be used to filter budgets by resource + * group, resource, or meter. + * @member {array} [filters.resourceGroups] The list of filters on resource + * groups, allowed at subscription level only. + * @member {array} [filters.resources] The list of filters on resources. + * @member {array} [filters.meters] The list of filters on meters (GUID), + * mandatory for budgets of usage category. + * @member {object} [filters.tags] The dictionary of filters on tags. + * @member {object} [currentSpend] The current amount of cost which is being + * tracked for a budget. + * @member {number} [currentSpend.amount] The total amount of cost which is + * being tracked by the budget. + * @member {string} [currentSpend.unit] The unit of measure for the budget + * amount. + * @member {object} [notifications] Dictionary of notifications associated + * with the budget. Budget can have up to five notifications. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Budget + * + * @returns {object} metadata of Budget + * + */ + mapper() { + return { + required: false, + serializedName: 'Budget', + type: { + name: 'Composite', + className: 'Budget', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + eTag: { + required: false, + serializedName: 'eTag', + type: { + name: 'String' + } + }, + category: { + required: true, + serializedName: 'properties.category', + type: { + name: 'String' + } + }, + amount: { + required: true, + serializedName: 'properties.amount', + type: { + name: 'Number' + } + }, + timeGrain: { + required: true, + serializedName: 'properties.timeGrain', + type: { + name: 'String' + } + }, + timePeriod: { + required: true, + serializedName: 'properties.timePeriod', + type: { + name: 'Composite', + className: 'BudgetTimePeriod' + } + }, + filters: { + required: false, + serializedName: 'properties.filters', + type: { + name: 'Composite', + className: 'Filters' + } + }, + currentSpend: { + required: false, + readOnly: true, + serializedName: 'properties.currentSpend', + type: { + name: 'Composite', + className: 'CurrentSpend' + } + }, + notifications: { + required: false, + serializedName: 'properties.notifications', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'NotificationElementType', + type: { + name: 'Composite', + className: 'Notification' + } + } + } + } + } + } + }; + } +} + +module.exports = Budget; diff --git a/lib/services/consumptionManagement/lib/lib/models/budgetTimePeriod.js b/lib/services/consumptionManagement/lib/lib/models/budgetTimePeriod.js new file mode 100644 index 0000000000..d360fa152a --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/budgetTimePeriod.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The start and end date for a budget. + * + */ +class BudgetTimePeriod { + /** + * Create a BudgetTimePeriod. + * @member {date} startDate The start date for the budget. + * @member {date} [endDate] The end date for the budget. If not provided, we + * default this to 10 years from the start date. + */ + constructor() { + } + + /** + * Defines the metadata of BudgetTimePeriod + * + * @returns {object} metadata of BudgetTimePeriod + * + */ + mapper() { + return { + required: false, + serializedName: 'BudgetTimePeriod', + type: { + name: 'Composite', + className: 'BudgetTimePeriod', + modelProperties: { + startDate: { + required: true, + serializedName: 'startDate', + type: { + name: 'DateTime' + } + }, + endDate: { + required: false, + serializedName: 'endDate', + type: { + name: 'DateTime' + } + } + } + } + }; + } +} + +module.exports = BudgetTimePeriod; diff --git a/lib/services/consumptionManagement/lib/lib/models/budgetsListResult.js b/lib/services/consumptionManagement/lib/lib/models/budgetsListResult.js new file mode 100644 index 0000000000..39e1f25fab --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/budgetsListResult.js @@ -0,0 +1,70 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Result of listing budgets. It contains a list of available budgets in the + * scope provided. + */ +class BudgetsListResult extends Array { + /** + * Create a BudgetsListResult. + * @member {string} [nextLink] The link (url) to the next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of BudgetsListResult + * + * @returns {object} metadata of BudgetsListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'BudgetsListResult', + type: { + name: 'Composite', + className: 'BudgetsListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'BudgetElementType', + type: { + name: 'Composite', + className: 'Budget' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = BudgetsListResult; diff --git a/lib/services/consumptionManagement/lib/lib/models/costAllocationTag.js b/lib/services/consumptionManagement/lib/lib/models/costAllocationTag.js new file mode 100644 index 0000000000..2da43a1e85 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/costAllocationTag.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The cost allocation tag. + * + */ +class CostAllocationTag { + /** + * Create a CostAllocationTag. + * @member {string} [key] Cost allocation tag key. + */ + constructor() { + } + + /** + * Defines the metadata of CostAllocationTag + * + * @returns {object} metadata of CostAllocationTag + * + */ + mapper() { + return { + required: false, + serializedName: 'CostAllocationTag', + type: { + name: 'Composite', + className: 'CostAllocationTag', + modelProperties: { + key: { + required: false, + serializedName: 'key', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = CostAllocationTag; diff --git a/lib/services/consumptionManagement/lib/lib/models/costAllocationTags.js b/lib/services/consumptionManagement/lib/lib/models/costAllocationTags.js new file mode 100644 index 0000000000..a77f1aa160 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/costAllocationTags.js @@ -0,0 +1,95 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * A cost allocation tag resource. + * + * @extends models['ProxyResource'] + */ +class CostAllocationTags extends models['ProxyResource'] { + /** + * Create a CostAllocationTags. + * @member {array} [costAllocationTags] Cost allocation tags. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of CostAllocationTags + * + * @returns {object} metadata of CostAllocationTags + * + */ + mapper() { + return { + required: false, + serializedName: 'CostAllocationTags', + type: { + name: 'Composite', + className: 'CostAllocationTags', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + eTag: { + required: false, + serializedName: 'eTag', + type: { + name: 'String' + } + }, + costAllocationTags: { + required: false, + serializedName: 'properties.costAllocationTags', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'CostAllocationTagElementType', + type: { + name: 'Composite', + className: 'CostAllocationTag' + } + } + } + } + } + } + }; + } +} + +module.exports = CostAllocationTags; diff --git a/lib/services/consumptionManagement/lib/lib/models/currentSpend.js b/lib/services/consumptionManagement/lib/lib/models/currentSpend.js new file mode 100644 index 0000000000..7d71826108 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/currentSpend.js @@ -0,0 +1,63 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The current amount of cost which is being tracked for a budget. + * + */ +class CurrentSpend { + /** + * Create a CurrentSpend. + * @member {number} [amount] The total amount of cost which is being tracked + * by the budget. + * @member {string} [unit] The unit of measure for the budget amount. + */ + constructor() { + } + + /** + * Defines the metadata of CurrentSpend + * + * @returns {object} metadata of CurrentSpend + * + */ + mapper() { + return { + required: false, + serializedName: 'CurrentSpend', + type: { + name: 'Composite', + className: 'CurrentSpend', + modelProperties: { + amount: { + required: false, + readOnly: true, + serializedName: 'amount', + type: { + name: 'Number' + } + }, + unit: { + required: false, + readOnly: true, + serializedName: 'unit', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = CurrentSpend; diff --git a/lib/services/consumptionManagement/lib/lib/models/errorDetails.js b/lib/services/consumptionManagement/lib/lib/models/errorDetails.js new file mode 100644 index 0000000000..1d4ab7af07 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/errorDetails.js @@ -0,0 +1,63 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The details of the error. + * + */ +class ErrorDetails { + /** + * Create a ErrorDetails. + * @member {string} [code] Error code. + * @member {string} [message] Error message indicating why the operation + * failed. + */ + constructor() { + } + + /** + * Defines the metadata of ErrorDetails + * + * @returns {object} metadata of ErrorDetails + * + */ + mapper() { + return { + required: false, + serializedName: 'ErrorDetails', + type: { + name: 'Composite', + className: 'ErrorDetails', + modelProperties: { + code: { + required: false, + readOnly: true, + serializedName: 'code', + type: { + name: 'String' + } + }, + message: { + required: false, + readOnly: true, + serializedName: 'message', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ErrorDetails; diff --git a/lib/services/consumptionManagement/lib/lib/models/errorResponse.js b/lib/services/consumptionManagement/lib/lib/models/errorResponse.js new file mode 100644 index 0000000000..c17058b696 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/errorResponse.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Error response indicates that the service is not able to process the + * incoming request. The reason is provided in the error message. + * + */ +class ErrorResponse { + /** + * Create a ErrorResponse. + * @member {object} [error] The details of the error. + * @member {string} [error.code] Error code. + * @member {string} [error.message] Error message indicating why the + * operation failed. + */ + constructor() { + } + + /** + * Defines the metadata of ErrorResponse + * + * @returns {object} metadata of ErrorResponse + * + */ + mapper() { + return { + required: false, + serializedName: 'ErrorResponse', + type: { + name: 'Composite', + className: 'ErrorResponse', + modelProperties: { + error: { + required: false, + serializedName: 'error', + type: { + name: 'Composite', + className: 'ErrorDetails' + } + } + } + } + }; + } +} + +module.exports = ErrorResponse; diff --git a/lib/services/consumptionManagement/lib/lib/models/filters.js b/lib/services/consumptionManagement/lib/lib/models/filters.js new file mode 100644 index 0000000000..957b3e3959 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/filters.js @@ -0,0 +1,125 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * May be used to filter budgets by resource group, resource, or meter. + * + */ +class Filters { + /** + * Create a Filters. + * @member {array} [resourceGroups] The list of filters on resource groups, + * allowed at subscription level only. + * @member {array} [resources] The list of filters on resources. + * @member {array} [meters] The list of filters on meters (GUID), mandatory + * for budgets of usage category. + * @member {object} [tags] The dictionary of filters on tags. + */ + constructor() { + } + + /** + * Defines the metadata of Filters + * + * @returns {object} metadata of Filters + * + */ + mapper() { + return { + required: false, + serializedName: 'Filters', + type: { + name: 'Composite', + className: 'Filters', + modelProperties: { + resourceGroups: { + required: false, + serializedName: 'resourceGroups', + constraints: { + MaxItems: 10, + MinItems: 0 + }, + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + resources: { + required: false, + serializedName: 'resources', + constraints: { + MaxItems: 10, + MinItems: 0 + }, + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + meters: { + required: false, + serializedName: 'meters', + constraints: { + MaxItems: 10, + MinItems: 0 + }, + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'UuidElementType', + type: { + name: 'String' + } + } + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'ArrayElementType', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + } + } + }; + } +} + +module.exports = Filters; diff --git a/lib/services/consumptionManagement/lib/lib/models/index.d.ts b/lib/services/consumptionManagement/lib/lib/models/index.d.ts new file mode 100644 index 0000000000..06dd4174d6 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/index.d.ts @@ -0,0 +1,745 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import { BaseResource } from 'ms-rest-azure'; +import { CloudError } from 'ms-rest-azure'; +import * as moment from 'moment'; + +export { BaseResource } from 'ms-rest-azure'; +export { CloudError } from 'ms-rest-azure'; + + +/** + * @class + * Initializes a new instance of the MeterDetails class. + * @constructor + * The properties of the meter detail. + * + * @member {string} [meterName] The name of the meter, within the given meter + * category + * @member {string} [meterCategory] The category of the meter, for example, + * 'Cloud services', 'Networking', etc.. + * @member {string} [meterSubCategory] The subcategory of the meter, for + * example, 'A6 Cloud services', 'ExpressRoute (IXP)', etc.. + * @member {string} [unit] The unit in which the meter consumption is charged, + * for example, 'Hours', 'GB', etc. + * @member {string} [meterLocation] The location in which the Azure service is + * available. + * @member {number} [totalIncludedQuantity] The total included quantity + * associated with the offer. + * @member {number} [pretaxStandardRate] The pretax listing price. + */ +export interface MeterDetails { + readonly meterName?: string; + readonly meterCategory?: string; + readonly meterSubCategory?: string; + readonly unit?: string; + readonly meterLocation?: string; + readonly totalIncludedQuantity?: number; + readonly pretaxStandardRate?: number; +} + +/** + * @class + * Initializes a new instance of the Resource class. + * @constructor + * The Resource model definition. + * + * @member {string} [id] Resource Id. + * @member {string} [name] Resource name. + * @member {string} [type] Resource type. + * @member {object} [tags] Resource tags. + */ +export interface Resource extends BaseResource { + readonly id?: string; + readonly name?: string; + readonly type?: string; + readonly tags?: { [propertyName: string]: string }; +} + +/** + * @class + * Initializes a new instance of the UsageDetail class. + * @constructor + * An usage detail resource. + * + * @member {string} [billingPeriodId] The id of the billing period resource + * that the usage belongs to. + * @member {string} [invoiceId] The id of the invoice resource that the usage + * belongs to. + * @member {date} [usageStart] The start of the date time range covered by the + * usage detail. + * @member {date} [usageEnd] The end of the date time range covered by the + * usage detail. + * @member {string} [instanceName] The name of the resource instance that the + * usage is about. + * @member {string} [instanceId] The uri of the resource instance that the + * usage is about. + * @member {string} [instanceLocation] The location of the resource instance + * that the usage is about. + * @member {string} [currency] The ISO currency in which the meter is charged, + * for example, USD. + * @member {number} [usageQuantity] The quantity of usage. + * @member {number} [billableQuantity] The billable usage quantity. + * @member {number} [pretaxCost] The amount of cost before tax. + * @member {boolean} [isEstimated] The estimated usage is subject to change. + * @member {uuid} [meterId] The meter id (GUID). + * @member {object} [meterDetails] The details about the meter. By default this + * is not populated, unless it's specified in $expand. + * @member {string} [meterDetails.meterName] The name of the meter, within the + * given meter category + * @member {string} [meterDetails.meterCategory] The category of the meter, for + * example, 'Cloud services', 'Networking', etc.. + * @member {string} [meterDetails.meterSubCategory] The subcategory of the + * meter, for example, 'A6 Cloud services', 'ExpressRoute (IXP)', etc.. + * @member {string} [meterDetails.unit] The unit in which the meter consumption + * is charged, for example, 'Hours', 'GB', etc. + * @member {string} [meterDetails.meterLocation] The location in which the + * Azure service is available. + * @member {number} [meterDetails.totalIncludedQuantity] The total included + * quantity associated with the offer. + * @member {number} [meterDetails.pretaxStandardRate] The pretax listing price. + * @member {uuid} [subscriptionGuid] Subscription guid. + * @member {string} [subscriptionName] Subscription name. + * @member {string} [accountName] Account name. + * @member {string} [departmentName] Department name. + * @member {string} [product] Product name. + * @member {string} [consumedService] Consumed service name. + * @member {string} [costCenter] The cost center of this department if it is a + * department and a costcenter exists + * @member {string} [additionalProperties] Additional details of this usage + * item. By default this is not populated, unless it's specified in $expand. + */ +export interface UsageDetail extends Resource { + readonly billingPeriodId?: string; + readonly invoiceId?: string; + readonly usageStart?: Date; + readonly usageEnd?: Date; + readonly instanceName?: string; + readonly instanceId?: string; + readonly instanceLocation?: string; + readonly currency?: string; + readonly usageQuantity?: number; + readonly billableQuantity?: number; + readonly pretaxCost?: number; + readonly isEstimated?: boolean; + readonly meterId?: string; + readonly meterDetails?: MeterDetails; + readonly subscriptionGuid?: string; + readonly subscriptionName?: string; + readonly accountName?: string; + readonly departmentName?: string; + readonly product?: string; + readonly consumedService?: string; + readonly costCenter?: string; + readonly additionalProperties?: string; +} + +/** + * @class + * Initializes a new instance of the Marketplace class. + * @constructor + * An marketplace resource. + * + * @member {string} [billingPeriodId] The id of the billing period resource + * that the usage belongs to. + * @member {date} [usageStart] The start of the date time range covered by the + * usage detail. + * @member {date} [usageEnd] The end of the date time range covered by the + * usage detail. + * @member {number} [resourceRate] The marketplace resource rate. + * @member {string} [offerName] The type of offer. + * @member {string} [resourceGroup] The name of resource group. + * @member {string} [orderNumber] The order number. + * @member {string} [instanceName] The name of the resource instance that the + * usage is about. + * @member {string} [instanceId] The uri of the resource instance that the + * usage is about. + * @member {string} [currency] The ISO currency in which the meter is charged, + * for example, USD. + * @member {number} [consumedQuantity] The quantity of usage. + * @member {string} [unitOfMeasure] The unit of measure. + * @member {number} [pretaxCost] The amount of cost before tax. + * @member {boolean} [isEstimated] The estimated usage is subject to change. + * @member {uuid} [meterId] The meter id (GUID). + * @member {uuid} [subscriptionGuid] Subscription guid. + * @member {string} [subscriptionName] Subscription name. + * @member {string} [accountName] Account name. + * @member {string} [departmentName] Department name. + * @member {string} [consumedService] Consumed service name. + * @member {string} [costCenter] The cost center of this department if it is a + * department and a costcenter exists + * @member {string} [additionalProperties] Additional details of this usage + * item. By default this is not populated, unless it's specified in $expand. + * @member {string} [publisherName] The name of publisher. + * @member {string} [planName] The name of plan. + */ +export interface Marketplace extends Resource { + readonly billingPeriodId?: string; + readonly usageStart?: Date; + readonly usageEnd?: Date; + readonly resourceRate?: number; + readonly offerName?: string; + readonly resourceGroup?: string; + readonly orderNumber?: string; + readonly instanceName?: string; + readonly instanceId?: string; + readonly currency?: string; + readonly consumedQuantity?: number; + readonly unitOfMeasure?: string; + readonly pretaxCost?: number; + readonly isEstimated?: boolean; + readonly meterId?: string; + readonly subscriptionGuid?: string; + readonly subscriptionName?: string; + readonly accountName?: string; + readonly departmentName?: string; + readonly consumedService?: string; + readonly costCenter?: string; + readonly additionalProperties?: string; + readonly publisherName?: string; + readonly planName?: string; +} + +/** + * @class + * Initializes a new instance of the ReservationSummaries class. + * @constructor + * reservation summaries resource. + * + * @member {string} [reservationOrderId] The reservation order ID is the + * identifier for a reservation purchase. Each reservation order ID represents + * a single purchase transaction. A reservation order contains reservations. + * The reservation order specifies the VM size and region for the reservations. + * @member {string} [reservationId] The reservation ID is the identifier of a + * reservation within a reservation order. Each reservation is the grouping for + * applying the benefit scope and also specifies the number of instances to + * which the reservation benefit can be applied to. + * @member {string} [skuName] This is the ARM Sku name. It can be used to join + * with the servicetype field in additoinalinfo in usage records. + * @member {number} [reservedHours] This is the total hours reserved. E.g. if + * reservation for 1 instance was made on 1 PM, this will be 11 hours for that + * day and 24 hours from subsequent days + * @member {date} [usageDate] Data corresponding to the utilization record. If + * the grain of data is monthly, it will be first day of month. + * @member {number} [usedHours] Total used hours by the reservation + * @member {number} [minUtilizationPercentage] This is the minimum hourly + * utilization in the usage time (day or month). E.g. if usage record + * corresponds to 12/10/2017 and on that for hour 4 and 5, utilization was 10%, + * this field will return 10% for that day + * @member {number} [avgUtilizationPercentage] This is average utilization for + * the entire time range. (day or month depending on the grain) + * @member {number} [maxUtilizationPercentage] This is the maximum hourly + * utilization in the usage time (day or month). E.g. if usage record + * corresponds to 12/10/2017 and on that for hour 4 and 5, utilization was + * 100%, this field will return 100% for that day. + */ +export interface ReservationSummaries extends Resource { + readonly reservationOrderId?: string; + readonly reservationId?: string; + readonly skuName?: string; + readonly reservedHours?: number; + readonly usageDate?: Date; + readonly usedHours?: number; + readonly minUtilizationPercentage?: number; + readonly avgUtilizationPercentage?: number; + readonly maxUtilizationPercentage?: number; +} + +/** + * @class + * Initializes a new instance of the ReservationDetails class. + * @constructor + * reservation details resource. + * + * @member {string} [reservationOrderId] The reservation order ID is the + * identifier for a reservation purchase. Each reservation order ID represents + * a single purchase transaction. A reservation order contains reservations. + * The reservation order specifies the VM size and region for the reservations. + * @member {string} [reservationId] The reservation ID is the identifier of a + * reservation within a reservation order. Each reservation is the grouping for + * applying the benefit scope and also specifies the number of instances to + * which the reservation benefit can be applied to. + * @member {string} [skuName] This is the ARM Sku name. It can be used to join + * with the servicetype field in additoinalinfo in usage records. + * @member {number} [reservedHours] This is the total hours reserved for the + * day. E.g. if reservation for 1 instance was made on 1 PM, this will be 11 + * hours for that day and 24 hours from subsequent days. + * @member {date} [usageDate] The date on which consumption occurred. + * @member {number} [usedHours] This is the total hours used by the instance. + * @member {string} [instanceId] This identifier is the name of the resource or + * the fully qualified Resource ID. + * @member {number} [totalReservedQuantity] This is the total count of + * instances that are reserved for the reservationid. + */ +export interface ReservationDetails extends Resource { + readonly reservationOrderId?: string; + readonly reservationId?: string; + readonly skuName?: string; + readonly reservedHours?: number; + readonly usageDate?: Date; + readonly usedHours?: number; + readonly instanceId?: string; + readonly totalReservedQuantity?: number; +} + +/** + * @class + * Initializes a new instance of the ReservationRecommendations class. + * @constructor + * Reservation recommendations resource. + * + * @member {string} [id] Resource Id. + * @member {string} [name] Resource name. + * @member {string} [type] Resource type. + * @member {object} [tags] Resource tags. + * @member {string} [location] Resource location + * @member {string} [sku] Resource sku + * @member {string} [lookBackPeriod] The number of days of usage to look back + * for recommendations. + * @member {uuid} [meterId] The meter id (GUID) + * @member {string} [term] RI recommendations in one or three year terms. + * @member {number} [costWithNoReservedInstances] The total amount of cost + * without reserved instances. + * @member {number} [recommendedQuantity] Recomended quality for reserved + * instances. + * @member {number} [totalCostWithReservedInstances] The total amount of cost + * with reserved instances. + * @member {number} [netSavings] Total estimated savings with reserved + * instances. + * @member {date} [firstUsageDate] The usage date for looking back. + * @member {string} [scope] Shared or single recommendation. + */ +export interface ReservationRecommendations { + readonly id?: string; + readonly name?: string; + readonly type?: string; + readonly tags?: { [propertyName: string]: string }; + readonly location?: string; + readonly sku?: string; + readonly lookBackPeriod?: string; + readonly meterId?: string; + readonly term?: string; + readonly costWithNoReservedInstances?: number; + readonly recommendedQuantity?: number; + readonly totalCostWithReservedInstances?: number; + readonly netSavings?: number; + readonly firstUsageDate?: Date; + readonly scope?: string; +} + +/** + * @class + * Initializes a new instance of the BudgetTimePeriod class. + * @constructor + * The start and end date for a budget. + * + * @member {date} startDate The start date for the budget. + * @member {date} [endDate] The end date for the budget. If not provided, we + * default this to 10 years from the start date. + */ +export interface BudgetTimePeriod { + startDate: Date; + endDate?: Date; +} + +/** + * @class + * Initializes a new instance of the Filters class. + * @constructor + * May be used to filter budgets by resource group, resource, or meter. + * + * @member {array} [resourceGroups] The list of filters on resource groups, + * allowed at subscription level only. + * @member {array} [resources] The list of filters on resources. + * @member {array} [meters] The list of filters on meters (GUID), mandatory for + * budgets of usage category. + * @member {object} [tags] The dictionary of filters on tags. + */ +export interface Filters { + resourceGroups?: string[]; + resources?: string[]; + meters?: string[]; + tags?: { [propertyName: string]: string[] }; +} + +/** + * @class + * Initializes a new instance of the CurrentSpend class. + * @constructor + * The current amount of cost which is being tracked for a budget. + * + * @member {number} [amount] The total amount of cost which is being tracked by + * the budget. + * @member {string} [unit] The unit of measure for the budget amount. + */ +export interface CurrentSpend { + readonly amount?: number; + readonly unit?: string; +} + +/** + * @class + * Initializes a new instance of the Notification class. + * @constructor + * The notification associated with a budget. + * + * @member {boolean} enabled The notification is enabled or not. + * @member {string} operator The comparison operator. Possible values include: + * 'EqualTo', 'GreaterThan', 'GreaterThanOrEqualTo' + * @member {number} threshold Threshold value associated with a notification. + * Notification is sent when the cost exceeded the threshold. It is always + * percent and has to be between 0 and 1000. + * @member {array} contactEmails Email addresses to send the budget + * notification to when the threshold is exceeded. + * @member {array} [contactRoles] Contact roles to send the budget notification + * to when the threshold is exceeded. + * @member {array} [contactGroups] Action groups to send the budget + * notification to when the threshold is exceeded. + */ +export interface Notification { + enabled: boolean; + operator: string; + threshold: number; + contactEmails: string[]; + contactRoles?: string[]; + contactGroups?: string[]; +} + +/** + * @class + * Initializes a new instance of the ProxyResource class. + * @constructor + * The Resource model definition. + * + * @member {string} [id] Resource Id. + * @member {string} [name] Resource name. + * @member {string} [type] Resource type. + * @member {string} [eTag] eTag of the resource. To handle concurrent update + * scenarion, this field will be used to determine whether the user is updating + * the latest version or not. + */ +export interface ProxyResource extends BaseResource { + readonly id?: string; + readonly name?: string; + readonly type?: string; + eTag?: string; +} + +/** + * @class + * Initializes a new instance of the Budget class. + * @constructor + * A budget resource. + * + * @member {string} category The category of the budget, whether the budget + * tracks cost or usage. Possible values include: 'Cost', 'Usage' + * @member {number} amount The total amount of cost to track with the budget + * @member {string} timeGrain The time covered by a budget. Tracking of the + * amount will be reset based on the time grain. Possible values include: + * 'Monthly', 'Quarterly', 'Annually' + * @member {object} timePeriod Has start and end date of the budget. The start + * date must be first of the month and should be less than the end date. Budget + * start date must be on or after June 1, 2017. Future start date should not be + * more than three months. Past start date should be selected within the + * timegrain preiod. There are no restrictions on the end date. + * @member {date} [timePeriod.startDate] The start date for the budget. + * @member {date} [timePeriod.endDate] The end date for the budget. If not + * provided, we default this to 10 years from the start date. + * @member {object} [filters] May be used to filter budgets by resource group, + * resource, or meter. + * @member {array} [filters.resourceGroups] The list of filters on resource + * groups, allowed at subscription level only. + * @member {array} [filters.resources] The list of filters on resources. + * @member {array} [filters.meters] The list of filters on meters (GUID), + * mandatory for budgets of usage category. + * @member {object} [filters.tags] The dictionary of filters on tags. + * @member {object} [currentSpend] The current amount of cost which is being + * tracked for a budget. + * @member {number} [currentSpend.amount] The total amount of cost which is + * being tracked by the budget. + * @member {string} [currentSpend.unit] The unit of measure for the budget + * amount. + * @member {object} [notifications] Dictionary of notifications associated with + * the budget. Budget can have up to five notifications. + */ +export interface Budget extends ProxyResource { + category: string; + amount: number; + timeGrain: string; + timePeriod: BudgetTimePeriod; + filters?: Filters; + readonly currentSpend?: CurrentSpend; + notifications?: { [propertyName: string]: Notification }; +} + +/** + * @class + * Initializes a new instance of the CostAllocationTag class. + * @constructor + * The cost allocation tag. + * + * @member {string} [key] Cost allocation tag key. + */ +export interface CostAllocationTag { + key?: string; +} + +/** + * @class + * Initializes a new instance of the CostAllocationTags class. + * @constructor + * A cost allocation tag resource. + * + * @member {array} [costAllocationTags] Cost allocation tags. + */ +export interface CostAllocationTags extends ProxyResource { + costAllocationTags?: CostAllocationTag[]; +} + +/** + * @class + * Initializes a new instance of the ErrorDetails class. + * @constructor + * The details of the error. + * + * @member {string} [code] Error code. + * @member {string} [message] Error message indicating why the operation + * failed. + */ +export interface ErrorDetails { + readonly code?: string; + readonly message?: string; +} + +/** + * @class + * Initializes a new instance of the ErrorResponse class. + * @constructor + * Error response indicates that the service is not able to process the + * incoming request. The reason is provided in the error message. + * + * @member {object} [error] The details of the error. + * @member {string} [error.code] Error code. + * @member {string} [error.message] Error message indicating why the operation + * failed. + */ +export interface ErrorResponse { + error?: ErrorDetails; +} + +/** + * @class + * Initializes a new instance of the OperationDisplay class. + * @constructor + * The object that represents the operation. + * + * @member {string} [provider] Service provider: Microsoft.Consumption. + * @member {string} [resource] Resource on which the operation is performed: + * UsageDetail, etc. + * @member {string} [operation] Operation type: Read, write, delete, etc. + */ +export interface OperationDisplay { + readonly provider?: string; + readonly resource?: string; + readonly operation?: string; +} + +/** + * @class + * Initializes a new instance of the Operation class. + * @constructor + * A Consumption REST API operation. + * + * @member {string} [name] Operation name: {provider}/{resource}/{operation}. + * @member {object} [display] The object that represents the operation. + * @member {string} [display.provider] Service provider: Microsoft.Consumption. + * @member {string} [display.resource] Resource on which the operation is + * performed: UsageDetail, etc. + * @member {string} [display.operation] Operation type: Read, write, delete, + * etc. + */ +export interface Operation { + readonly name?: string; + display?: OperationDisplay; +} + +/** + * @class + * Initializes a new instance of the ResourceAttributes class. + * @constructor + * The Resource model definition. + * + * @member {string} [location] Resource location + * @member {string} [sku] Resource sku + */ +export interface ResourceAttributes { + readonly location?: string; + readonly sku?: string; +} + +/** + * @class + * Initializes a new instance of the PriceSheetProperties class. + * @constructor + * The properties of the price sheet. + * + * @member {string} [billingPeriodId] The id of the billing period resource + * that the usage belongs to. + * @member {uuid} [meterId] The meter id (GUID) + * @member {object} [meterDetails] The details about the meter. By default this + * is not populated, unless it's specified in $expand. + * @member {string} [meterDetails.meterName] The name of the meter, within the + * given meter category + * @member {string} [meterDetails.meterCategory] The category of the meter, for + * example, 'Cloud services', 'Networking', etc.. + * @member {string} [meterDetails.meterSubCategory] The subcategory of the + * meter, for example, 'A6 Cloud services', 'ExpressRoute (IXP)', etc.. + * @member {string} [meterDetails.unit] The unit in which the meter consumption + * is charged, for example, 'Hours', 'GB', etc. + * @member {string} [meterDetails.meterLocation] The location in which the + * Azure service is available. + * @member {number} [meterDetails.totalIncludedQuantity] The total included + * quantity associated with the offer. + * @member {number} [meterDetails.pretaxStandardRate] The pretax listing price. + * @member {string} [unitOfMeasure] Unit of measure + * @member {number} [includedQuantity] Included quality for an offer + * @member {string} [partNumber] Part Number + * @member {number} [unitPrice] Unit Price + * @member {string} [currencyCode] Currency Code + */ +export interface PriceSheetProperties { + readonly billingPeriodId?: string; + readonly meterId?: string; + readonly meterDetails?: MeterDetails; + readonly unitOfMeasure?: string; + readonly includedQuantity?: number; + readonly partNumber?: string; + readonly unitPrice?: number; + readonly currencyCode?: string; +} + +/** + * @class + * Initializes a new instance of the PriceSheetResult class. + * @constructor + * An pricesheet resource. + * + * @member {array} [pricesheets] Price sheet + * @member {string} [nextLink] The link (url) to the next page of results. + */ +export interface PriceSheetResult extends Resource { + readonly pricesheets?: PriceSheetProperties[]; + readonly nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the QueryOptions class. + * @constructor + * Additional parameters for a set of operations, such as: UsageDetails_list, + * UsageDetails_listByBillingPeriod. + * + * @member {string} [apply] OData apply expression to aggregatie usageDetails + * by tags or (tags and properties/usageStart) + */ +export interface QueryOptions { + apply?: string; +} + + +/** + * @class + * Initializes a new instance of the UsageDetailsListResult class. + * @constructor + * Result of listing usage details. It contains a list of available usage + * details in reverse chronological order by billing period. + * + * @member {string} [nextLink] The link (url) to the next page of results. + */ +export interface UsageDetailsListResult extends Array { + readonly nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the MarketplacesListResult class. + * @constructor + * Result of listing marketplaces. It contains a list of available marketplaces + * in reverse chronological order by billing period. + * + * @member {string} [nextLink] The link (url) to the next page of results. + */ +export interface MarketplacesListResult extends Array { + readonly nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the ReservationSummariesListResult class. + * @constructor + * Result of listing reservation summaries. + * + * @member {string} [nextLink] The link (url) to the next page of results. + */ +export interface ReservationSummariesListResult extends Array { + readonly nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the ReservationDetailsListResult class. + * @constructor + * Result of listing reservation details. + * + * @member {string} [nextLink] The link (url) to the next page of results. + */ +export interface ReservationDetailsListResult extends Array { + readonly nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the ReservationRecommendationsListResult class. + * @constructor + * Result of listing reservation recommendations. + * + * @member {string} [nextLink] The link (url) to the next page of results. + */ +export interface ReservationRecommendationsListResult extends Array { + readonly nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the BudgetsListResult class. + * @constructor + * Result of listing budgets. It contains a list of available budgets in the + * scope provided. + * + * @member {string} [nextLink] The link (url) to the next page of results. + */ +export interface BudgetsListResult extends Array { + readonly nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the OperationListResult class. + * @constructor + * Result of listing consumption operations. It contains a list of operations + * and a URL link to get the next set of results. + * + * @member {string} [nextLink] URL to get the next set of operation list + * results if there are any. + */ +export interface OperationListResult extends Array { + readonly nextLink?: string; +} diff --git a/lib/services/consumptionManagement/lib/lib/models/index.js b/lib/services/consumptionManagement/lib/lib/models/index.js new file mode 100644 index 0000000000..35476b9bf0 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/index.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +var msRestAzure = require('ms-rest-azure'); + +exports.BaseResource = msRestAzure.BaseResource; +exports.CloudError = msRestAzure.CloudError; +exports.MeterDetails = require('./meterDetails'); +exports.Resource = require('./resource'); +exports.UsageDetail = require('./usageDetail'); +exports.Marketplace = require('./marketplace'); +exports.ReservationSummaries = require('./reservationSummaries'); +exports.ReservationDetails = require('./reservationDetails'); +exports.ReservationRecommendations = require('./reservationRecommendations'); +exports.BudgetTimePeriod = require('./budgetTimePeriod'); +exports.Filters = require('./filters'); +exports.CurrentSpend = require('./currentSpend'); +exports.Notification = require('./notification'); +exports.ProxyResource = require('./proxyResource'); +exports.Budget = require('./budget'); +exports.CostAllocationTag = require('./costAllocationTag'); +exports.CostAllocationTags = require('./costAllocationTags'); +exports.ErrorDetails = require('./errorDetails'); +exports.ErrorResponse = require('./errorResponse'); +exports.OperationDisplay = require('./operationDisplay'); +exports.Operation = require('./operation'); +exports.ResourceAttributes = require('./resourceAttributes'); +exports.PriceSheetProperties = require('./priceSheetProperties'); +exports.PriceSheetResult = require('./priceSheetResult'); +exports.QueryOptions = require('./queryOptions'); +exports.UsageDetailsListResult = require('./usageDetailsListResult'); +exports.MarketplacesListResult = require('./marketplacesListResult'); +exports.ReservationSummariesListResult = require('./reservationSummariesListResult'); +exports.ReservationDetailsListResult = require('./reservationDetailsListResult'); +exports.ReservationRecommendationsListResult = require('./reservationRecommendationsListResult'); +exports.BudgetsListResult = require('./budgetsListResult'); +exports.OperationListResult = require('./operationListResult'); diff --git a/lib/services/consumptionManagement/lib/lib/models/marketplace.js b/lib/services/consumptionManagement/lib/lib/models/marketplace.js new file mode 100644 index 0000000000..b7e9515134 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/marketplace.js @@ -0,0 +1,311 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * An marketplace resource. + * + * @extends models['Resource'] + */ +class Marketplace extends models['Resource'] { + /** + * Create a Marketplace. + * @member {string} [billingPeriodId] The id of the billing period resource + * that the usage belongs to. + * @member {date} [usageStart] The start of the date time range covered by + * the usage detail. + * @member {date} [usageEnd] The end of the date time range covered by the + * usage detail. + * @member {number} [resourceRate] The marketplace resource rate. + * @member {string} [offerName] The type of offer. + * @member {string} [resourceGroup] The name of resource group. + * @member {string} [orderNumber] The order number. + * @member {string} [instanceName] The name of the resource instance that the + * usage is about. + * @member {string} [instanceId] The uri of the resource instance that the + * usage is about. + * @member {string} [currency] The ISO currency in which the meter is + * charged, for example, USD. + * @member {number} [consumedQuantity] The quantity of usage. + * @member {string} [unitOfMeasure] The unit of measure. + * @member {number} [pretaxCost] The amount of cost before tax. + * @member {boolean} [isEstimated] The estimated usage is subject to change. + * @member {uuid} [meterId] The meter id (GUID). + * @member {uuid} [subscriptionGuid] Subscription guid. + * @member {string} [subscriptionName] Subscription name. + * @member {string} [accountName] Account name. + * @member {string} [departmentName] Department name. + * @member {string} [consumedService] Consumed service name. + * @member {string} [costCenter] The cost center of this department if it is + * a department and a costcenter exists + * @member {string} [additionalProperties] Additional details of this usage + * item. By default this is not populated, unless it's specified in $expand. + * @member {string} [publisherName] The name of publisher. + * @member {string} [planName] The name of plan. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Marketplace + * + * @returns {object} metadata of Marketplace + * + */ + mapper() { + return { + required: false, + serializedName: 'Marketplace', + type: { + name: 'Composite', + className: 'Marketplace', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + tags: { + required: false, + readOnly: true, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + billingPeriodId: { + required: false, + readOnly: true, + serializedName: 'properties.billingPeriodId', + type: { + name: 'String' + } + }, + usageStart: { + required: false, + readOnly: true, + serializedName: 'properties.usageStart', + type: { + name: 'DateTime' + } + }, + usageEnd: { + required: false, + readOnly: true, + serializedName: 'properties.usageEnd', + type: { + name: 'DateTime' + } + }, + resourceRate: { + required: false, + readOnly: true, + serializedName: 'properties.resourceRate', + type: { + name: 'Number' + } + }, + offerName: { + required: false, + readOnly: true, + serializedName: 'properties.offerName', + type: { + name: 'String' + } + }, + resourceGroup: { + required: false, + readOnly: true, + serializedName: 'properties.resourceGroup', + type: { + name: 'String' + } + }, + orderNumber: { + required: false, + readOnly: true, + serializedName: 'properties.orderNumber', + type: { + name: 'String' + } + }, + instanceName: { + required: false, + readOnly: true, + serializedName: 'properties.instanceName', + type: { + name: 'String' + } + }, + instanceId: { + required: false, + readOnly: true, + serializedName: 'properties.instanceId', + type: { + name: 'String' + } + }, + currency: { + required: false, + readOnly: true, + serializedName: 'properties.currency', + type: { + name: 'String' + } + }, + consumedQuantity: { + required: false, + readOnly: true, + serializedName: 'properties.consumedQuantity', + type: { + name: 'Number' + } + }, + unitOfMeasure: { + required: false, + readOnly: true, + serializedName: 'properties.unitOfMeasure', + type: { + name: 'String' + } + }, + pretaxCost: { + required: false, + readOnly: true, + serializedName: 'properties.pretaxCost', + type: { + name: 'Number' + } + }, + isEstimated: { + required: false, + readOnly: true, + serializedName: 'properties.isEstimated', + type: { + name: 'Boolean' + } + }, + meterId: { + required: false, + readOnly: true, + serializedName: 'properties.meterId', + type: { + name: 'String' + } + }, + subscriptionGuid: { + required: false, + readOnly: true, + serializedName: 'properties.subscriptionGuid', + type: { + name: 'String' + } + }, + subscriptionName: { + required: false, + readOnly: true, + serializedName: 'properties.subscriptionName', + type: { + name: 'String' + } + }, + accountName: { + required: false, + readOnly: true, + serializedName: 'properties.accountName', + type: { + name: 'String' + } + }, + departmentName: { + required: false, + readOnly: true, + serializedName: 'properties.departmentName', + type: { + name: 'String' + } + }, + consumedService: { + required: false, + readOnly: true, + serializedName: 'properties.consumedService', + type: { + name: 'String' + } + }, + costCenter: { + required: false, + readOnly: true, + serializedName: 'properties.costCenter', + type: { + name: 'String' + } + }, + additionalProperties: { + required: false, + readOnly: true, + serializedName: 'properties.additionalProperties', + type: { + name: 'String' + } + }, + publisherName: { + required: false, + readOnly: true, + serializedName: 'properties.publisherName', + type: { + name: 'String' + } + }, + planName: { + required: false, + readOnly: true, + serializedName: 'properties.planName', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = Marketplace; diff --git a/lib/services/consumptionManagement/lib/lib/models/marketplacesListResult.js b/lib/services/consumptionManagement/lib/lib/models/marketplacesListResult.js new file mode 100644 index 0000000000..1d5273cd2e --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/marketplacesListResult.js @@ -0,0 +1,70 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Result of listing marketplaces. It contains a list of available marketplaces + * in reverse chronological order by billing period. + */ +class MarketplacesListResult extends Array { + /** + * Create a MarketplacesListResult. + * @member {string} [nextLink] The link (url) to the next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of MarketplacesListResult + * + * @returns {object} metadata of MarketplacesListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'MarketplacesListResult', + type: { + name: 'Composite', + className: 'MarketplacesListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'MarketplaceElementType', + type: { + name: 'Composite', + className: 'Marketplace' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = MarketplacesListResult; diff --git a/lib/services/consumptionManagement/lib/lib/models/meterDetails.js b/lib/services/consumptionManagement/lib/lib/models/meterDetails.js new file mode 100644 index 0000000000..3420ce4172 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/meterDetails.js @@ -0,0 +1,113 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The properties of the meter detail. + * + */ +class MeterDetails { + /** + * Create a MeterDetails. + * @member {string} [meterName] The name of the meter, within the given meter + * category + * @member {string} [meterCategory] The category of the meter, for example, + * 'Cloud services', 'Networking', etc.. + * @member {string} [meterSubCategory] The subcategory of the meter, for + * example, 'A6 Cloud services', 'ExpressRoute (IXP)', etc.. + * @member {string} [unit] The unit in which the meter consumption is + * charged, for example, 'Hours', 'GB', etc. + * @member {string} [meterLocation] The location in which the Azure service + * is available. + * @member {number} [totalIncludedQuantity] The total included quantity + * associated with the offer. + * @member {number} [pretaxStandardRate] The pretax listing price. + */ + constructor() { + } + + /** + * Defines the metadata of MeterDetails + * + * @returns {object} metadata of MeterDetails + * + */ + mapper() { + return { + required: false, + serializedName: 'MeterDetails', + type: { + name: 'Composite', + className: 'MeterDetails', + modelProperties: { + meterName: { + required: false, + readOnly: true, + serializedName: 'meterName', + type: { + name: 'String' + } + }, + meterCategory: { + required: false, + readOnly: true, + serializedName: 'meterCategory', + type: { + name: 'String' + } + }, + meterSubCategory: { + required: false, + readOnly: true, + serializedName: 'meterSubCategory', + type: { + name: 'String' + } + }, + unit: { + required: false, + readOnly: true, + serializedName: 'unit', + type: { + name: 'String' + } + }, + meterLocation: { + required: false, + readOnly: true, + serializedName: 'meterLocation', + type: { + name: 'String' + } + }, + totalIncludedQuantity: { + required: false, + readOnly: true, + serializedName: 'totalIncludedQuantity', + type: { + name: 'Number' + } + }, + pretaxStandardRate: { + required: false, + readOnly: true, + serializedName: 'pretaxStandardRate', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = MeterDetails; diff --git a/lib/services/consumptionManagement/lib/lib/models/notification.js b/lib/services/consumptionManagement/lib/lib/models/notification.js new file mode 100644 index 0000000000..95329c8e72 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/notification.js @@ -0,0 +1,127 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The notification associated with a budget. + * + */ +class Notification { + /** + * Create a Notification. + * @member {boolean} enabled The notification is enabled or not. + * @member {string} operator The comparison operator. Possible values + * include: 'EqualTo', 'GreaterThan', 'GreaterThanOrEqualTo' + * @member {number} threshold Threshold value associated with a notification. + * Notification is sent when the cost exceeded the threshold. It is always + * percent and has to be between 0 and 1000. + * @member {array} contactEmails Email addresses to send the budget + * notification to when the threshold is exceeded. + * @member {array} [contactRoles] Contact roles to send the budget + * notification to when the threshold is exceeded. + * @member {array} [contactGroups] Action groups to send the budget + * notification to when the threshold is exceeded. + */ + constructor() { + } + + /** + * Defines the metadata of Notification + * + * @returns {object} metadata of Notification + * + */ + mapper() { + return { + required: false, + serializedName: 'Notification', + type: { + name: 'Composite', + className: 'Notification', + modelProperties: { + enabled: { + required: true, + serializedName: 'enabled', + type: { + name: 'Boolean' + } + }, + operator: { + required: true, + serializedName: 'operator', + type: { + name: 'String' + } + }, + threshold: { + required: true, + serializedName: 'threshold', + type: { + name: 'Number' + } + }, + contactEmails: { + required: true, + serializedName: 'contactEmails', + constraints: { + MaxItems: 50, + MinItems: 1 + }, + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + contactRoles: { + required: false, + serializedName: 'contactRoles', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + contactGroups: { + required: false, + serializedName: 'contactGroups', + constraints: { + MaxItems: 50, + MinItems: 0 + }, + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = Notification; diff --git a/lib/services/consumptionManagement/lib/lib/models/operation.js b/lib/services/consumptionManagement/lib/lib/models/operation.js new file mode 100644 index 0000000000..733b297050 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/operation.js @@ -0,0 +1,70 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * A Consumption REST API operation. + * + */ +class Operation { + /** + * Create a Operation. + * @member {string} [name] Operation name: {provider}/{resource}/{operation}. + * @member {object} [display] The object that represents the operation. + * @member {string} [display.provider] Service provider: + * Microsoft.Consumption. + * @member {string} [display.resource] Resource on which the operation is + * performed: UsageDetail, etc. + * @member {string} [display.operation] Operation type: Read, write, delete, + * etc. + */ + constructor() { + } + + /** + * Defines the metadata of Operation + * + * @returns {object} metadata of Operation + * + */ + mapper() { + return { + required: false, + serializedName: 'Operation', + type: { + name: 'Composite', + className: 'Operation', + modelProperties: { + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + display: { + required: false, + serializedName: 'display', + type: { + name: 'Composite', + className: 'OperationDisplay' + } + } + } + } + }; + } +} + +module.exports = Operation; diff --git a/lib/services/consumptionManagement/lib/lib/models/operationDisplay.js b/lib/services/consumptionManagement/lib/lib/models/operationDisplay.js new file mode 100644 index 0000000000..310f7845fc --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/operationDisplay.js @@ -0,0 +1,72 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The object that represents the operation. + * + */ +class OperationDisplay { + /** + * Create a OperationDisplay. + * @member {string} [provider] Service provider: Microsoft.Consumption. + * @member {string} [resource] Resource on which the operation is performed: + * UsageDetail, etc. + * @member {string} [operation] Operation type: Read, write, delete, etc. + */ + constructor() { + } + + /** + * Defines the metadata of OperationDisplay + * + * @returns {object} metadata of OperationDisplay + * + */ + mapper() { + return { + required: false, + serializedName: 'Operation_display', + type: { + name: 'Composite', + className: 'OperationDisplay', + modelProperties: { + provider: { + required: false, + readOnly: true, + serializedName: 'provider', + type: { + name: 'String' + } + }, + resource: { + required: false, + readOnly: true, + serializedName: 'resource', + type: { + name: 'String' + } + }, + operation: { + required: false, + readOnly: true, + serializedName: 'operation', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = OperationDisplay; diff --git a/lib/services/consumptionManagement/lib/lib/models/operationListResult.js b/lib/services/consumptionManagement/lib/lib/models/operationListResult.js new file mode 100644 index 0000000000..6f0354dbf6 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/operationListResult.js @@ -0,0 +1,71 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Result of listing consumption operations. It contains a list of operations + * and a URL link to get the next set of results. + */ +class OperationListResult extends Array { + /** + * Create a OperationListResult. + * @member {string} [nextLink] URL to get the next set of operation list + * results if there are any. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of OperationListResult + * + * @returns {object} metadata of OperationListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'OperationListResult', + type: { + name: 'Composite', + className: 'OperationListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'OperationElementType', + type: { + name: 'Composite', + className: 'Operation' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = OperationListResult; diff --git a/lib/services/consumptionManagement/lib/lib/models/priceSheetProperties.js b/lib/services/consumptionManagement/lib/lib/models/priceSheetProperties.js new file mode 100644 index 0000000000..b40d0a6a23 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/priceSheetProperties.js @@ -0,0 +1,135 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * The properties of the price sheet. + * + */ +class PriceSheetProperties { + /** + * Create a PriceSheetProperties. + * @member {string} [billingPeriodId] The id of the billing period resource + * that the usage belongs to. + * @member {uuid} [meterId] The meter id (GUID) + * @member {object} [meterDetails] The details about the meter. By default + * this is not populated, unless it's specified in $expand. + * @member {string} [meterDetails.meterName] The name of the meter, within + * the given meter category + * @member {string} [meterDetails.meterCategory] The category of the meter, + * for example, 'Cloud services', 'Networking', etc.. + * @member {string} [meterDetails.meterSubCategory] The subcategory of the + * meter, for example, 'A6 Cloud services', 'ExpressRoute (IXP)', etc.. + * @member {string} [meterDetails.unit] The unit in which the meter + * consumption is charged, for example, 'Hours', 'GB', etc. + * @member {string} [meterDetails.meterLocation] The location in which the + * Azure service is available. + * @member {number} [meterDetails.totalIncludedQuantity] The total included + * quantity associated with the offer. + * @member {number} [meterDetails.pretaxStandardRate] The pretax listing + * price. + * @member {string} [unitOfMeasure] Unit of measure + * @member {number} [includedQuantity] Included quality for an offer + * @member {string} [partNumber] Part Number + * @member {number} [unitPrice] Unit Price + * @member {string} [currencyCode] Currency Code + */ + constructor() { + } + + /** + * Defines the metadata of PriceSheetProperties + * + * @returns {object} metadata of PriceSheetProperties + * + */ + mapper() { + return { + required: false, + serializedName: 'PriceSheetProperties', + type: { + name: 'Composite', + className: 'PriceSheetProperties', + modelProperties: { + billingPeriodId: { + required: false, + readOnly: true, + serializedName: 'billingPeriodId', + type: { + name: 'String' + } + }, + meterId: { + required: false, + readOnly: true, + serializedName: 'meterId', + type: { + name: 'String' + } + }, + meterDetails: { + required: false, + readOnly: true, + serializedName: 'meterDetails', + type: { + name: 'Composite', + className: 'MeterDetails' + } + }, + unitOfMeasure: { + required: false, + readOnly: true, + serializedName: 'unitOfMeasure', + type: { + name: 'String' + } + }, + includedQuantity: { + required: false, + readOnly: true, + serializedName: 'includedQuantity', + type: { + name: 'Number' + } + }, + partNumber: { + required: false, + readOnly: true, + serializedName: 'partNumber', + type: { + name: 'String' + } + }, + unitPrice: { + required: false, + readOnly: true, + serializedName: 'unitPrice', + type: { + name: 'Number' + } + }, + currencyCode: { + required: false, + readOnly: true, + serializedName: 'currencyCode', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = PriceSheetProperties; diff --git a/lib/services/consumptionManagement/lib/lib/models/priceSheetResult.js b/lib/services/consumptionManagement/lib/lib/models/priceSheetResult.js new file mode 100644 index 0000000000..946e5c5157 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/priceSheetResult.js @@ -0,0 +1,113 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * An pricesheet resource. + * + * @extends models['Resource'] + */ +class PriceSheetResult extends models['Resource'] { + /** + * Create a PriceSheetResult. + * @member {array} [pricesheets] Price sheet + * @member {string} [nextLink] The link (url) to the next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of PriceSheetResult + * + * @returns {object} metadata of PriceSheetResult + * + */ + mapper() { + return { + required: false, + serializedName: 'PriceSheetResult', + type: { + name: 'Composite', + className: 'PriceSheetResult', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + tags: { + required: false, + readOnly: true, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + pricesheets: { + required: false, + readOnly: true, + serializedName: 'properties.pricesheets', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'PriceSheetPropertiesElementType', + type: { + name: 'Composite', + className: 'PriceSheetProperties' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'properties.nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = PriceSheetResult; diff --git a/lib/services/consumptionManagement/lib/lib/models/proxyResource.js b/lib/services/consumptionManagement/lib/lib/models/proxyResource.js new file mode 100644 index 0000000000..d973e15776 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/proxyResource.js @@ -0,0 +1,85 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * The Resource model definition. + * + * @extends models['BaseResource'] + */ +class ProxyResource extends models['BaseResource'] { + /** + * Create a ProxyResource. + * @member {string} [id] Resource Id. + * @member {string} [name] Resource name. + * @member {string} [type] Resource type. + * @member {string} [eTag] eTag of the resource. To handle concurrent update + * scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ProxyResource + * + * @returns {object} metadata of ProxyResource + * + */ + mapper() { + return { + required: false, + serializedName: 'ProxyResource', + type: { + name: 'Composite', + className: 'ProxyResource', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + eTag: { + required: false, + serializedName: 'eTag', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ProxyResource; diff --git a/lib/services/consumptionManagement/lib/lib/models/queryOptions.js b/lib/services/consumptionManagement/lib/lib/models/queryOptions.js new file mode 100644 index 0000000000..f06ccd1be2 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/queryOptions.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Additional parameters for a set of operations, such as: UsageDetails_list, + * UsageDetails_listByBillingPeriod. + * + */ +class QueryOptions { + /** + * Create a QueryOptions. + * @member {string} [apply] OData apply expression to aggregatie usageDetails + * by tags or (tags and properties/usageStart) + */ + constructor() { + } + + /** + * Defines the metadata of QueryOptions + * + * @returns {object} metadata of QueryOptions + * + */ + mapper() { + return { + required: false, + type: { + name: 'Composite', + className: 'QueryOptions', + modelProperties: { + apply: { + required: false, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = QueryOptions; diff --git a/lib/services/consumptionManagement/lib/lib/models/reservationDetails.js b/lib/services/consumptionManagement/lib/lib/models/reservationDetails.js new file mode 100644 index 0000000000..f0d4a7ba0b --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/reservationDetails.js @@ -0,0 +1,171 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * reservation details resource. + * + * @extends models['Resource'] + */ +class ReservationDetails extends models['Resource'] { + /** + * Create a ReservationDetails. + * @member {string} [reservationOrderId] The reservation order ID is the + * identifier for a reservation purchase. Each reservation order ID + * represents a single purchase transaction. A reservation order contains + * reservations. The reservation order specifies the VM size and region for + * the reservations. + * @member {string} [reservationId] The reservation ID is the identifier of a + * reservation within a reservation order. Each reservation is the grouping + * for applying the benefit scope and also specifies the number of instances + * to which the reservation benefit can be applied to. + * @member {string} [skuName] This is the ARM Sku name. It can be used to + * join with the servicetype field in additoinalinfo in usage records. + * @member {number} [reservedHours] This is the total hours reserved for the + * day. E.g. if reservation for 1 instance was made on 1 PM, this will be 11 + * hours for that day and 24 hours from subsequent days. + * @member {date} [usageDate] The date on which consumption occurred. + * @member {number} [usedHours] This is the total hours used by the instance. + * @member {string} [instanceId] This identifier is the name of the resource + * or the fully qualified Resource ID. + * @member {number} [totalReservedQuantity] This is the total count of + * instances that are reserved for the reservationid. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ReservationDetails + * + * @returns {object} metadata of ReservationDetails + * + */ + mapper() { + return { + required: false, + serializedName: 'ReservationDetails', + type: { + name: 'Composite', + className: 'ReservationDetails', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + tags: { + required: false, + readOnly: true, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + reservationOrderId: { + required: false, + readOnly: true, + serializedName: 'properties.reservationOrderId', + type: { + name: 'String' + } + }, + reservationId: { + required: false, + readOnly: true, + serializedName: 'properties.reservationId', + type: { + name: 'String' + } + }, + skuName: { + required: false, + readOnly: true, + serializedName: 'properties.skuName', + type: { + name: 'String' + } + }, + reservedHours: { + required: false, + readOnly: true, + serializedName: 'properties.reservedHours', + type: { + name: 'Number' + } + }, + usageDate: { + required: false, + readOnly: true, + serializedName: 'properties.usageDate', + type: { + name: 'DateTime' + } + }, + usedHours: { + required: false, + readOnly: true, + serializedName: 'properties.usedHours', + type: { + name: 'Number' + } + }, + instanceId: { + required: false, + readOnly: true, + serializedName: 'properties.instanceId', + type: { + name: 'String' + } + }, + totalReservedQuantity: { + required: false, + readOnly: true, + serializedName: 'properties.totalReservedQuantity', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = ReservationDetails; diff --git a/lib/services/consumptionManagement/lib/lib/models/reservationDetailsListResult.js b/lib/services/consumptionManagement/lib/lib/models/reservationDetailsListResult.js new file mode 100644 index 0000000000..2e81e65d1a --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/reservationDetailsListResult.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Result of listing reservation details. + */ +class ReservationDetailsListResult extends Array { + /** + * Create a ReservationDetailsListResult. + * @member {string} [nextLink] The link (url) to the next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ReservationDetailsListResult + * + * @returns {object} metadata of ReservationDetailsListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'ReservationDetailsListResult', + type: { + name: 'Composite', + className: 'ReservationDetailsListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ReservationDetailsElementType', + type: { + name: 'Composite', + className: 'ReservationDetails' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ReservationDetailsListResult; diff --git a/lib/services/consumptionManagement/lib/lib/models/reservationRecommendations.js b/lib/services/consumptionManagement/lib/lib/models/reservationRecommendations.js new file mode 100644 index 0000000000..f6c37b78a0 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/reservationRecommendations.js @@ -0,0 +1,191 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Reservation recommendations resource. + * + */ +class ReservationRecommendations { + /** + * Create a ReservationRecommendations. + * @member {string} [id] Resource Id. + * @member {string} [name] Resource name. + * @member {string} [type] Resource type. + * @member {object} [tags] Resource tags. + * @member {string} [location] Resource location + * @member {string} [sku] Resource sku + * @member {string} [lookBackPeriod] The number of days of usage to look back + * for recommendations. + * @member {uuid} [meterId] The meter id (GUID) + * @member {string} [term] RI recommendations in one or three year terms. + * @member {number} [costWithNoReservedInstances] The total amount of cost + * without reserved instances. + * @member {number} [recommendedQuantity] Recomended quality for reserved + * instances. + * @member {number} [totalCostWithReservedInstances] The total amount of cost + * with reserved instances. + * @member {number} [netSavings] Total estimated savings with reserved + * instances. + * @member {date} [firstUsageDate] The usage date for looking back. + * @member {string} [scope] Shared or single recommendation. + */ + constructor() { + } + + /** + * Defines the metadata of ReservationRecommendations + * + * @returns {object} metadata of ReservationRecommendations + * + */ + mapper() { + return { + required: false, + serializedName: 'ReservationRecommendations', + type: { + name: 'Composite', + className: 'ReservationRecommendations', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + tags: { + required: false, + readOnly: true, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + location: { + required: false, + readOnly: true, + serializedName: 'location', + type: { + name: 'String' + } + }, + sku: { + required: false, + readOnly: true, + serializedName: 'sku', + type: { + name: 'String' + } + }, + lookBackPeriod: { + required: false, + readOnly: true, + serializedName: 'properties.lookBackPeriod', + type: { + name: 'String' + } + }, + meterId: { + required: false, + readOnly: true, + serializedName: 'properties.meterId', + type: { + name: 'String' + } + }, + term: { + required: false, + readOnly: true, + serializedName: 'properties.term', + type: { + name: 'String' + } + }, + costWithNoReservedInstances: { + required: false, + readOnly: true, + serializedName: 'properties.costWithNoReservedInstances', + type: { + name: 'Number' + } + }, + recommendedQuantity: { + required: false, + readOnly: true, + serializedName: 'properties.recommendedQuantity', + type: { + name: 'Number' + } + }, + totalCostWithReservedInstances: { + required: false, + readOnly: true, + serializedName: 'properties.totalCostWithReservedInstances', + type: { + name: 'Number' + } + }, + netSavings: { + required: false, + readOnly: true, + serializedName: 'properties.netSavings', + type: { + name: 'Number' + } + }, + firstUsageDate: { + required: false, + readOnly: true, + serializedName: 'properties.firstUsageDate', + type: { + name: 'DateTime' + } + }, + scope: { + required: false, + readOnly: true, + serializedName: 'properties.scope', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ReservationRecommendations; diff --git a/lib/services/consumptionManagement/lib/lib/models/reservationRecommendationsListResult.js b/lib/services/consumptionManagement/lib/lib/models/reservationRecommendationsListResult.js new file mode 100644 index 0000000000..b7529c060d --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/reservationRecommendationsListResult.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Result of listing reservation recommendations. + */ +class ReservationRecommendationsListResult extends Array { + /** + * Create a ReservationRecommendationsListResult. + * @member {string} [nextLink] The link (url) to the next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ReservationRecommendationsListResult + * + * @returns {object} metadata of ReservationRecommendationsListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'ReservationRecommendationsListResult', + type: { + name: 'Composite', + className: 'ReservationRecommendationsListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ReservationRecommendationsElementType', + type: { + name: 'Composite', + className: 'ReservationRecommendations' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ReservationRecommendationsListResult; diff --git a/lib/services/consumptionManagement/lib/lib/models/reservationSummaries.js b/lib/services/consumptionManagement/lib/lib/models/reservationSummaries.js new file mode 100644 index 0000000000..89f199afa5 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/reservationSummaries.js @@ -0,0 +1,186 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * reservation summaries resource. + * + * @extends models['Resource'] + */ +class ReservationSummaries extends models['Resource'] { + /** + * Create a ReservationSummaries. + * @member {string} [reservationOrderId] The reservation order ID is the + * identifier for a reservation purchase. Each reservation order ID + * represents a single purchase transaction. A reservation order contains + * reservations. The reservation order specifies the VM size and region for + * the reservations. + * @member {string} [reservationId] The reservation ID is the identifier of a + * reservation within a reservation order. Each reservation is the grouping + * for applying the benefit scope and also specifies the number of instances + * to which the reservation benefit can be applied to. + * @member {string} [skuName] This is the ARM Sku name. It can be used to + * join with the servicetype field in additoinalinfo in usage records. + * @member {number} [reservedHours] This is the total hours reserved. E.g. if + * reservation for 1 instance was made on 1 PM, this will be 11 hours for + * that day and 24 hours from subsequent days + * @member {date} [usageDate] Data corresponding to the utilization record. + * If the grain of data is monthly, it will be first day of month. + * @member {number} [usedHours] Total used hours by the reservation + * @member {number} [minUtilizationPercentage] This is the minimum hourly + * utilization in the usage time (day or month). E.g. if usage record + * corresponds to 12/10/2017 and on that for hour 4 and 5, utilization was + * 10%, this field will return 10% for that day + * @member {number} [avgUtilizationPercentage] This is average utilization + * for the entire time range. (day or month depending on the grain) + * @member {number} [maxUtilizationPercentage] This is the maximum hourly + * utilization in the usage time (day or month). E.g. if usage record + * corresponds to 12/10/2017 and on that for hour 4 and 5, utilization was + * 100%, this field will return 100% for that day. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ReservationSummaries + * + * @returns {object} metadata of ReservationSummaries + * + */ + mapper() { + return { + required: false, + serializedName: 'ReservationSummaries', + type: { + name: 'Composite', + className: 'ReservationSummaries', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + tags: { + required: false, + readOnly: true, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + reservationOrderId: { + required: false, + readOnly: true, + serializedName: 'properties.reservationOrderId', + type: { + name: 'String' + } + }, + reservationId: { + required: false, + readOnly: true, + serializedName: 'properties.reservationId', + type: { + name: 'String' + } + }, + skuName: { + required: false, + readOnly: true, + serializedName: 'properties.skuName', + type: { + name: 'String' + } + }, + reservedHours: { + required: false, + readOnly: true, + serializedName: 'properties.reservedHours', + type: { + name: 'Number' + } + }, + usageDate: { + required: false, + readOnly: true, + serializedName: 'properties.usageDate', + type: { + name: 'DateTime' + } + }, + usedHours: { + required: false, + readOnly: true, + serializedName: 'properties.usedHours', + type: { + name: 'Number' + } + }, + minUtilizationPercentage: { + required: false, + readOnly: true, + serializedName: 'properties.minUtilizationPercentage', + type: { + name: 'Number' + } + }, + avgUtilizationPercentage: { + required: false, + readOnly: true, + serializedName: 'properties.avgUtilizationPercentage', + type: { + name: 'Number' + } + }, + maxUtilizationPercentage: { + required: false, + readOnly: true, + serializedName: 'properties.maxUtilizationPercentage', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = ReservationSummaries; diff --git a/lib/services/consumptionManagement/lib/lib/models/reservationSummariesListResult.js b/lib/services/consumptionManagement/lib/lib/models/reservationSummariesListResult.js new file mode 100644 index 0000000000..864c674160 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/reservationSummariesListResult.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Result of listing reservation summaries. + */ +class ReservationSummariesListResult extends Array { + /** + * Create a ReservationSummariesListResult. + * @member {string} [nextLink] The link (url) to the next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ReservationSummariesListResult + * + * @returns {object} metadata of ReservationSummariesListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'ReservationSummariesListResult', + type: { + name: 'Composite', + className: 'ReservationSummariesListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ReservationSummariesElementType', + type: { + name: 'Composite', + className: 'ReservationSummaries' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ReservationSummariesListResult; diff --git a/lib/services/consumptionManagement/lib/lib/models/resource.js b/lib/services/consumptionManagement/lib/lib/models/resource.js new file mode 100644 index 0000000000..036218624c --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/resource.js @@ -0,0 +1,91 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * The Resource model definition. + * + * @extends models['BaseResource'] + */ +class Resource extends models['BaseResource'] { + /** + * Create a Resource. + * @member {string} [id] Resource Id. + * @member {string} [name] Resource name. + * @member {string} [type] Resource type. + * @member {object} [tags] Resource tags. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Resource + * + * @returns {object} metadata of Resource + * + */ + mapper() { + return { + required: false, + serializedName: 'Resource', + type: { + name: 'Composite', + className: 'Resource', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + tags: { + required: false, + readOnly: true, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = Resource; diff --git a/lib/services/consumptionManagement/lib/lib/models/resourceAttributes.js b/lib/services/consumptionManagement/lib/lib/models/resourceAttributes.js new file mode 100644 index 0000000000..68350e7d44 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/resourceAttributes.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The Resource model definition. + * + */ +class ResourceAttributes { + /** + * Create a ResourceAttributes. + * @member {string} [location] Resource location + * @member {string} [sku] Resource sku + */ + constructor() { + } + + /** + * Defines the metadata of ResourceAttributes + * + * @returns {object} metadata of ResourceAttributes + * + */ + mapper() { + return { + required: false, + serializedName: 'ResourceAttributes', + type: { + name: 'Composite', + className: 'ResourceAttributes', + modelProperties: { + location: { + required: false, + readOnly: true, + serializedName: 'location', + type: { + name: 'String' + } + }, + sku: { + required: false, + readOnly: true, + serializedName: 'sku', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ResourceAttributes; diff --git a/lib/services/consumptionManagement/lib/lib/models/usageDetail.js b/lib/services/consumptionManagement/lib/lib/models/usageDetail.js new file mode 100644 index 0000000000..787e10d164 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/usageDetail.js @@ -0,0 +1,311 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * An usage detail resource. + * + * @extends models['Resource'] + */ +class UsageDetail extends models['Resource'] { + /** + * Create a UsageDetail. + * @member {string} [billingPeriodId] The id of the billing period resource + * that the usage belongs to. + * @member {string} [invoiceId] The id of the invoice resource that the usage + * belongs to. + * @member {date} [usageStart] The start of the date time range covered by + * the usage detail. + * @member {date} [usageEnd] The end of the date time range covered by the + * usage detail. + * @member {string} [instanceName] The name of the resource instance that the + * usage is about. + * @member {string} [instanceId] The uri of the resource instance that the + * usage is about. + * @member {string} [instanceLocation] The location of the resource instance + * that the usage is about. + * @member {string} [currency] The ISO currency in which the meter is + * charged, for example, USD. + * @member {number} [usageQuantity] The quantity of usage. + * @member {number} [billableQuantity] The billable usage quantity. + * @member {number} [pretaxCost] The amount of cost before tax. + * @member {boolean} [isEstimated] The estimated usage is subject to change. + * @member {uuid} [meterId] The meter id (GUID). + * @member {object} [meterDetails] The details about the meter. By default + * this is not populated, unless it's specified in $expand. + * @member {string} [meterDetails.meterName] The name of the meter, within + * the given meter category + * @member {string} [meterDetails.meterCategory] The category of the meter, + * for example, 'Cloud services', 'Networking', etc.. + * @member {string} [meterDetails.meterSubCategory] The subcategory of the + * meter, for example, 'A6 Cloud services', 'ExpressRoute (IXP)', etc.. + * @member {string} [meterDetails.unit] The unit in which the meter + * consumption is charged, for example, 'Hours', 'GB', etc. + * @member {string} [meterDetails.meterLocation] The location in which the + * Azure service is available. + * @member {number} [meterDetails.totalIncludedQuantity] The total included + * quantity associated with the offer. + * @member {number} [meterDetails.pretaxStandardRate] The pretax listing + * price. + * @member {uuid} [subscriptionGuid] Subscription guid. + * @member {string} [subscriptionName] Subscription name. + * @member {string} [accountName] Account name. + * @member {string} [departmentName] Department name. + * @member {string} [product] Product name. + * @member {string} [consumedService] Consumed service name. + * @member {string} [costCenter] The cost center of this department if it is + * a department and a costcenter exists + * @member {string} [additionalProperties] Additional details of this usage + * item. By default this is not populated, unless it's specified in $expand. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of UsageDetail + * + * @returns {object} metadata of UsageDetail + * + */ + mapper() { + return { + required: false, + serializedName: 'UsageDetail', + type: { + name: 'Composite', + className: 'UsageDetail', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + tags: { + required: false, + readOnly: true, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + billingPeriodId: { + required: false, + readOnly: true, + serializedName: 'properties.billingPeriodId', + type: { + name: 'String' + } + }, + invoiceId: { + required: false, + readOnly: true, + serializedName: 'properties.invoiceId', + type: { + name: 'String' + } + }, + usageStart: { + required: false, + readOnly: true, + serializedName: 'properties.usageStart', + type: { + name: 'DateTime' + } + }, + usageEnd: { + required: false, + readOnly: true, + serializedName: 'properties.usageEnd', + type: { + name: 'DateTime' + } + }, + instanceName: { + required: false, + readOnly: true, + serializedName: 'properties.instanceName', + type: { + name: 'String' + } + }, + instanceId: { + required: false, + readOnly: true, + serializedName: 'properties.instanceId', + type: { + name: 'String' + } + }, + instanceLocation: { + required: false, + readOnly: true, + serializedName: 'properties.instanceLocation', + type: { + name: 'String' + } + }, + currency: { + required: false, + readOnly: true, + serializedName: 'properties.currency', + type: { + name: 'String' + } + }, + usageQuantity: { + required: false, + readOnly: true, + serializedName: 'properties.usageQuantity', + type: { + name: 'Number' + } + }, + billableQuantity: { + required: false, + readOnly: true, + serializedName: 'properties.billableQuantity', + type: { + name: 'Number' + } + }, + pretaxCost: { + required: false, + readOnly: true, + serializedName: 'properties.pretaxCost', + type: { + name: 'Number' + } + }, + isEstimated: { + required: false, + readOnly: true, + serializedName: 'properties.isEstimated', + type: { + name: 'Boolean' + } + }, + meterId: { + required: false, + readOnly: true, + serializedName: 'properties.meterId', + type: { + name: 'String' + } + }, + meterDetails: { + required: false, + readOnly: true, + serializedName: 'properties.meterDetails', + type: { + name: 'Composite', + className: 'MeterDetails' + } + }, + subscriptionGuid: { + required: false, + readOnly: true, + serializedName: 'properties.subscriptionGuid', + type: { + name: 'String' + } + }, + subscriptionName: { + required: false, + readOnly: true, + serializedName: 'properties.subscriptionName', + type: { + name: 'String' + } + }, + accountName: { + required: false, + readOnly: true, + serializedName: 'properties.accountName', + type: { + name: 'String' + } + }, + departmentName: { + required: false, + readOnly: true, + serializedName: 'properties.departmentName', + type: { + name: 'String' + } + }, + product: { + required: false, + readOnly: true, + serializedName: 'properties.product', + type: { + name: 'String' + } + }, + consumedService: { + required: false, + readOnly: true, + serializedName: 'properties.consumedService', + type: { + name: 'String' + } + }, + costCenter: { + required: false, + readOnly: true, + serializedName: 'properties.costCenter', + type: { + name: 'String' + } + }, + additionalProperties: { + required: false, + readOnly: true, + serializedName: 'properties.additionalProperties', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = UsageDetail; diff --git a/lib/services/consumptionManagement/lib/lib/models/usageDetailsListResult.js b/lib/services/consumptionManagement/lib/lib/models/usageDetailsListResult.js new file mode 100644 index 0000000000..1f13ad662f --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/models/usageDetailsListResult.js @@ -0,0 +1,70 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Result of listing usage details. It contains a list of available usage + * details in reverse chronological order by billing period. + */ +class UsageDetailsListResult extends Array { + /** + * Create a UsageDetailsListResult. + * @member {string} [nextLink] The link (url) to the next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of UsageDetailsListResult + * + * @returns {object} metadata of UsageDetailsListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'UsageDetailsListResult', + type: { + name: 'Composite', + className: 'UsageDetailsListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'UsageDetailElementType', + type: { + name: 'Composite', + className: 'UsageDetail' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = UsageDetailsListResult; diff --git a/lib/services/consumptionManagement/lib/lib/operations/budgets.js b/lib/services/consumptionManagement/lib/lib/operations/budgets.js new file mode 100644 index 0000000000..d6fb7a1f58 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/operations/budgets.js @@ -0,0 +1,2571 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists all budgets for a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link BudgetsListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Consumption/budgets'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['BudgetsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists all budgets for a resource group under a subscription. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link BudgetsListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByResourceGroupName(resourceGroupName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Consumption/budgets'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['BudgetsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets the budget for a subscription by budget name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Budget} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(budgetName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (budgetName === null || budgetName === undefined || typeof budgetName.valueOf() !== 'string') { + throw new Error('budgetName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Consumption/budgets/{budgetName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{budgetName}', encodeURIComponent(budgetName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Budget']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * The operation to create or update a budget. Update operation requires latest + * eTag to be set in the request mandatorily. You may obtain the latest eTag by + * performing a get operation. Create operation does not require eTag. + * + * @param {string} budgetName Budget Name. + * + * @param {object} parameters Parameters supplied to the Create Budget + * operation. + * + * @param {string} parameters.category The category of the budget, whether the + * budget tracks cost or usage. Possible values include: 'Cost', 'Usage' + * + * @param {number} parameters.amount The total amount of cost to track with the + * budget + * + * @param {string} parameters.timeGrain The time covered by a budget. Tracking + * of the amount will be reset based on the time grain. Possible values + * include: 'Monthly', 'Quarterly', 'Annually' + * + * @param {object} parameters.timePeriod Has start and end date of the budget. + * The start date must be first of the month and should be less than the end + * date. Budget start date must be on or after June 1, 2017. Future start date + * should not be more than three months. Past start date should be selected + * within the timegrain preiod. There are no restrictions on the end date. + * + * @param {date} parameters.timePeriod.startDate The start date for the budget. + * + * @param {date} [parameters.timePeriod.endDate] The end date for the budget. + * If not provided, we default this to 10 years from the start date. + * + * @param {object} [parameters.filters] May be used to filter budgets by + * resource group, resource, or meter. + * + * @param {array} [parameters.filters.resourceGroups] The list of filters on + * resource groups, allowed at subscription level only. + * + * @param {array} [parameters.filters.resources] The list of filters on + * resources. + * + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. + * + * @param {object} [parameters.notifications] Dictionary of notifications + * associated with the budget. Budget can have up to five notifications. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Budget} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(budgetName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (budgetName === null || budgetName === undefined || typeof budgetName.valueOf() !== 'string') { + throw new Error('budgetName cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Consumption/budgets/{budgetName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{budgetName}', encodeURIComponent(budgetName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['Budget']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Budget']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Budget']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * The operation to delete a budget. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(budgetName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (budgetName === null || budgetName === undefined || typeof budgetName.valueOf() !== 'string') { + throw new Error('budgetName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Consumption/budgets/{budgetName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{budgetName}', encodeURIComponent(budgetName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets the budget for a resource group under a subscription by budget name. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Budget} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _getByResourceGroupName(resourceGroupName, budgetName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (budgetName === null || budgetName === undefined || typeof budgetName.valueOf() !== 'string') { + throw new Error('budgetName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Consumption/budgets/{budgetName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{budgetName}', encodeURIComponent(budgetName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Budget']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * The operation to create or update a budget. Update operation requires latest + * eTag to be set in the request mandatorily. You may obtain the latest eTag by + * performing a get operation. Create operation does not require eTag. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} parameters Parameters supplied to the Create Budget + * operation. + * + * @param {string} parameters.category The category of the budget, whether the + * budget tracks cost or usage. Possible values include: 'Cost', 'Usage' + * + * @param {number} parameters.amount The total amount of cost to track with the + * budget + * + * @param {string} parameters.timeGrain The time covered by a budget. Tracking + * of the amount will be reset based on the time grain. Possible values + * include: 'Monthly', 'Quarterly', 'Annually' + * + * @param {object} parameters.timePeriod Has start and end date of the budget. + * The start date must be first of the month and should be less than the end + * date. Budget start date must be on or after June 1, 2017. Future start date + * should not be more than three months. Past start date should be selected + * within the timegrain preiod. There are no restrictions on the end date. + * + * @param {date} parameters.timePeriod.startDate The start date for the budget. + * + * @param {date} [parameters.timePeriod.endDate] The end date for the budget. + * If not provided, we default this to 10 years from the start date. + * + * @param {object} [parameters.filters] May be used to filter budgets by + * resource group, resource, or meter. + * + * @param {array} [parameters.filters.resourceGroups] The list of filters on + * resource groups, allowed at subscription level only. + * + * @param {array} [parameters.filters.resources] The list of filters on + * resources. + * + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. + * + * @param {object} [parameters.notifications] Dictionary of notifications + * associated with the budget. Budget can have up to five notifications. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Budget} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdateByResourceGroupName(resourceGroupName, budgetName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (budgetName === null || budgetName === undefined || typeof budgetName.valueOf() !== 'string') { + throw new Error('budgetName cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Consumption/budgets/{budgetName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{budgetName}', encodeURIComponent(budgetName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['Budget']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Budget']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Budget']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * The operation to delete a budget. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteByResourceGroupName(resourceGroupName, budgetName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (budgetName === null || budgetName === undefined || typeof budgetName.valueOf() !== 'string') { + throw new Error('budgetName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Consumption/budgets/{budgetName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{budgetName}', encodeURIComponent(budgetName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists all budgets for a subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link BudgetsListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['BudgetsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists all budgets for a resource group under a subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link BudgetsListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByResourceGroupNameNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['BudgetsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a Budgets. */ +class Budgets { + /** + * Create a Budgets. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listByResourceGroupName = _listByResourceGroupName; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + this._deleteMethod = _deleteMethod; + this._getByResourceGroupName = _getByResourceGroupName; + this._createOrUpdateByResourceGroupName = _createOrUpdateByResourceGroupName; + this._deleteByResourceGroupName = _deleteByResourceGroupName; + this._listNext = _listNext; + this._listByResourceGroupNameNext = _listByResourceGroupNameNext; + } + + /** + * Lists all budgets for a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all budgets for a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {BudgetsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link BudgetsListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(options, optionalCallback); + } + } + + /** + * Lists all budgets for a resource group under a subscription. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByResourceGroupNameWithHttpOperationResponse(resourceGroupName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByResourceGroupName(resourceGroupName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all budgets for a resource group under a subscription. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {BudgetsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link BudgetsListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByResourceGroupName(resourceGroupName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByResourceGroupName(resourceGroupName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByResourceGroupName(resourceGroupName, options, optionalCallback); + } + } + + /** + * Gets the budget for a subscription by budget name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(budgetName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(budgetName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the budget for a subscription by budget name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Budget} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Budget} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(budgetName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(budgetName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(budgetName, options, optionalCallback); + } + } + + /** + * The operation to create or update a budget. Update operation requires latest + * eTag to be set in the request mandatorily. You may obtain the latest eTag by + * performing a get operation. Create operation does not require eTag. + * + * @param {string} budgetName Budget Name. + * + * @param {object} parameters Parameters supplied to the Create Budget + * operation. + * + * @param {string} parameters.category The category of the budget, whether the + * budget tracks cost or usage. Possible values include: 'Cost', 'Usage' + * + * @param {number} parameters.amount The total amount of cost to track with the + * budget + * + * @param {string} parameters.timeGrain The time covered by a budget. Tracking + * of the amount will be reset based on the time grain. Possible values + * include: 'Monthly', 'Quarterly', 'Annually' + * + * @param {object} parameters.timePeriod Has start and end date of the budget. + * The start date must be first of the month and should be less than the end + * date. Budget start date must be on or after June 1, 2017. Future start date + * should not be more than three months. Past start date should be selected + * within the timegrain preiod. There are no restrictions on the end date. + * + * @param {date} parameters.timePeriod.startDate The start date for the budget. + * + * @param {date} [parameters.timePeriod.endDate] The end date for the budget. + * If not provided, we default this to 10 years from the start date. + * + * @param {object} [parameters.filters] May be used to filter budgets by + * resource group, resource, or meter. + * + * @param {array} [parameters.filters.resourceGroups] The list of filters on + * resource groups, allowed at subscription level only. + * + * @param {array} [parameters.filters.resources] The list of filters on + * resources. + * + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. + * + * @param {object} [parameters.notifications] Dictionary of notifications + * associated with the budget. Budget can have up to five notifications. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createOrUpdateWithHttpOperationResponse(budgetName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(budgetName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * The operation to create or update a budget. Update operation requires latest + * eTag to be set in the request mandatorily. You may obtain the latest eTag by + * performing a get operation. Create operation does not require eTag. + * + * @param {string} budgetName Budget Name. + * + * @param {object} parameters Parameters supplied to the Create Budget + * operation. + * + * @param {string} parameters.category The category of the budget, whether the + * budget tracks cost or usage. Possible values include: 'Cost', 'Usage' + * + * @param {number} parameters.amount The total amount of cost to track with the + * budget + * + * @param {string} parameters.timeGrain The time covered by a budget. Tracking + * of the amount will be reset based on the time grain. Possible values + * include: 'Monthly', 'Quarterly', 'Annually' + * + * @param {object} parameters.timePeriod Has start and end date of the budget. + * The start date must be first of the month and should be less than the end + * date. Budget start date must be on or after June 1, 2017. Future start date + * should not be more than three months. Past start date should be selected + * within the timegrain preiod. There are no restrictions on the end date. + * + * @param {date} parameters.timePeriod.startDate The start date for the budget. + * + * @param {date} [parameters.timePeriod.endDate] The end date for the budget. + * If not provided, we default this to 10 years from the start date. + * + * @param {object} [parameters.filters] May be used to filter budgets by + * resource group, resource, or meter. + * + * @param {array} [parameters.filters.resourceGroups] The list of filters on + * resource groups, allowed at subscription level only. + * + * @param {array} [parameters.filters.resources] The list of filters on + * resources. + * + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. + * + * @param {object} [parameters.notifications] Dictionary of notifications + * associated with the budget. Budget can have up to five notifications. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Budget} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Budget} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(budgetName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(budgetName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(budgetName, parameters, options, optionalCallback); + } + } + + /** + * The operation to delete a budget. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(budgetName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(budgetName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * The operation to delete a budget. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(budgetName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(budgetName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(budgetName, options, optionalCallback); + } + } + + /** + * Gets the budget for a resource group under a subscription by budget name. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getByResourceGroupNameWithHttpOperationResponse(resourceGroupName, budgetName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._getByResourceGroupName(resourceGroupName, budgetName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the budget for a resource group under a subscription by budget name. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Budget} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Budget} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + getByResourceGroupName(resourceGroupName, budgetName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._getByResourceGroupName(resourceGroupName, budgetName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._getByResourceGroupName(resourceGroupName, budgetName, options, optionalCallback); + } + } + + /** + * The operation to create or update a budget. Update operation requires latest + * eTag to be set in the request mandatorily. You may obtain the latest eTag by + * performing a get operation. Create operation does not require eTag. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} parameters Parameters supplied to the Create Budget + * operation. + * + * @param {string} parameters.category The category of the budget, whether the + * budget tracks cost or usage. Possible values include: 'Cost', 'Usage' + * + * @param {number} parameters.amount The total amount of cost to track with the + * budget + * + * @param {string} parameters.timeGrain The time covered by a budget. Tracking + * of the amount will be reset based on the time grain. Possible values + * include: 'Monthly', 'Quarterly', 'Annually' + * + * @param {object} parameters.timePeriod Has start and end date of the budget. + * The start date must be first of the month and should be less than the end + * date. Budget start date must be on or after June 1, 2017. Future start date + * should not be more than three months. Past start date should be selected + * within the timegrain preiod. There are no restrictions on the end date. + * + * @param {date} parameters.timePeriod.startDate The start date for the budget. + * + * @param {date} [parameters.timePeriod.endDate] The end date for the budget. + * If not provided, we default this to 10 years from the start date. + * + * @param {object} [parameters.filters] May be used to filter budgets by + * resource group, resource, or meter. + * + * @param {array} [parameters.filters.resourceGroups] The list of filters on + * resource groups, allowed at subscription level only. + * + * @param {array} [parameters.filters.resources] The list of filters on + * resources. + * + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. + * + * @param {object} [parameters.notifications] Dictionary of notifications + * associated with the budget. Budget can have up to five notifications. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createOrUpdateByResourceGroupNameWithHttpOperationResponse(resourceGroupName, budgetName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdateByResourceGroupName(resourceGroupName, budgetName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * The operation to create or update a budget. Update operation requires latest + * eTag to be set in the request mandatorily. You may obtain the latest eTag by + * performing a get operation. Create operation does not require eTag. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} parameters Parameters supplied to the Create Budget + * operation. + * + * @param {string} parameters.category The category of the budget, whether the + * budget tracks cost or usage. Possible values include: 'Cost', 'Usage' + * + * @param {number} parameters.amount The total amount of cost to track with the + * budget + * + * @param {string} parameters.timeGrain The time covered by a budget. Tracking + * of the amount will be reset based on the time grain. Possible values + * include: 'Monthly', 'Quarterly', 'Annually' + * + * @param {object} parameters.timePeriod Has start and end date of the budget. + * The start date must be first of the month and should be less than the end + * date. Budget start date must be on or after June 1, 2017. Future start date + * should not be more than three months. Past start date should be selected + * within the timegrain preiod. There are no restrictions on the end date. + * + * @param {date} parameters.timePeriod.startDate The start date for the budget. + * + * @param {date} [parameters.timePeriod.endDate] The end date for the budget. + * If not provided, we default this to 10 years from the start date. + * + * @param {object} [parameters.filters] May be used to filter budgets by + * resource group, resource, or meter. + * + * @param {array} [parameters.filters.resourceGroups] The list of filters on + * resource groups, allowed at subscription level only. + * + * @param {array} [parameters.filters.resources] The list of filters on + * resources. + * + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. + * + * @param {object} [parameters.notifications] Dictionary of notifications + * associated with the budget. Budget can have up to five notifications. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Budget} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Budget} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdateByResourceGroupName(resourceGroupName, budgetName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdateByResourceGroupName(resourceGroupName, budgetName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdateByResourceGroupName(resourceGroupName, budgetName, parameters, options, optionalCallback); + } + } + + /** + * The operation to delete a budget. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteByResourceGroupNameWithHttpOperationResponse(resourceGroupName, budgetName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteByResourceGroupName(resourceGroupName, budgetName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * The operation to delete a budget. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteByResourceGroupName(resourceGroupName, budgetName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteByResourceGroupName(resourceGroupName, budgetName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteByResourceGroupName(resourceGroupName, budgetName, options, optionalCallback); + } + } + + /** + * Lists all budgets for a subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all budgets for a subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {BudgetsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link BudgetsListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Lists all budgets for a resource group under a subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByResourceGroupNameNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByResourceGroupNameNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all budgets for a resource group under a subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {BudgetsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link BudgetsListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByResourceGroupNameNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByResourceGroupNameNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByResourceGroupNameNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = Budgets; diff --git a/lib/services/consumptionManagement/lib/lib/operations/costAllocationTagsOperations.js b/lib/services/consumptionManagement/lib/lib/operations/costAllocationTagsOperations.js new file mode 100644 index 0000000000..ddadc0dc3c --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/operations/costAllocationTagsOperations.js @@ -0,0 +1,537 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Get cost allocation tags for a billing account. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link CostAllocationTags} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(billingAccountId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.CostManagement/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/costAllocationTags'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['CostAllocationTags']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * The operation to create or update cost allocation tags assiciated with a + * billing account. Update operation requires latest eTag to be set in the + * request mandatorily. You may obtain the latest eTag by performing a get + * operation. Create operation does not require eTag. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} parameters Parameters supplied to the Create cost allocation + * tags operation. + * + * @param {array} [parameters.costAllocationTags] Cost allocation tags. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link CostAllocationTags} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(billingAccountId, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.CostManagement/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/costAllocationTags'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['CostAllocationTags']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['CostAllocationTags']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['CostAllocationTags']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a CostAllocationTagsOperations. */ +class CostAllocationTagsOperations { + /** + * Create a CostAllocationTagsOperations. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + } + + /** + * Get cost allocation tags for a billing account. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(billingAccountId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get cost allocation tags for a billing account. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {CostAllocationTags} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link CostAllocationTags} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(billingAccountId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(billingAccountId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountId, options, optionalCallback); + } + } + + /** + * The operation to create or update cost allocation tags assiciated with a + * billing account. Update operation requires latest eTag to be set in the + * request mandatorily. You may obtain the latest eTag by performing a get + * operation. Create operation does not require eTag. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} parameters Parameters supplied to the Create cost allocation + * tags operation. + * + * @param {array} [parameters.costAllocationTags] Cost allocation tags. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createOrUpdateWithHttpOperationResponse(billingAccountId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(billingAccountId, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * The operation to create or update cost allocation tags assiciated with a + * billing account. Update operation requires latest eTag to be set in the + * request mandatorily. You may obtain the latest eTag by performing a get + * operation. Create operation does not require eTag. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} parameters Parameters supplied to the Create cost allocation + * tags operation. + * + * @param {array} [parameters.costAllocationTags] Cost allocation tags. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {CostAllocationTags} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link CostAllocationTags} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(billingAccountId, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(billingAccountId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(billingAccountId, parameters, options, optionalCallback); + } + } + +} + +module.exports = CostAllocationTagsOperations; diff --git a/lib/services/consumptionManagement/lib/lib/operations/index.d.ts b/lib/services/consumptionManagement/lib/lib/operations/index.d.ts new file mode 100644 index 0000000000..6835239a43 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/operations/index.d.ts @@ -0,0 +1,2492 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. +*/ + +import { ServiceClientOptions, RequestOptions, ServiceCallback, HttpOperationResponse } from 'ms-rest'; +import * as models from '../models'; + + +/** + * @class + * UsageDetails + * __NOTE__: An instance of this class is automatically created for an + * instance of the ConsumptionManagementClient. + */ +export interface UsageDetails { + + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregatie usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregatie usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregatie usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByBillingPeriodWithHttpOperationResponse(billingPeriodName: string, options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregatie usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriod(billingPeriodName: string, options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise; + listByBillingPeriod(billingPeriodName: string, callback: ServiceCallback): void; + listByBillingPeriod(billingPeriodName: string, options: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextPageLink: string, callback: ServiceCallback): void; + listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByBillingPeriodNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriodNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByBillingPeriodNext(nextPageLink: string, callback: ServiceCallback): void; + listByBillingPeriodNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * Marketplaces + * __NOTE__: An instance of this class is automatically created for an + * instance of the ConsumptionManagementClient. + */ +export interface Marketplaces { + + + /** + * Lists the marketplaces for a scope by subscriptionId. Marketplaces are + * available via this API only for May 1, 2014 or later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the marketplaces for a scope by subscriptionId. Marketplaces are + * available via this API only for May 1, 2014 or later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the marketplaces for a scope by billing period and subscripotionId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByBillingPeriodWithHttpOperationResponse(billingPeriodName: string, options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the marketplaces for a scope by billing period and subscripotionId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriod(billingPeriodName: string, options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + listByBillingPeriod(billingPeriodName: string, callback: ServiceCallback): void; + listByBillingPeriod(billingPeriodName: string, options: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the marketplaces for a scope by subscriptionId. Marketplaces are + * available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the marketplaces for a scope by subscriptionId. Marketplaces are + * available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextPageLink: string, callback: ServiceCallback): void; + listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the marketplaces for a scope by billing period and subscripotionId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByBillingPeriodNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the marketplaces for a scope by billing period and subscripotionId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriodNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByBillingPeriodNext(nextPageLink: string, callback: ServiceCallback): void; + listByBillingPeriodNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ReservationsSummaries + * __NOTE__: An instance of this class is automatically created for an + * instance of the ConsumptionManagementClient. + */ +export interface ReservationsSummaries { + + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} grain Can be daily or monthly. Possible values include: + * 'DailyGrain', 'MonthlyGrain' + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] Required only for daily grain. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByReservationOrderWithHttpOperationResponse(reservationOrderId: string, grain: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} grain Can be daily or monthly. Possible values include: + * 'DailyGrain', 'MonthlyGrain' + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] Required only for daily grain. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ReservationSummariesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ReservationSummariesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationSummariesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrder(reservationOrderId: string, grain: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + listByReservationOrder(reservationOrderId: string, grain: string, callback: ServiceCallback): void; + listByReservationOrder(reservationOrderId: string, grain: string, options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} reservationId Id of the reservation + * + * @param {string} grain Can be daily or monthly. Possible values include: + * 'DailyGrain', 'MonthlyGrain' + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] Required only for daily grain. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByReservationOrderAndReservationWithHttpOperationResponse(reservationOrderId: string, reservationId: string, grain: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} reservationId Id of the reservation + * + * @param {string} grain Can be daily or monthly. Possible values include: + * 'DailyGrain', 'MonthlyGrain' + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] Required only for daily grain. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ReservationSummariesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ReservationSummariesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationSummariesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrderAndReservation(reservationOrderId: string, reservationId: string, grain: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + listByReservationOrderAndReservation(reservationOrderId: string, reservationId: string, grain: string, callback: ServiceCallback): void; + listByReservationOrderAndReservation(reservationOrderId: string, reservationId: string, grain: string, options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByReservationOrderNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ReservationSummariesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ReservationSummariesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationSummariesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrderNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByReservationOrderNext(nextPageLink: string, callback: ServiceCallback): void; + listByReservationOrderNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByReservationOrderAndReservationNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ReservationSummariesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ReservationSummariesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationSummariesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrderAndReservationNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByReservationOrderAndReservationNext(nextPageLink: string, callback: ServiceCallback): void; + listByReservationOrderAndReservationNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ReservationsDetails + * __NOTE__: An instance of this class is automatically created for an + * instance of the ConsumptionManagementClient. + */ +export interface ReservationsDetails { + + + /** + * Lists the reservations details for provided date range. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} filter Filter reservation details by date range. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByReservationOrderWithHttpOperationResponse(reservationOrderId: string, filter: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the reservations details for provided date range. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} filter Filter reservation details by date range. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ReservationDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ReservationDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrder(reservationOrderId: string, filter: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByReservationOrder(reservationOrderId: string, filter: string, callback: ServiceCallback): void; + listByReservationOrder(reservationOrderId: string, filter: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the reservations details for provided date range. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} reservationId Id of the reservation + * + * @param {string} filter Filter reservation details by date range. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByReservationOrderAndReservationWithHttpOperationResponse(reservationOrderId: string, reservationId: string, filter: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the reservations details for provided date range. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} reservationId Id of the reservation + * + * @param {string} filter Filter reservation details by date range. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ReservationDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ReservationDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrderAndReservation(reservationOrderId: string, reservationId: string, filter: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByReservationOrderAndReservation(reservationOrderId: string, reservationId: string, filter: string, callback: ServiceCallback): void; + listByReservationOrderAndReservation(reservationOrderId: string, reservationId: string, filter: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the reservations details for provided date range. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByReservationOrderNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the reservations details for provided date range. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ReservationDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ReservationDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrderNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByReservationOrderNext(nextPageLink: string, callback: ServiceCallback): void; + listByReservationOrderNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the reservations details for provided date range. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByReservationOrderAndReservationNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the reservations details for provided date range. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ReservationDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ReservationDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrderAndReservationNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByReservationOrderAndReservationNext(nextPageLink: string, callback: ServiceCallback): void; + listByReservationOrderAndReservationNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ReservationRecommendationsOperations + * __NOTE__: An instance of this class is automatically created for an + * instance of the ConsumptionManagementClient. + */ +export interface ReservationRecommendationsOperations { + + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter + * reservationRecommendations by properties/scope and + * properties/lookBackPeriod. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter + * reservationRecommendations by properties/scope and + * properties/lookBackPeriod. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ReservationRecommendationsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ReservationRecommendationsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationRecommendationsListResult} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ReservationRecommendationsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ReservationRecommendationsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationRecommendationsListResult} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextPageLink: string, callback: ServiceCallback): void; + listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * Budgets + * __NOTE__: An instance of this class is automatically created for an + * instance of the ConsumptionManagementClient. + */ +export interface Budgets { + + + /** + * Lists all budgets for a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all budgets for a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {BudgetsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {BudgetsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BudgetsListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all budgets for a resource group under a subscription. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByResourceGroupNameWithHttpOperationResponse(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all budgets for a resource group under a subscription. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {BudgetsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {BudgetsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BudgetsListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByResourceGroupName(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByResourceGroupName(resourceGroupName: string, callback: ServiceCallback): void; + listByResourceGroupName(resourceGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets the budget for a subscription by budget name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the budget for a subscription by budget name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Budget} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Budget} [result] - The deserialized result object if an error did not occur. + * See {@link Budget} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(budgetName: string, callback: ServiceCallback): void; + get(budgetName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to create or update a budget. Update operation requires latest + * eTag to be set in the request mandatorily. You may obtain the latest eTag by + * performing a get operation. Create operation does not require eTag. + * + * @param {string} budgetName Budget Name. + * + * @param {object} parameters Parameters supplied to the Create Budget + * operation. + * + * @param {string} parameters.category The category of the budget, whether the + * budget tracks cost or usage. Possible values include: 'Cost', 'Usage' + * + * @param {number} parameters.amount The total amount of cost to track with the + * budget + * + * @param {string} parameters.timeGrain The time covered by a budget. Tracking + * of the amount will be reset based on the time grain. Possible values + * include: 'Monthly', 'Quarterly', 'Annually' + * + * @param {object} parameters.timePeriod Has start and end date of the budget. + * The start date must be first of the month and should be less than the end + * date. Budget start date must be on or after June 1, 2017. Future start date + * should not be more than three months. Past start date should be selected + * within the timegrain preiod. There are no restrictions on the end date. + * + * @param {date} parameters.timePeriod.startDate The start date for the budget. + * + * @param {date} [parameters.timePeriod.endDate] The end date for the budget. + * If not provided, we default this to 10 years from the start date. + * + * @param {object} [parameters.filters] May be used to filter budgets by + * resource group, resource, or meter. + * + * @param {array} [parameters.filters.resourceGroups] The list of filters on + * resource groups, allowed at subscription level only. + * + * @param {array} [parameters.filters.resources] The list of filters on + * resources. + * + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. + * + * @param {object} [parameters.notifications] Dictionary of notifications + * associated with the budget. Budget can have up to five notifications. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createOrUpdateWithHttpOperationResponse(budgetName: string, parameters: models.Budget, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to create or update a budget. Update operation requires latest + * eTag to be set in the request mandatorily. You may obtain the latest eTag by + * performing a get operation. Create operation does not require eTag. + * + * @param {string} budgetName Budget Name. + * + * @param {object} parameters Parameters supplied to the Create Budget + * operation. + * + * @param {string} parameters.category The category of the budget, whether the + * budget tracks cost or usage. Possible values include: 'Cost', 'Usage' + * + * @param {number} parameters.amount The total amount of cost to track with the + * budget + * + * @param {string} parameters.timeGrain The time covered by a budget. Tracking + * of the amount will be reset based on the time grain. Possible values + * include: 'Monthly', 'Quarterly', 'Annually' + * + * @param {object} parameters.timePeriod Has start and end date of the budget. + * The start date must be first of the month and should be less than the end + * date. Budget start date must be on or after June 1, 2017. Future start date + * should not be more than three months. Past start date should be selected + * within the timegrain preiod. There are no restrictions on the end date. + * + * @param {date} parameters.timePeriod.startDate The start date for the budget. + * + * @param {date} [parameters.timePeriod.endDate] The end date for the budget. + * If not provided, we default this to 10 years from the start date. + * + * @param {object} [parameters.filters] May be used to filter budgets by + * resource group, resource, or meter. + * + * @param {array} [parameters.filters.resourceGroups] The list of filters on + * resource groups, allowed at subscription level only. + * + * @param {array} [parameters.filters.resources] The list of filters on + * resources. + * + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. + * + * @param {object} [parameters.notifications] Dictionary of notifications + * associated with the budget. Budget can have up to five notifications. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Budget} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Budget} [result] - The deserialized result object if an error did not occur. + * See {@link Budget} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(budgetName: string, parameters: models.Budget, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(budgetName: string, parameters: models.Budget, callback: ServiceCallback): void; + createOrUpdate(budgetName: string, parameters: models.Budget, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to delete a budget. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to delete a budget. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(budgetName: string, callback: ServiceCallback): void; + deleteMethod(budgetName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets the budget for a resource group under a subscription by budget name. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getByResourceGroupNameWithHttpOperationResponse(resourceGroupName: string, budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the budget for a resource group under a subscription by budget name. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Budget} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Budget} [result] - The deserialized result object if an error did not occur. + * See {@link Budget} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + getByResourceGroupName(resourceGroupName: string, budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getByResourceGroupName(resourceGroupName: string, budgetName: string, callback: ServiceCallback): void; + getByResourceGroupName(resourceGroupName: string, budgetName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to create or update a budget. Update operation requires latest + * eTag to be set in the request mandatorily. You may obtain the latest eTag by + * performing a get operation. Create operation does not require eTag. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} parameters Parameters supplied to the Create Budget + * operation. + * + * @param {string} parameters.category The category of the budget, whether the + * budget tracks cost or usage. Possible values include: 'Cost', 'Usage' + * + * @param {number} parameters.amount The total amount of cost to track with the + * budget + * + * @param {string} parameters.timeGrain The time covered by a budget. Tracking + * of the amount will be reset based on the time grain. Possible values + * include: 'Monthly', 'Quarterly', 'Annually' + * + * @param {object} parameters.timePeriod Has start and end date of the budget. + * The start date must be first of the month and should be less than the end + * date. Budget start date must be on or after June 1, 2017. Future start date + * should not be more than three months. Past start date should be selected + * within the timegrain preiod. There are no restrictions on the end date. + * + * @param {date} parameters.timePeriod.startDate The start date for the budget. + * + * @param {date} [parameters.timePeriod.endDate] The end date for the budget. + * If not provided, we default this to 10 years from the start date. + * + * @param {object} [parameters.filters] May be used to filter budgets by + * resource group, resource, or meter. + * + * @param {array} [parameters.filters.resourceGroups] The list of filters on + * resource groups, allowed at subscription level only. + * + * @param {array} [parameters.filters.resources] The list of filters on + * resources. + * + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. + * + * @param {object} [parameters.notifications] Dictionary of notifications + * associated with the budget. Budget can have up to five notifications. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createOrUpdateByResourceGroupNameWithHttpOperationResponse(resourceGroupName: string, budgetName: string, parameters: models.Budget, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to create or update a budget. Update operation requires latest + * eTag to be set in the request mandatorily. You may obtain the latest eTag by + * performing a get operation. Create operation does not require eTag. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} parameters Parameters supplied to the Create Budget + * operation. + * + * @param {string} parameters.category The category of the budget, whether the + * budget tracks cost or usage. Possible values include: 'Cost', 'Usage' + * + * @param {number} parameters.amount The total amount of cost to track with the + * budget + * + * @param {string} parameters.timeGrain The time covered by a budget. Tracking + * of the amount will be reset based on the time grain. Possible values + * include: 'Monthly', 'Quarterly', 'Annually' + * + * @param {object} parameters.timePeriod Has start and end date of the budget. + * The start date must be first of the month and should be less than the end + * date. Budget start date must be on or after June 1, 2017. Future start date + * should not be more than three months. Past start date should be selected + * within the timegrain preiod. There are no restrictions on the end date. + * + * @param {date} parameters.timePeriod.startDate The start date for the budget. + * + * @param {date} [parameters.timePeriod.endDate] The end date for the budget. + * If not provided, we default this to 10 years from the start date. + * + * @param {object} [parameters.filters] May be used to filter budgets by + * resource group, resource, or meter. + * + * @param {array} [parameters.filters.resourceGroups] The list of filters on + * resource groups, allowed at subscription level only. + * + * @param {array} [parameters.filters.resources] The list of filters on + * resources. + * + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. + * + * @param {object} [parameters.notifications] Dictionary of notifications + * associated with the budget. Budget can have up to five notifications. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Budget} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Budget} [result] - The deserialized result object if an error did not occur. + * See {@link Budget} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdateByResourceGroupName(resourceGroupName: string, budgetName: string, parameters: models.Budget, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdateByResourceGroupName(resourceGroupName: string, budgetName: string, parameters: models.Budget, callback: ServiceCallback): void; + createOrUpdateByResourceGroupName(resourceGroupName: string, budgetName: string, parameters: models.Budget, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to delete a budget. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteByResourceGroupNameWithHttpOperationResponse(resourceGroupName: string, budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to delete a budget. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteByResourceGroupName(resourceGroupName: string, budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteByResourceGroupName(resourceGroupName: string, budgetName: string, callback: ServiceCallback): void; + deleteByResourceGroupName(resourceGroupName: string, budgetName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all budgets for a subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all budgets for a subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {BudgetsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {BudgetsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BudgetsListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextPageLink: string, callback: ServiceCallback): void; + listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all budgets for a resource group under a subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByResourceGroupNameNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all budgets for a resource group under a subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {BudgetsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {BudgetsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BudgetsListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByResourceGroupNameNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByResourceGroupNameNext(nextPageLink: string, callback: ServiceCallback): void; + listByResourceGroupNameNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * Operations + * __NOTE__: An instance of this class is automatically created for an + * instance of the ConsumptionManagementClient. + */ +export interface Operations { + + + /** + * Lists all of the available consumption REST API operations. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all of the available consumption REST API operations. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {OperationListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {OperationListResult} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all of the available consumption REST API operations. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all of the available consumption REST API operations. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {OperationListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {OperationListResult} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextPageLink: string, callback: ServiceCallback): void; + listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * PriceSheet + * __NOTE__: An instance of this class is automatically created for an + * instance of the ConsumptionManagementClient. + */ +export interface PriceSheet { + + + /** + * Gets the price sheet for a scope by subscriptionId. Price sheet is available + * via this API only for May 1, 2014 or later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/meterDetails within a price sheet. By default, these fields are + * not included when returning price sheet. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the price sheet for a scope by subscriptionId. Price sheet is available + * via this API only for May 1, 2014 or later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/meterDetails within a price sheet. By default, these fields are + * not included when returning price sheet. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {PriceSheetResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {PriceSheetResult} [result] - The deserialized result object if an error did not occur. + * See {@link PriceSheetResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; + get(callback: ServiceCallback): void; + get(options: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get the price sheet for a scope by subscriptionId and billing period. Price + * sheet is available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/meterDetails within a price sheet. By default, these fields are + * not included when returning price sheet. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getByBillingPeriodWithHttpOperationResponse(billingPeriodName: string, options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the price sheet for a scope by subscriptionId and billing period. Price + * sheet is available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/meterDetails within a price sheet. By default, these fields are + * not included when returning price sheet. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {PriceSheetResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {PriceSheetResult} [result] - The deserialized result object if an error did not occur. + * See {@link PriceSheetResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + getByBillingPeriod(billingPeriodName: string, options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; + getByBillingPeriod(billingPeriodName: string, callback: ServiceCallback): void; + getByBillingPeriod(billingPeriodName: string, options: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * CostAllocationTagsOperations + * __NOTE__: An instance of this class is automatically created for an + * instance of the ConsumptionManagementClient. + */ +export interface CostAllocationTagsOperations { + + + /** + * Get cost allocation tags for a billing account. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(billingAccountId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get cost allocation tags for a billing account. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {CostAllocationTags} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {CostAllocationTags} [result] - The deserialized result object if an error did not occur. + * See {@link CostAllocationTags} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(billingAccountId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountId: string, callback: ServiceCallback): void; + get(billingAccountId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to create or update cost allocation tags assiciated with a + * billing account. Update operation requires latest eTag to be set in the + * request mandatorily. You may obtain the latest eTag by performing a get + * operation. Create operation does not require eTag. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} parameters Parameters supplied to the Create cost allocation + * tags operation. + * + * @param {array} [parameters.costAllocationTags] Cost allocation tags. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createOrUpdateWithHttpOperationResponse(billingAccountId: string, parameters: models.CostAllocationTags, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to create or update cost allocation tags assiciated with a + * billing account. Update operation requires latest eTag to be set in the + * request mandatorily. You may obtain the latest eTag by performing a get + * operation. Create operation does not require eTag. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} parameters Parameters supplied to the Create cost allocation + * tags operation. + * + * @param {array} [parameters.costAllocationTags] Cost allocation tags. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {CostAllocationTags} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {CostAllocationTags} [result] - The deserialized result object if an error did not occur. + * See {@link CostAllocationTags} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(billingAccountId: string, parameters: models.CostAllocationTags, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(billingAccountId: string, parameters: models.CostAllocationTags, callback: ServiceCallback): void; + createOrUpdate(billingAccountId: string, parameters: models.CostAllocationTags, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} diff --git a/lib/services/consumptionManagement/lib/lib/operations/index.js b/lib/services/consumptionManagement/lib/lib/operations/index.js new file mode 100644 index 0000000000..252d834305 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/operations/index.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +exports.UsageDetails = require('./usageDetails'); +exports.Marketplaces = require('./marketplaces'); +exports.ReservationsSummaries = require('./reservationsSummaries'); +exports.ReservationsDetails = require('./reservationsDetails'); +exports.ReservationRecommendationsOperations = require('./reservationRecommendationsOperations'); +exports.Budgets = require('./budgets'); +exports.Operations = require('./operations'); +exports.PriceSheet = require('./priceSheet'); +exports.CostAllocationTagsOperations = require('./costAllocationTagsOperations'); diff --git a/lib/services/consumptionManagement/lib/lib/operations/marketplaces.js b/lib/services/consumptionManagement/lib/lib/operations/marketplaces.js new file mode 100644 index 0000000000..c9313c2057 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/operations/marketplaces.js @@ -0,0 +1,1057 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists the marketplaces for a scope by subscriptionId. Marketplaces are + * available via this API only for May 1, 2014 or later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + // Validate + try { + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Consumption/marketplaces'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the marketplaces for a scope by billing period and subscripotionId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByBillingPeriod(billingPeriodName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + // Validate + try { + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (billingPeriodName === null || billingPeriodName === undefined || typeof billingPeriodName.valueOf() !== 'string') { + throw new Error('billingPeriodName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/marketplaces'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{billingPeriodName}', encodeURIComponent(billingPeriodName)); + let queryParameters = []; + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the marketplaces for a scope by subscriptionId. Marketplaces are + * available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the marketplaces for a scope by billing period and subscripotionId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByBillingPeriodNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a Marketplaces. */ +class Marketplaces { + /** + * Create a Marketplaces. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listByBillingPeriod = _listByBillingPeriod; + this._listNext = _listNext; + this._listByBillingPeriodNext = _listByBillingPeriodNext; + } + + /** + * Lists the marketplaces for a scope by subscriptionId. Marketplaces are + * available via this API only for May 1, 2014 or later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by subscriptionId. Marketplaces are + * available via this API only for May 1, 2014 or later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(options, optionalCallback); + } + } + + /** + * Lists the marketplaces for a scope by billing period and subscripotionId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByBillingPeriodWithHttpOperationResponse(billingPeriodName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingPeriod(billingPeriodName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by billing period and subscripotionId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriod(billingPeriodName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingPeriod(billingPeriodName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingPeriod(billingPeriodName, options, optionalCallback); + } + } + + /** + * Lists the marketplaces for a scope by subscriptionId. Marketplaces are + * available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by subscriptionId. Marketplaces are + * available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Lists the marketplaces for a scope by billing period and subscripotionId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByBillingPeriodNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by billing period and subscripotionId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriodNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingPeriodNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = Marketplaces; diff --git a/lib/services/consumptionManagement/lib/lib/operations/operations.js b/lib/services/consumptionManagement/lib/lib/operations/operations.js new file mode 100644 index 0000000000..4db46bceb3 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/operations/operations.js @@ -0,0 +1,451 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists all of the available consumption REST API operations. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Consumption/operations'; + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['OperationListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists all of the available consumption REST API operations. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['OperationListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a Operations. */ +class Operations { + /** + * Create a Operations. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listNext = _listNext; + } + + /** + * Lists all of the available consumption REST API operations. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all of the available consumption REST API operations. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {OperationListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(options, optionalCallback); + } + } + + /** + * Lists all of the available consumption REST API operations. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all of the available consumption REST API operations. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {OperationListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = Operations; diff --git a/lib/services/consumptionManagement/lib/lib/operations/priceSheet.js b/lib/services/consumptionManagement/lib/lib/operations/priceSheet.js new file mode 100644 index 0000000000..5d9f6a5625 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/operations/priceSheet.js @@ -0,0 +1,605 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets the price sheet for a scope by subscriptionId. Price sheet is available + * via this API only for May 1, 2014 or later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/meterDetails within a price sheet. By default, these fields are + * not included when returning price sheet. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PriceSheetResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + // Validate + try { + if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets/default'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['PriceSheetResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Get the price sheet for a scope by subscriptionId and billing period. Price + * sheet is available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/meterDetails within a price sheet. By default, these fields are + * not included when returning price sheet. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PriceSheetResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _getByBillingPeriod(billingPeriodName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + // Validate + try { + if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (billingPeriodName === null || billingPeriodName === undefined || typeof billingPeriodName.valueOf() !== 'string') { + throw new Error('billingPeriodName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/pricesheets/default'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{billingPeriodName}', encodeURIComponent(billingPeriodName)); + let queryParameters = []; + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['PriceSheetResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a PriceSheet. */ +class PriceSheet { + /** + * Create a PriceSheet. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._getByBillingPeriod = _getByBillingPeriod; + } + + /** + * Gets the price sheet for a scope by subscriptionId. Price sheet is available + * via this API only for May 1, 2014 or later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/meterDetails within a price sheet. By default, these fields are + * not included when returning price sheet. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the price sheet for a scope by subscriptionId. Price sheet is available + * via this API only for May 1, 2014 or later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/meterDetails within a price sheet. By default, these fields are + * not included when returning price sheet. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {PriceSheetResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PriceSheetResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(options, optionalCallback); + } + } + + /** + * Get the price sheet for a scope by subscriptionId and billing period. Price + * sheet is available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/meterDetails within a price sheet. By default, these fields are + * not included when returning price sheet. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getByBillingPeriodWithHttpOperationResponse(billingPeriodName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._getByBillingPeriod(billingPeriodName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get the price sheet for a scope by subscriptionId and billing period. Price + * sheet is available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/meterDetails within a price sheet. By default, these fields are + * not included when returning price sheet. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {PriceSheetResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PriceSheetResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + getByBillingPeriod(billingPeriodName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._getByBillingPeriod(billingPeriodName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._getByBillingPeriod(billingPeriodName, options, optionalCallback); + } + } + +} + +module.exports = PriceSheet; diff --git a/lib/services/consumptionManagement/lib/lib/operations/reservationRecommendationsOperations.js b/lib/services/consumptionManagement/lib/lib/operations/reservationRecommendationsOperations.js new file mode 100644 index 0000000000..08e3905565 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/operations/reservationRecommendationsOperations.js @@ -0,0 +1,478 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * List of recomendations for purchasing reserved instances. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter + * reservationRecommendations by properties/scope and + * properties/lookBackPeriod. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationRecommendationsListResult} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + // Validate + try { + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Consumption/reservationRecommendations'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ReservationRecommendationsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * List of recomendations for purchasing reserved instances. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationRecommendationsListResult} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ReservationRecommendationsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a ReservationRecommendationsOperations. */ +class ReservationRecommendationsOperations { + /** + * Create a ReservationRecommendationsOperations. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listNext = _listNext; + } + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter + * reservationRecommendations by properties/scope and + * properties/lookBackPeriod. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter + * reservationRecommendations by properties/scope and + * properties/lookBackPeriod. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ReservationRecommendationsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationRecommendationsListResult} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(options, optionalCallback); + } + } + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ReservationRecommendationsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationRecommendationsListResult} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = ReservationRecommendationsOperations; diff --git a/lib/services/consumptionManagement/lib/lib/operations/reservationsDetails.js b/lib/services/consumptionManagement/lib/lib/operations/reservationsDetails.js new file mode 100644 index 0000000000..00e73e8c60 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/operations/reservationsDetails.js @@ -0,0 +1,943 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists the reservations details for provided date range. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} filter Filter reservation details by date range. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByReservationOrder(reservationOrderId, filter, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (reservationOrderId === null || reservationOrderId === undefined || typeof reservationOrderId.valueOf() !== 'string') { + throw new Error('reservationOrderId cannot be null or undefined and it must be of type string.'); + } + if (filter === null || filter === undefined || typeof filter.valueOf() !== 'string') { + throw new Error('filter cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationDetails'; + requestUrl = requestUrl.replace('{reservationOrderId}', encodeURIComponent(reservationOrderId)); + let queryParameters = []; + queryParameters.push('$filter=' + encodeURIComponent(filter)); + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ReservationDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the reservations details for provided date range. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} reservationId Id of the reservation + * + * @param {string} filter Filter reservation details by date range. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByReservationOrderAndReservation(reservationOrderId, reservationId, filter, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (reservationOrderId === null || reservationOrderId === undefined || typeof reservationOrderId.valueOf() !== 'string') { + throw new Error('reservationOrderId cannot be null or undefined and it must be of type string.'); + } + if (reservationId === null || reservationId === undefined || typeof reservationId.valueOf() !== 'string') { + throw new Error('reservationId cannot be null or undefined and it must be of type string.'); + } + if (filter === null || filter === undefined || typeof filter.valueOf() !== 'string') { + throw new Error('filter cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationDetails'; + requestUrl = requestUrl.replace('{reservationOrderId}', encodeURIComponent(reservationOrderId)); + requestUrl = requestUrl.replace('{reservationId}', encodeURIComponent(reservationId)); + let queryParameters = []; + queryParameters.push('$filter=' + encodeURIComponent(filter)); + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ReservationDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the reservations details for provided date range. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByReservationOrderNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ReservationDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the reservations details for provided date range. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByReservationOrderAndReservationNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ReservationDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a ReservationsDetails. */ +class ReservationsDetails { + /** + * Create a ReservationsDetails. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._listByReservationOrder = _listByReservationOrder; + this._listByReservationOrderAndReservation = _listByReservationOrderAndReservation; + this._listByReservationOrderNext = _listByReservationOrderNext; + this._listByReservationOrderAndReservationNext = _listByReservationOrderAndReservationNext; + } + + /** + * Lists the reservations details for provided date range. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} filter Filter reservation details by date range. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByReservationOrderWithHttpOperationResponse(reservationOrderId, filter, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByReservationOrder(reservationOrderId, filter, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the reservations details for provided date range. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} filter Filter reservation details by date range. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ReservationDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrder(reservationOrderId, filter, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByReservationOrder(reservationOrderId, filter, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByReservationOrder(reservationOrderId, filter, options, optionalCallback); + } + } + + /** + * Lists the reservations details for provided date range. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} reservationId Id of the reservation + * + * @param {string} filter Filter reservation details by date range. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByReservationOrderAndReservationWithHttpOperationResponse(reservationOrderId, reservationId, filter, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByReservationOrderAndReservation(reservationOrderId, reservationId, filter, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the reservations details for provided date range. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} reservationId Id of the reservation + * + * @param {string} filter Filter reservation details by date range. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ReservationDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrderAndReservation(reservationOrderId, reservationId, filter, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByReservationOrderAndReservation(reservationOrderId, reservationId, filter, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByReservationOrderAndReservation(reservationOrderId, reservationId, filter, options, optionalCallback); + } + } + + /** + * Lists the reservations details for provided date range. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByReservationOrderNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByReservationOrderNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the reservations details for provided date range. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ReservationDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrderNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByReservationOrderNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByReservationOrderNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Lists the reservations details for provided date range. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByReservationOrderAndReservationNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByReservationOrderAndReservationNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the reservations details for provided date range. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ReservationDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrderAndReservationNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByReservationOrderAndReservationNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByReservationOrderAndReservationNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = ReservationsDetails; diff --git a/lib/services/consumptionManagement/lib/lib/operations/reservationsSummaries.js b/lib/services/consumptionManagement/lib/lib/operations/reservationsSummaries.js new file mode 100644 index 0000000000..ba89539b16 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/operations/reservationsSummaries.js @@ -0,0 +1,975 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} grain Can be daily or monthly. Possible values include: + * 'DailyGrain', 'MonthlyGrain' + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] Required only for daily grain. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationSummariesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByReservationOrder(reservationOrderId, grain, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + // Validate + try { + if (reservationOrderId === null || reservationOrderId === undefined || typeof reservationOrderId.valueOf() !== 'string') { + throw new Error('reservationOrderId cannot be null or undefined and it must be of type string.'); + } + if (grain === null || grain === undefined || typeof grain.valueOf() !== 'string') { + throw new Error('grain cannot be null or undefined and it must be of type string.'); + } + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationSummaries'; + requestUrl = requestUrl.replace('{reservationOrderId}', encodeURIComponent(reservationOrderId)); + let queryParameters = []; + queryParameters.push('grain=' + encodeURIComponent(grain)); + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ReservationSummariesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} reservationId Id of the reservation + * + * @param {string} grain Can be daily or monthly. Possible values include: + * 'DailyGrain', 'MonthlyGrain' + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] Required only for daily grain. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationSummariesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByReservationOrderAndReservation(reservationOrderId, reservationId, grain, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + // Validate + try { + if (reservationOrderId === null || reservationOrderId === undefined || typeof reservationOrderId.valueOf() !== 'string') { + throw new Error('reservationOrderId cannot be null or undefined and it must be of type string.'); + } + if (reservationId === null || reservationId === undefined || typeof reservationId.valueOf() !== 'string') { + throw new Error('reservationId cannot be null or undefined and it must be of type string.'); + } + if (grain === null || grain === undefined || typeof grain.valueOf() !== 'string') { + throw new Error('grain cannot be null or undefined and it must be of type string.'); + } + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationSummaries'; + requestUrl = requestUrl.replace('{reservationOrderId}', encodeURIComponent(reservationOrderId)); + requestUrl = requestUrl.replace('{reservationId}', encodeURIComponent(reservationId)); + let queryParameters = []; + queryParameters.push('grain=' + encodeURIComponent(grain)); + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ReservationSummariesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationSummariesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByReservationOrderNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ReservationSummariesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationSummariesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByReservationOrderAndReservationNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ReservationSummariesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a ReservationsSummaries. */ +class ReservationsSummaries { + /** + * Create a ReservationsSummaries. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._listByReservationOrder = _listByReservationOrder; + this._listByReservationOrderAndReservation = _listByReservationOrderAndReservation; + this._listByReservationOrderNext = _listByReservationOrderNext; + this._listByReservationOrderAndReservationNext = _listByReservationOrderAndReservationNext; + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} grain Can be daily or monthly. Possible values include: + * 'DailyGrain', 'MonthlyGrain' + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] Required only for daily grain. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByReservationOrderWithHttpOperationResponse(reservationOrderId, grain, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByReservationOrder(reservationOrderId, grain, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} grain Can be daily or monthly. Possible values include: + * 'DailyGrain', 'MonthlyGrain' + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] Required only for daily grain. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ReservationSummariesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationSummariesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrder(reservationOrderId, grain, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByReservationOrder(reservationOrderId, grain, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByReservationOrder(reservationOrderId, grain, options, optionalCallback); + } + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} reservationId Id of the reservation + * + * @param {string} grain Can be daily or monthly. Possible values include: + * 'DailyGrain', 'MonthlyGrain' + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] Required only for daily grain. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByReservationOrderAndReservationWithHttpOperationResponse(reservationOrderId, reservationId, grain, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByReservationOrderAndReservation(reservationOrderId, reservationId, grain, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} reservationId Id of the reservation + * + * @param {string} grain Can be daily or monthly. Possible values include: + * 'DailyGrain', 'MonthlyGrain' + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] Required only for daily grain. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ReservationSummariesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationSummariesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrderAndReservation(reservationOrderId, reservationId, grain, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByReservationOrderAndReservation(reservationOrderId, reservationId, grain, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByReservationOrderAndReservation(reservationOrderId, reservationId, grain, options, optionalCallback); + } + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByReservationOrderNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByReservationOrderNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ReservationSummariesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationSummariesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrderNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByReservationOrderNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByReservationOrderNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByReservationOrderAndReservationNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByReservationOrderAndReservationNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ReservationSummariesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationSummariesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrderAndReservationNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByReservationOrderAndReservationNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByReservationOrderAndReservationNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = ReservationsSummaries; diff --git a/lib/services/consumptionManagement/lib/lib/operations/usageDetails.js b/lib/services/consumptionManagement/lib/lib/operations/usageDetails.js new file mode 100644 index 0000000000..2dfbb6cfb5 --- /dev/null +++ b/lib/services/consumptionManagement/lib/lib/operations/usageDetails.js @@ -0,0 +1,1175 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregatie usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let queryOptions = (options && options.queryOptions !== undefined) ? options.queryOptions : undefined; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + let apply; + try { + if (queryOptions !== null && queryOptions !== undefined) + { + apply = queryOptions.apply; + if (apply !== null && apply !== undefined && typeof apply.valueOf() !== 'string') { + throw new Error('apply must be of type string.'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Consumption/usageDetails'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (apply !== null && apply !== undefined) { + queryParameters.push('$apply=' + encodeURIComponent(apply)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregatie usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByBillingPeriod(billingPeriodName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let queryOptions = (options && options.queryOptions !== undefined) ? options.queryOptions : undefined; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (billingPeriodName === null || billingPeriodName === undefined || typeof billingPeriodName.valueOf() !== 'string') { + throw new Error('billingPeriodName cannot be null or undefined and it must be of type string.'); + } + if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + let apply; + try { + if (queryOptions !== null && queryOptions !== undefined) + { + apply = queryOptions.apply; + if (apply !== null && apply !== undefined && typeof apply.valueOf() !== 'string') { + throw new Error('apply must be of type string.'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/usageDetails'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{billingPeriodName}', encodeURIComponent(billingPeriodName)); + let queryParameters = []; + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (apply !== null && apply !== undefined) { + queryParameters.push('$apply=' + encodeURIComponent(apply)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByBillingPeriodNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a UsageDetails. */ +class UsageDetails { + /** + * Create a UsageDetails. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listByBillingPeriod = _listByBillingPeriod; + this._listNext = _listNext; + this._listByBillingPeriodNext = _listByBillingPeriodNext; + } + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregatie usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregatie usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(options, optionalCallback); + } + } + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregatie usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByBillingPeriodWithHttpOperationResponse(billingPeriodName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingPeriod(billingPeriodName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregatie usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriod(billingPeriodName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingPeriod(billingPeriodName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingPeriod(billingPeriodName, options, optionalCallback); + } + } + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByBillingPeriodNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriodNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingPeriodNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = UsageDetails; diff --git a/lib/services/consumptionManagement/lib/models/budget.js b/lib/services/consumptionManagement/lib/models/budget.js index a8bab30325..7d80ffe881 100644 --- a/lib/services/consumptionManagement/lib/models/budget.js +++ b/lib/services/consumptionManagement/lib/models/budget.js @@ -40,8 +40,9 @@ class Budget extends models['ProxyResource'] { * @member {array} [filters.resourceGroups] The list of filters on resource * groups, allowed at subscription level only. * @member {array} [filters.resources] The list of filters on resources. - * @member {array} [filters.meters] The list of filters on meters, mandatory - * for budgets of usage category. + * @member {array} [filters.meters] The list of filters on meters (GUID), + * mandatory for budgets of usage category. + * @member {object} [filters.tags] The dictionary of filters on tags. * @member {object} [currentSpend] The current amount of cost which is being * tracked for a budget. * @member {number} [currentSpend.amount] The total amount of cost which is diff --git a/lib/services/consumptionManagement/lib/models/costAllocationTag.js b/lib/services/consumptionManagement/lib/models/costAllocationTag.js new file mode 100644 index 0000000000..2da43a1e85 --- /dev/null +++ b/lib/services/consumptionManagement/lib/models/costAllocationTag.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The cost allocation tag. + * + */ +class CostAllocationTag { + /** + * Create a CostAllocationTag. + * @member {string} [key] Cost allocation tag key. + */ + constructor() { + } + + /** + * Defines the metadata of CostAllocationTag + * + * @returns {object} metadata of CostAllocationTag + * + */ + mapper() { + return { + required: false, + serializedName: 'CostAllocationTag', + type: { + name: 'Composite', + className: 'CostAllocationTag', + modelProperties: { + key: { + required: false, + serializedName: 'key', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = CostAllocationTag; diff --git a/lib/services/consumptionManagement/lib/models/costAllocationTags.js b/lib/services/consumptionManagement/lib/models/costAllocationTags.js new file mode 100644 index 0000000000..a77f1aa160 --- /dev/null +++ b/lib/services/consumptionManagement/lib/models/costAllocationTags.js @@ -0,0 +1,95 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * A cost allocation tag resource. + * + * @extends models['ProxyResource'] + */ +class CostAllocationTags extends models['ProxyResource'] { + /** + * Create a CostAllocationTags. + * @member {array} [costAllocationTags] Cost allocation tags. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of CostAllocationTags + * + * @returns {object} metadata of CostAllocationTags + * + */ + mapper() { + return { + required: false, + serializedName: 'CostAllocationTags', + type: { + name: 'Composite', + className: 'CostAllocationTags', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + eTag: { + required: false, + serializedName: 'eTag', + type: { + name: 'String' + } + }, + costAllocationTags: { + required: false, + serializedName: 'properties.costAllocationTags', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'CostAllocationTagElementType', + type: { + name: 'Composite', + className: 'CostAllocationTag' + } + } + } + } + } + } + }; + } +} + +module.exports = CostAllocationTags; diff --git a/lib/services/consumptionManagement/lib/models/filters.js b/lib/services/consumptionManagement/lib/models/filters.js index 22f370fab3..957b3e3959 100644 --- a/lib/services/consumptionManagement/lib/models/filters.js +++ b/lib/services/consumptionManagement/lib/models/filters.js @@ -20,8 +20,9 @@ class Filters { * @member {array} [resourceGroups] The list of filters on resource groups, * allowed at subscription level only. * @member {array} [resources] The list of filters on resources. - * @member {array} [meters] The list of filters on meters, mandatory for - * budgets of usage category. + * @member {array} [meters] The list of filters on meters (GUID), mandatory + * for budgets of usage category. + * @member {object} [tags] The dictionary of filters on tags. */ constructor() { } @@ -87,12 +88,33 @@ class Filters { name: 'Sequence', element: { required: false, - serializedName: 'StringElementType', + serializedName: 'UuidElementType', type: { name: 'String' } } } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'ArrayElementType', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } } } } diff --git a/lib/services/consumptionManagement/lib/models/index.d.ts b/lib/services/consumptionManagement/lib/models/index.d.ts index 71e72127ff..06dd4174d6 100644 --- a/lib/services/consumptionManagement/lib/models/index.d.ts +++ b/lib/services/consumptionManagement/lib/models/index.d.ts @@ -90,7 +90,7 @@ export interface Resource extends BaseResource { * @member {number} [billableQuantity] The billable usage quantity. * @member {number} [pretaxCost] The amount of cost before tax. * @member {boolean} [isEstimated] The estimated usage is subject to change. - * @member {string} [meterId] The meter id. + * @member {uuid} [meterId] The meter id (GUID). * @member {object} [meterDetails] The details about the meter. By default this * is not populated, unless it's specified in $expand. * @member {string} [meterDetails.meterName] The name of the meter, within the @@ -106,7 +106,7 @@ export interface Resource extends BaseResource { * @member {number} [meterDetails.totalIncludedQuantity] The total included * quantity associated with the offer. * @member {number} [meterDetails.pretaxStandardRate] The pretax listing price. - * @member {string} [subscriptionGuid] Subscription guid. + * @member {uuid} [subscriptionGuid] Subscription guid. * @member {string} [subscriptionName] Subscription name. * @member {string} [accountName] Account name. * @member {string} [departmentName] Department name. @@ -168,8 +168,8 @@ export interface UsageDetail extends Resource { * @member {string} [unitOfMeasure] The unit of measure. * @member {number} [pretaxCost] The amount of cost before tax. * @member {boolean} [isEstimated] The estimated usage is subject to change. - * @member {string} [meterId] The meter id. - * @member {string} [subscriptionGuid] Subscription guid. + * @member {uuid} [meterId] The meter id (GUID). + * @member {uuid} [subscriptionGuid] Subscription guid. * @member {string} [subscriptionName] Subscription name. * @member {string} [accountName] Account name. * @member {string} [departmentName] Department name. @@ -290,6 +290,51 @@ export interface ReservationDetails extends Resource { readonly totalReservedQuantity?: number; } +/** + * @class + * Initializes a new instance of the ReservationRecommendations class. + * @constructor + * Reservation recommendations resource. + * + * @member {string} [id] Resource Id. + * @member {string} [name] Resource name. + * @member {string} [type] Resource type. + * @member {object} [tags] Resource tags. + * @member {string} [location] Resource location + * @member {string} [sku] Resource sku + * @member {string} [lookBackPeriod] The number of days of usage to look back + * for recommendations. + * @member {uuid} [meterId] The meter id (GUID) + * @member {string} [term] RI recommendations in one or three year terms. + * @member {number} [costWithNoReservedInstances] The total amount of cost + * without reserved instances. + * @member {number} [recommendedQuantity] Recomended quality for reserved + * instances. + * @member {number} [totalCostWithReservedInstances] The total amount of cost + * with reserved instances. + * @member {number} [netSavings] Total estimated savings with reserved + * instances. + * @member {date} [firstUsageDate] The usage date for looking back. + * @member {string} [scope] Shared or single recommendation. + */ +export interface ReservationRecommendations { + readonly id?: string; + readonly name?: string; + readonly type?: string; + readonly tags?: { [propertyName: string]: string }; + readonly location?: string; + readonly sku?: string; + readonly lookBackPeriod?: string; + readonly meterId?: string; + readonly term?: string; + readonly costWithNoReservedInstances?: number; + readonly recommendedQuantity?: number; + readonly totalCostWithReservedInstances?: number; + readonly netSavings?: number; + readonly firstUsageDate?: Date; + readonly scope?: string; +} + /** * @class * Initializes a new instance of the BudgetTimePeriod class. @@ -314,13 +359,15 @@ export interface BudgetTimePeriod { * @member {array} [resourceGroups] The list of filters on resource groups, * allowed at subscription level only. * @member {array} [resources] The list of filters on resources. - * @member {array} [meters] The list of filters on meters, mandatory for + * @member {array} [meters] The list of filters on meters (GUID), mandatory for * budgets of usage category. + * @member {object} [tags] The dictionary of filters on tags. */ export interface Filters { resourceGroups?: string[]; resources?: string[]; meters?: string[]; + tags?: { [propertyName: string]: string[] }; } /** @@ -411,8 +458,9 @@ export interface ProxyResource extends BaseResource { * @member {array} [filters.resourceGroups] The list of filters on resource * groups, allowed at subscription level only. * @member {array} [filters.resources] The list of filters on resources. - * @member {array} [filters.meters] The list of filters on meters, mandatory - * for budgets of usage category. + * @member {array} [filters.meters] The list of filters on meters (GUID), + * mandatory for budgets of usage category. + * @member {object} [filters.tags] The dictionary of filters on tags. * @member {object} [currentSpend] The current amount of cost which is being * tracked for a budget. * @member {number} [currentSpend.amount] The total amount of cost which is @@ -432,6 +480,30 @@ export interface Budget extends ProxyResource { notifications?: { [propertyName: string]: Notification }; } +/** + * @class + * Initializes a new instance of the CostAllocationTag class. + * @constructor + * The cost allocation tag. + * + * @member {string} [key] Cost allocation tag key. + */ +export interface CostAllocationTag { + key?: string; +} + +/** + * @class + * Initializes a new instance of the CostAllocationTags class. + * @constructor + * A cost allocation tag resource. + * + * @member {array} [costAllocationTags] Cost allocation tags. + */ +export interface CostAllocationTags extends ProxyResource { + costAllocationTags?: CostAllocationTag[]; +} + /** * @class * Initializes a new instance of the ErrorDetails class. @@ -499,6 +571,20 @@ export interface Operation { display?: OperationDisplay; } +/** + * @class + * Initializes a new instance of the ResourceAttributes class. + * @constructor + * The Resource model definition. + * + * @member {string} [location] Resource location + * @member {string} [sku] Resource sku + */ +export interface ResourceAttributes { + readonly location?: string; + readonly sku?: string; +} + /** * @class * Initializes a new instance of the PriceSheetProperties class. @@ -507,7 +593,7 @@ export interface Operation { * * @member {string} [billingPeriodId] The id of the billing period resource * that the usage belongs to. - * @member {string} [meterId] The meter id + * @member {uuid} [meterId] The meter id (GUID) * @member {object} [meterDetails] The details about the meter. By default this * is not populated, unless it's specified in $expand. * @member {string} [meterDetails.meterName] The name of the meter, within the @@ -554,6 +640,20 @@ export interface PriceSheetResult extends Resource { readonly nextLink?: string; } +/** + * @class + * Initializes a new instance of the QueryOptions class. + * @constructor + * Additional parameters for a set of operations, such as: UsageDetails_list, + * UsageDetails_listByBillingPeriod. + * + * @member {string} [apply] OData apply expression to aggregatie usageDetails + * by tags or (tags and properties/usageStart) + */ +export interface QueryOptions { + apply?: string; +} + /** * @class @@ -605,6 +705,18 @@ export interface ReservationDetailsListResult extends Array readonly nextLink?: string; } +/** + * @class + * Initializes a new instance of the ReservationRecommendationsListResult class. + * @constructor + * Result of listing reservation recommendations. + * + * @member {string} [nextLink] The link (url) to the next page of results. + */ +export interface ReservationRecommendationsListResult extends Array { + readonly nextLink?: string; +} + /** * @class * Initializes a new instance of the BudgetsListResult class. diff --git a/lib/services/consumptionManagement/lib/models/index.js b/lib/services/consumptionManagement/lib/models/index.js index 3c9216c932..35476b9bf0 100644 --- a/lib/services/consumptionManagement/lib/models/index.js +++ b/lib/services/consumptionManagement/lib/models/index.js @@ -24,21 +24,27 @@ exports.UsageDetail = require('./usageDetail'); exports.Marketplace = require('./marketplace'); exports.ReservationSummaries = require('./reservationSummaries'); exports.ReservationDetails = require('./reservationDetails'); +exports.ReservationRecommendations = require('./reservationRecommendations'); exports.BudgetTimePeriod = require('./budgetTimePeriod'); exports.Filters = require('./filters'); exports.CurrentSpend = require('./currentSpend'); exports.Notification = require('./notification'); exports.ProxyResource = require('./proxyResource'); exports.Budget = require('./budget'); +exports.CostAllocationTag = require('./costAllocationTag'); +exports.CostAllocationTags = require('./costAllocationTags'); exports.ErrorDetails = require('./errorDetails'); exports.ErrorResponse = require('./errorResponse'); exports.OperationDisplay = require('./operationDisplay'); exports.Operation = require('./operation'); +exports.ResourceAttributes = require('./resourceAttributes'); exports.PriceSheetProperties = require('./priceSheetProperties'); exports.PriceSheetResult = require('./priceSheetResult'); +exports.QueryOptions = require('./queryOptions'); exports.UsageDetailsListResult = require('./usageDetailsListResult'); exports.MarketplacesListResult = require('./marketplacesListResult'); exports.ReservationSummariesListResult = require('./reservationSummariesListResult'); exports.ReservationDetailsListResult = require('./reservationDetailsListResult'); +exports.ReservationRecommendationsListResult = require('./reservationRecommendationsListResult'); exports.BudgetsListResult = require('./budgetsListResult'); exports.OperationListResult = require('./operationListResult'); diff --git a/lib/services/consumptionManagement/lib/models/marketplace.js b/lib/services/consumptionManagement/lib/models/marketplace.js index 3ad2b6ead4..b7e9515134 100644 --- a/lib/services/consumptionManagement/lib/models/marketplace.js +++ b/lib/services/consumptionManagement/lib/models/marketplace.js @@ -40,8 +40,8 @@ class Marketplace extends models['Resource'] { * @member {string} [unitOfMeasure] The unit of measure. * @member {number} [pretaxCost] The amount of cost before tax. * @member {boolean} [isEstimated] The estimated usage is subject to change. - * @member {string} [meterId] The meter id. - * @member {string} [subscriptionGuid] Subscription guid. + * @member {uuid} [meterId] The meter id (GUID). + * @member {uuid} [subscriptionGuid] Subscription guid. * @member {string} [subscriptionName] Subscription name. * @member {string} [accountName] Account name. * @member {string} [departmentName] Department name. diff --git a/lib/services/consumptionManagement/lib/models/priceSheetProperties.js b/lib/services/consumptionManagement/lib/models/priceSheetProperties.js index 6ebba523fc..b40d0a6a23 100644 --- a/lib/services/consumptionManagement/lib/models/priceSheetProperties.js +++ b/lib/services/consumptionManagement/lib/models/priceSheetProperties.js @@ -21,7 +21,7 @@ class PriceSheetProperties { * Create a PriceSheetProperties. * @member {string} [billingPeriodId] The id of the billing period resource * that the usage belongs to. - * @member {string} [meterId] The meter id + * @member {uuid} [meterId] The meter id (GUID) * @member {object} [meterDetails] The details about the meter. By default * this is not populated, unless it's specified in $expand. * @member {string} [meterDetails.meterName] The name of the meter, within diff --git a/lib/services/consumptionManagement/lib/models/queryOptions.js b/lib/services/consumptionManagement/lib/models/queryOptions.js new file mode 100644 index 0000000000..f06ccd1be2 --- /dev/null +++ b/lib/services/consumptionManagement/lib/models/queryOptions.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Additional parameters for a set of operations, such as: UsageDetails_list, + * UsageDetails_listByBillingPeriod. + * + */ +class QueryOptions { + /** + * Create a QueryOptions. + * @member {string} [apply] OData apply expression to aggregatie usageDetails + * by tags or (tags and properties/usageStart) + */ + constructor() { + } + + /** + * Defines the metadata of QueryOptions + * + * @returns {object} metadata of QueryOptions + * + */ + mapper() { + return { + required: false, + type: { + name: 'Composite', + className: 'QueryOptions', + modelProperties: { + apply: { + required: false, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = QueryOptions; diff --git a/lib/services/consumptionManagement/lib/models/reservationRecommendations.js b/lib/services/consumptionManagement/lib/models/reservationRecommendations.js new file mode 100644 index 0000000000..f6c37b78a0 --- /dev/null +++ b/lib/services/consumptionManagement/lib/models/reservationRecommendations.js @@ -0,0 +1,191 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Reservation recommendations resource. + * + */ +class ReservationRecommendations { + /** + * Create a ReservationRecommendations. + * @member {string} [id] Resource Id. + * @member {string} [name] Resource name. + * @member {string} [type] Resource type. + * @member {object} [tags] Resource tags. + * @member {string} [location] Resource location + * @member {string} [sku] Resource sku + * @member {string} [lookBackPeriod] The number of days of usage to look back + * for recommendations. + * @member {uuid} [meterId] The meter id (GUID) + * @member {string} [term] RI recommendations in one or three year terms. + * @member {number} [costWithNoReservedInstances] The total amount of cost + * without reserved instances. + * @member {number} [recommendedQuantity] Recomended quality for reserved + * instances. + * @member {number} [totalCostWithReservedInstances] The total amount of cost + * with reserved instances. + * @member {number} [netSavings] Total estimated savings with reserved + * instances. + * @member {date} [firstUsageDate] The usage date for looking back. + * @member {string} [scope] Shared or single recommendation. + */ + constructor() { + } + + /** + * Defines the metadata of ReservationRecommendations + * + * @returns {object} metadata of ReservationRecommendations + * + */ + mapper() { + return { + required: false, + serializedName: 'ReservationRecommendations', + type: { + name: 'Composite', + className: 'ReservationRecommendations', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + tags: { + required: false, + readOnly: true, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + location: { + required: false, + readOnly: true, + serializedName: 'location', + type: { + name: 'String' + } + }, + sku: { + required: false, + readOnly: true, + serializedName: 'sku', + type: { + name: 'String' + } + }, + lookBackPeriod: { + required: false, + readOnly: true, + serializedName: 'properties.lookBackPeriod', + type: { + name: 'String' + } + }, + meterId: { + required: false, + readOnly: true, + serializedName: 'properties.meterId', + type: { + name: 'String' + } + }, + term: { + required: false, + readOnly: true, + serializedName: 'properties.term', + type: { + name: 'String' + } + }, + costWithNoReservedInstances: { + required: false, + readOnly: true, + serializedName: 'properties.costWithNoReservedInstances', + type: { + name: 'Number' + } + }, + recommendedQuantity: { + required: false, + readOnly: true, + serializedName: 'properties.recommendedQuantity', + type: { + name: 'Number' + } + }, + totalCostWithReservedInstances: { + required: false, + readOnly: true, + serializedName: 'properties.totalCostWithReservedInstances', + type: { + name: 'Number' + } + }, + netSavings: { + required: false, + readOnly: true, + serializedName: 'properties.netSavings', + type: { + name: 'Number' + } + }, + firstUsageDate: { + required: false, + readOnly: true, + serializedName: 'properties.firstUsageDate', + type: { + name: 'DateTime' + } + }, + scope: { + required: false, + readOnly: true, + serializedName: 'properties.scope', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ReservationRecommendations; diff --git a/lib/services/consumptionManagement/lib/models/reservationRecommendationsListResult.js b/lib/services/consumptionManagement/lib/models/reservationRecommendationsListResult.js new file mode 100644 index 0000000000..b7529c060d --- /dev/null +++ b/lib/services/consumptionManagement/lib/models/reservationRecommendationsListResult.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Result of listing reservation recommendations. + */ +class ReservationRecommendationsListResult extends Array { + /** + * Create a ReservationRecommendationsListResult. + * @member {string} [nextLink] The link (url) to the next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ReservationRecommendationsListResult + * + * @returns {object} metadata of ReservationRecommendationsListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'ReservationRecommendationsListResult', + type: { + name: 'Composite', + className: 'ReservationRecommendationsListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ReservationRecommendationsElementType', + type: { + name: 'Composite', + className: 'ReservationRecommendations' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ReservationRecommendationsListResult; diff --git a/lib/services/consumptionManagement/lib/models/resourceAttributes.js b/lib/services/consumptionManagement/lib/models/resourceAttributes.js new file mode 100644 index 0000000000..68350e7d44 --- /dev/null +++ b/lib/services/consumptionManagement/lib/models/resourceAttributes.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The Resource model definition. + * + */ +class ResourceAttributes { + /** + * Create a ResourceAttributes. + * @member {string} [location] Resource location + * @member {string} [sku] Resource sku + */ + constructor() { + } + + /** + * Defines the metadata of ResourceAttributes + * + * @returns {object} metadata of ResourceAttributes + * + */ + mapper() { + return { + required: false, + serializedName: 'ResourceAttributes', + type: { + name: 'Composite', + className: 'ResourceAttributes', + modelProperties: { + location: { + required: false, + readOnly: true, + serializedName: 'location', + type: { + name: 'String' + } + }, + sku: { + required: false, + readOnly: true, + serializedName: 'sku', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ResourceAttributes; diff --git a/lib/services/consumptionManagement/lib/models/usageDetail.js b/lib/services/consumptionManagement/lib/models/usageDetail.js index 83536a505a..787e10d164 100644 --- a/lib/services/consumptionManagement/lib/models/usageDetail.js +++ b/lib/services/consumptionManagement/lib/models/usageDetail.js @@ -40,7 +40,7 @@ class UsageDetail extends models['Resource'] { * @member {number} [billableQuantity] The billable usage quantity. * @member {number} [pretaxCost] The amount of cost before tax. * @member {boolean} [isEstimated] The estimated usage is subject to change. - * @member {string} [meterId] The meter id. + * @member {uuid} [meterId] The meter id (GUID). * @member {object} [meterDetails] The details about the meter. By default * this is not populated, unless it's specified in $expand. * @member {string} [meterDetails.meterName] The name of the meter, within @@ -57,7 +57,7 @@ class UsageDetail extends models['Resource'] { * quantity associated with the offer. * @member {number} [meterDetails.pretaxStandardRate] The pretax listing * price. - * @member {string} [subscriptionGuid] Subscription guid. + * @member {uuid} [subscriptionGuid] Subscription guid. * @member {string} [subscriptionName] Subscription name. * @member {string} [accountName] Account name. * @member {string} [departmentName] Department name. diff --git a/lib/services/consumptionManagement/lib/operations/budgets.js b/lib/services/consumptionManagement/lib/operations/budgets.js index 4e4a3423a0..d6fb7a1f58 100644 --- a/lib/services/consumptionManagement/lib/operations/budgets.js +++ b/lib/services/consumptionManagement/lib/operations/budgets.js @@ -468,8 +468,10 @@ function _get(budgetName, options, callback) { * @param {array} [parameters.filters.resources] The list of filters on * resources. * - * @param {array} [parameters.filters.meters] The list of filters on meters, - * mandatory for budgets of usage category. + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. * * @param {object} [parameters.notifications] Dictionary of notifications * associated with the budget. Budget can have up to five notifications. @@ -957,8 +959,10 @@ function _getByResourceGroupName(resourceGroupName, budgetName, options, callbac * @param {array} [parameters.filters.resources] The list of filters on * resources. * - * @param {array} [parameters.filters.meters] The list of filters on meters, - * mandatory for budgets of usage category. + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. * * @param {object} [parameters.notifications] Dictionary of notifications * associated with the budget. Budget can have up to five notifications. @@ -1826,8 +1830,10 @@ class Budgets { * @param {array} [parameters.filters.resources] The list of filters on * resources. * - * @param {array} [parameters.filters.meters] The list of filters on meters, - * mandatory for budgets of usage category. + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. * * @param {object} [parameters.notifications] Dictionary of notifications * associated with the budget. Budget can have up to five notifications. @@ -1901,8 +1907,10 @@ class Budgets { * @param {array} [parameters.filters.resources] The list of filters on * resources. * - * @param {array} [parameters.filters.meters] The list of filters on meters, - * mandatory for budgets of usage category. + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. * * @param {object} [parameters.notifications] Dictionary of notifications * associated with the budget. Budget can have up to five notifications. @@ -2167,8 +2175,10 @@ class Budgets { * @param {array} [parameters.filters.resources] The list of filters on * resources. * - * @param {array} [parameters.filters.meters] The list of filters on meters, - * mandatory for budgets of usage category. + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. * * @param {object} [parameters.notifications] Dictionary of notifications * associated with the budget. Budget can have up to five notifications. @@ -2244,8 +2254,10 @@ class Budgets { * @param {array} [parameters.filters.resources] The list of filters on * resources. * - * @param {array} [parameters.filters.meters] The list of filters on meters, - * mandatory for budgets of usage category. + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. * * @param {object} [parameters.notifications] Dictionary of notifications * associated with the budget. Budget can have up to five notifications. diff --git a/lib/services/consumptionManagement/lib/operations/costAllocationTagsOperations.js b/lib/services/consumptionManagement/lib/operations/costAllocationTagsOperations.js new file mode 100644 index 0000000000..ddadc0dc3c --- /dev/null +++ b/lib/services/consumptionManagement/lib/operations/costAllocationTagsOperations.js @@ -0,0 +1,537 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Get cost allocation tags for a billing account. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link CostAllocationTags} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(billingAccountId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.CostManagement/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/costAllocationTags'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['CostAllocationTags']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * The operation to create or update cost allocation tags assiciated with a + * billing account. Update operation requires latest eTag to be set in the + * request mandatorily. You may obtain the latest eTag by performing a get + * operation. Create operation does not require eTag. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} parameters Parameters supplied to the Create cost allocation + * tags operation. + * + * @param {array} [parameters.costAllocationTags] Cost allocation tags. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link CostAllocationTags} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(billingAccountId, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.CostManagement/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/costAllocationTags'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['CostAllocationTags']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['CostAllocationTags']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['CostAllocationTags']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a CostAllocationTagsOperations. */ +class CostAllocationTagsOperations { + /** + * Create a CostAllocationTagsOperations. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + } + + /** + * Get cost allocation tags for a billing account. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(billingAccountId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get cost allocation tags for a billing account. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {CostAllocationTags} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link CostAllocationTags} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(billingAccountId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(billingAccountId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountId, options, optionalCallback); + } + } + + /** + * The operation to create or update cost allocation tags assiciated with a + * billing account. Update operation requires latest eTag to be set in the + * request mandatorily. You may obtain the latest eTag by performing a get + * operation. Create operation does not require eTag. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} parameters Parameters supplied to the Create cost allocation + * tags operation. + * + * @param {array} [parameters.costAllocationTags] Cost allocation tags. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createOrUpdateWithHttpOperationResponse(billingAccountId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(billingAccountId, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * The operation to create or update cost allocation tags assiciated with a + * billing account. Update operation requires latest eTag to be set in the + * request mandatorily. You may obtain the latest eTag by performing a get + * operation. Create operation does not require eTag. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} parameters Parameters supplied to the Create cost allocation + * tags operation. + * + * @param {array} [parameters.costAllocationTags] Cost allocation tags. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {CostAllocationTags} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link CostAllocationTags} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(billingAccountId, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(billingAccountId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(billingAccountId, parameters, options, optionalCallback); + } + } + +} + +module.exports = CostAllocationTagsOperations; diff --git a/lib/services/consumptionManagement/lib/operations/index.d.ts b/lib/services/consumptionManagement/lib/operations/index.d.ts index 8b62e485d0..6835239a43 100644 --- a/lib/services/consumptionManagement/lib/operations/index.d.ts +++ b/lib/services/consumptionManagement/lib/operations/index.d.ts @@ -34,9 +34,10 @@ export interface UsageDetails { * * @param {string} [options.filter] May be used to filter usageDetails by * properties/usageEnd (Utc time), properties/usageStart (Utc time), - * properties/resourceGroup, properties/instanceName or properties/instanceId. - * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not - * currently support 'ne', 'or', or 'not'. + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). * * @param {string} [options.skiptoken] Skiptoken is only used if a previous * operation returned a partial result. If a previous response contains a @@ -46,6 +47,12 @@ export interface UsageDetails { * @param {number} [options.top] May be used to limit the number of results to * the most recent N usageDetails. * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregatie usageDetails by tags or (tags and properties/usageStart) + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -55,7 +62,7 @@ export interface UsageDetails { * * @reject {Error|ServiceError} - The error object. */ - listWithHttpOperationResponse(options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + listWithHttpOperationResponse(options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Lists the usage details for a scope by billing period. Usage details are @@ -70,9 +77,10 @@ export interface UsageDetails { * * @param {string} [options.filter] May be used to filter usageDetails by * properties/usageEnd (Utc time), properties/usageStart (Utc time), - * properties/resourceGroup, properties/instanceName or properties/instanceId. - * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not - * currently support 'ne', 'or', or 'not'. + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). * * @param {string} [options.skiptoken] Skiptoken is only used if a previous * operation returned a partial result. If a previous response contains a @@ -82,6 +90,12 @@ export interface UsageDetails { * @param {number} [options.top] May be used to limit the number of results to * the most recent N usageDetails. * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregatie usageDetails by tags or (tags and properties/usageStart) + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -108,9 +122,9 @@ export interface UsageDetails { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - list(options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; + list(options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise; list(callback: ServiceCallback): void; - list(options: { expand? : string, filter? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + list(options: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -130,7 +144,8 @@ export interface UsageDetails { * properties/usageEnd (Utc time), properties/usageStart (Utc time), * properties/resourceGroup, properties/instanceName or properties/instanceId. * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not - * currently support 'ne', 'or', or 'not'. + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). * * @param {string} [options.skiptoken] Skiptoken is only used if a previous * operation returned a partial result. If a previous response contains a @@ -140,6 +155,12 @@ export interface UsageDetails { * @param {number} [options.top] May be used to limit the number of results to * the most recent N usageDetails. * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregatie usageDetails by tags or (tags and properties/usageStart) + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -149,7 +170,7 @@ export interface UsageDetails { * * @reject {Error|ServiceError} - The error object. */ - listByBillingPeriodWithHttpOperationResponse(billingPeriodName: string, options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + listByBillingPeriodWithHttpOperationResponse(billingPeriodName: string, options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Lists the usage details for a scope by billing period. Usage details are @@ -168,7 +189,8 @@ export interface UsageDetails { * properties/usageEnd (Utc time), properties/usageStart (Utc time), * properties/resourceGroup, properties/instanceName or properties/instanceId. * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not - * currently support 'ne', 'or', or 'not'. + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). * * @param {string} [options.skiptoken] Skiptoken is only used if a previous * operation returned a partial result. If a previous response contains a @@ -178,6 +200,12 @@ export interface UsageDetails { * @param {number} [options.top] May be used to limit the number of results to * the most recent N usageDetails. * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregatie usageDetails by tags or (tags and properties/usageStart) + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -204,9 +232,9 @@ export interface UsageDetails { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - listByBillingPeriod(billingPeriodName: string, options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; + listByBillingPeriod(billingPeriodName: string, options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise; listByBillingPeriod(billingPeriodName: string, callback: ServiceCallback): void; - listByBillingPeriod(billingPeriodName: string, options: { expand? : string, filter? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + listByBillingPeriod(billingPeriodName: string, options: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -1152,6 +1180,133 @@ export interface ReservationsDetails { listByReservationOrderAndReservationNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } +/** + * @class + * ReservationRecommendationsOperations + * __NOTE__: An instance of this class is automatically created for an + * instance of the ConsumptionManagementClient. + */ +export interface ReservationRecommendationsOperations { + + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter + * reservationRecommendations by properties/scope and + * properties/lookBackPeriod. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter + * reservationRecommendations by properties/scope and + * properties/lookBackPeriod. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ReservationRecommendationsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ReservationRecommendationsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationRecommendationsListResult} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ReservationRecommendationsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ReservationRecommendationsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationRecommendationsListResult} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextPageLink: string, callback: ServiceCallback): void; + listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + /** * @class * Budgets @@ -1362,8 +1517,10 @@ export interface Budgets { * @param {array} [parameters.filters.resources] The list of filters on * resources. * - * @param {array} [parameters.filters.meters] The list of filters on meters, - * mandatory for budgets of usage category. + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. * * @param {object} [parameters.notifications] Dictionary of notifications * associated with the budget. Budget can have up to five notifications. @@ -1425,8 +1582,10 @@ export interface Budgets { * @param {array} [parameters.filters.resources] The list of filters on * resources. * - * @param {array} [parameters.filters.meters] The list of filters on meters, - * mandatory for budgets of usage category. + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. * * @param {object} [parameters.notifications] Dictionary of notifications * associated with the budget. Budget can have up to five notifications. @@ -1622,8 +1781,10 @@ export interface Budgets { * @param {array} [parameters.filters.resources] The list of filters on * resources. * - * @param {array} [parameters.filters.meters] The list of filters on meters, - * mandatory for budgets of usage category. + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. * * @param {object} [parameters.notifications] Dictionary of notifications * associated with the budget. Budget can have up to five notifications. @@ -1687,8 +1848,10 @@ export interface Budgets { * @param {array} [parameters.filters.resources] The list of filters on * resources. * - * @param {array} [parameters.filters.meters] The list of filters on meters, - * mandatory for budgets of usage category. + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. * * @param {object} [parameters.notifications] Dictionary of notifications * associated with the budget. Budget can have up to five notifications. @@ -2042,6 +2205,9 @@ export interface PriceSheet { * nextLink element, the value of the nextLink element will include a skiptoken * parameter that specifies a starting point to use for subsequent calls. * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -2051,7 +2217,7 @@ export interface PriceSheet { * * @reject {Error|ServiceError} - The error object. */ - getWithHttpOperationResponse(options?: { expand? : string, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + getWithHttpOperationResponse(options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Gets the price sheet for a scope by subscriptionId. Price sheet is available @@ -2068,6 +2234,9 @@ export interface PriceSheet { * nextLink element, the value of the nextLink element will include a skiptoken * parameter that specifies a starting point to use for subsequent calls. * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -2093,9 +2262,9 @@ export interface PriceSheet { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - get(options?: { expand? : string, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + get(options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; get(callback: ServiceCallback): void; - get(options: { expand? : string, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + get(options: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -2115,6 +2284,9 @@ export interface PriceSheet { * nextLink element, the value of the nextLink element will include a skiptoken * parameter that specifies a starting point to use for subsequent calls. * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -2124,7 +2296,7 @@ export interface PriceSheet { * * @reject {Error|ServiceError} - The error object. */ - getByBillingPeriodWithHttpOperationResponse(billingPeriodName: string, options?: { expand? : string, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + getByBillingPeriodWithHttpOperationResponse(billingPeriodName: string, options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Get the price sheet for a scope by subscriptionId and billing period. Price @@ -2143,6 +2315,9 @@ export interface PriceSheet { * nextLink element, the value of the nextLink element will include a skiptoken * parameter that specifies a starting point to use for subsequent calls. * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -2168,7 +2343,150 @@ export interface PriceSheet { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - getByBillingPeriod(billingPeriodName: string, options?: { expand? : string, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + getByBillingPeriod(billingPeriodName: string, options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; getByBillingPeriod(billingPeriodName: string, callback: ServiceCallback): void; - getByBillingPeriod(billingPeriodName: string, options: { expand? : string, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + getByBillingPeriod(billingPeriodName: string, options: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * CostAllocationTagsOperations + * __NOTE__: An instance of this class is automatically created for an + * instance of the ConsumptionManagementClient. + */ +export interface CostAllocationTagsOperations { + + + /** + * Get cost allocation tags for a billing account. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(billingAccountId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get cost allocation tags for a billing account. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {CostAllocationTags} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {CostAllocationTags} [result] - The deserialized result object if an error did not occur. + * See {@link CostAllocationTags} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(billingAccountId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountId: string, callback: ServiceCallback): void; + get(billingAccountId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to create or update cost allocation tags assiciated with a + * billing account. Update operation requires latest eTag to be set in the + * request mandatorily. You may obtain the latest eTag by performing a get + * operation. Create operation does not require eTag. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} parameters Parameters supplied to the Create cost allocation + * tags operation. + * + * @param {array} [parameters.costAllocationTags] Cost allocation tags. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createOrUpdateWithHttpOperationResponse(billingAccountId: string, parameters: models.CostAllocationTags, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to create or update cost allocation tags assiciated with a + * billing account. Update operation requires latest eTag to be set in the + * request mandatorily. You may obtain the latest eTag by performing a get + * operation. Create operation does not require eTag. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} parameters Parameters supplied to the Create cost allocation + * tags operation. + * + * @param {array} [parameters.costAllocationTags] Cost allocation tags. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {CostAllocationTags} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {CostAllocationTags} [result] - The deserialized result object if an error did not occur. + * See {@link CostAllocationTags} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(billingAccountId: string, parameters: models.CostAllocationTags, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(billingAccountId: string, parameters: models.CostAllocationTags, callback: ServiceCallback): void; + createOrUpdate(billingAccountId: string, parameters: models.CostAllocationTags, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } diff --git a/lib/services/consumptionManagement/lib/operations/index.js b/lib/services/consumptionManagement/lib/operations/index.js index 6e4d705339..252d834305 100644 --- a/lib/services/consumptionManagement/lib/operations/index.js +++ b/lib/services/consumptionManagement/lib/operations/index.js @@ -18,6 +18,8 @@ exports.UsageDetails = require('./usageDetails'); exports.Marketplaces = require('./marketplaces'); exports.ReservationsSummaries = require('./reservationsSummaries'); exports.ReservationsDetails = require('./reservationsDetails'); +exports.ReservationRecommendationsOperations = require('./reservationRecommendationsOperations'); exports.Budgets = require('./budgets'); exports.Operations = require('./operations'); exports.PriceSheet = require('./priceSheet'); +exports.CostAllocationTagsOperations = require('./costAllocationTagsOperations'); diff --git a/lib/services/consumptionManagement/lib/operations/priceSheet.js b/lib/services/consumptionManagement/lib/operations/priceSheet.js index 79e6e6a07c..5d9f6a5625 100644 --- a/lib/services/consumptionManagement/lib/operations/priceSheet.js +++ b/lib/services/consumptionManagement/lib/operations/priceSheet.js @@ -29,6 +29,9 @@ const WebResource = msRest.WebResource; * nextLink element, the value of the nextLink element will include a skiptoken * parameter that specifies a starting point to use for subsequent calls. * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -57,6 +60,7 @@ function _get(options, callback) { } let expand = (options && options.expand !== undefined) ? options.expand : undefined; let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; // Validate try { if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { @@ -65,6 +69,19 @@ function _get(options, callback) { if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { throw new Error('skiptoken must be of type string.'); } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); } @@ -89,6 +106,9 @@ function _get(options, callback) { if (skiptoken !== null && skiptoken !== undefined) { queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); @@ -189,6 +209,9 @@ function _get(options, callback) { * nextLink element, the value of the nextLink element will include a skiptoken * parameter that specifies a starting point to use for subsequent calls. * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -217,6 +240,7 @@ function _getByBillingPeriod(billingPeriodName, options, callback) { } let expand = (options && options.expand !== undefined) ? options.expand : undefined; let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; // Validate try { if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { @@ -225,6 +249,19 @@ function _getByBillingPeriod(billingPeriodName, options, callback) { if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { throw new Error('skiptoken must be of type string.'); } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); } @@ -253,6 +290,9 @@ function _getByBillingPeriod(billingPeriodName, options, callback) { if (skiptoken !== null && skiptoken !== undefined) { queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); @@ -363,6 +403,9 @@ class PriceSheet { * nextLink element, the value of the nextLink element will include a skiptoken * parameter that specifies a starting point to use for subsequent calls. * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -401,6 +444,9 @@ class PriceSheet { * nextLink element, the value of the nextLink element will include a skiptoken * parameter that specifies a starting point to use for subsequent calls. * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -463,6 +509,9 @@ class PriceSheet { * nextLink element, the value of the nextLink element will include a skiptoken * parameter that specifies a starting point to use for subsequent calls. * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -503,6 +552,9 @@ class PriceSheet { * nextLink element, the value of the nextLink element will include a skiptoken * parameter that specifies a starting point to use for subsequent calls. * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * diff --git a/lib/services/consumptionManagement/lib/operations/reservationRecommendationsOperations.js b/lib/services/consumptionManagement/lib/operations/reservationRecommendationsOperations.js new file mode 100644 index 0000000000..08e3905565 --- /dev/null +++ b/lib/services/consumptionManagement/lib/operations/reservationRecommendationsOperations.js @@ -0,0 +1,478 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * List of recomendations for purchasing reserved instances. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter + * reservationRecommendations by properties/scope and + * properties/lookBackPeriod. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationRecommendationsListResult} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + // Validate + try { + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Consumption/reservationRecommendations'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ReservationRecommendationsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * List of recomendations for purchasing reserved instances. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationRecommendationsListResult} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ReservationRecommendationsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a ReservationRecommendationsOperations. */ +class ReservationRecommendationsOperations { + /** + * Create a ReservationRecommendationsOperations. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listNext = _listNext; + } + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter + * reservationRecommendations by properties/scope and + * properties/lookBackPeriod. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter + * reservationRecommendations by properties/scope and + * properties/lookBackPeriod. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ReservationRecommendationsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationRecommendationsListResult} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(options, optionalCallback); + } + } + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ReservationRecommendationsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationRecommendationsListResult} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = ReservationRecommendationsOperations; diff --git a/lib/services/consumptionManagement/lib/operations/usageDetails.js b/lib/services/consumptionManagement/lib/operations/usageDetails.js index 0f710f2179..2dfbb6cfb5 100644 --- a/lib/services/consumptionManagement/lib/operations/usageDetails.js +++ b/lib/services/consumptionManagement/lib/operations/usageDetails.js @@ -27,9 +27,10 @@ const WebResource = msRest.WebResource; * * @param {string} [options.filter] May be used to filter usageDetails by * properties/usageEnd (Utc time), properties/usageStart (Utc time), - * properties/resourceGroup, properties/instanceName or properties/instanceId. - * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not - * currently support 'ne', 'or', or 'not'. + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). * * @param {string} [options.skiptoken] Skiptoken is only used if a previous * operation returned a partial result. If a previous response contains a @@ -39,6 +40,12 @@ const WebResource = msRest.WebResource; * @param {number} [options.top] May be used to limit the number of results to * the most recent N usageDetails. * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregatie usageDetails by tags or (tags and properties/usageStart) + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -70,6 +77,7 @@ function _list(options, callback) { let filter = (options && options.filter !== undefined) ? options.filter : undefined; let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; let top = (options && options.top !== undefined) ? options.top : undefined; + let queryOptions = (options && options.queryOptions !== undefined) ? options.queryOptions : undefined; // Validate try { if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { @@ -106,6 +114,18 @@ function _list(options, callback) { } catch (error) { return callback(error); } + let apply; + try { + if (queryOptions !== null && queryOptions !== undefined) + { + apply = queryOptions.apply; + if (apply !== null && apply !== undefined && typeof apply.valueOf() !== 'string') { + throw new Error('apply must be of type string.'); + } + } + } catch (error) { + return callback(error); + } // Construct URL let baseUrl = this.client.baseUri; @@ -125,6 +145,9 @@ function _list(options, callback) { queryParameters.push('$top=' + encodeURIComponent(top.toString())); } queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (apply !== null && apply !== undefined) { + queryParameters.push('$apply=' + encodeURIComponent(apply)); + } if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); } @@ -224,7 +247,8 @@ function _list(options, callback) { * properties/usageEnd (Utc time), properties/usageStart (Utc time), * properties/resourceGroup, properties/instanceName or properties/instanceId. * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not - * currently support 'ne', 'or', or 'not'. + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). * * @param {string} [options.skiptoken] Skiptoken is only used if a previous * operation returned a partial result. If a previous response contains a @@ -234,6 +258,12 @@ function _list(options, callback) { * @param {number} [options.top] May be used to limit the number of results to * the most recent N usageDetails. * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregatie usageDetails by tags or (tags and properties/usageStart) + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -265,6 +295,7 @@ function _listByBillingPeriod(billingPeriodName, options, callback) { let filter = (options && options.filter !== undefined) ? options.filter : undefined; let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; let top = (options && options.top !== undefined) ? options.top : undefined; + let queryOptions = (options && options.queryOptions !== undefined) ? options.queryOptions : undefined; // Validate try { if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { @@ -304,6 +335,18 @@ function _listByBillingPeriod(billingPeriodName, options, callback) { } catch (error) { return callback(error); } + let apply; + try { + if (queryOptions !== null && queryOptions !== undefined) + { + apply = queryOptions.apply; + if (apply !== null && apply !== undefined && typeof apply.valueOf() !== 'string') { + throw new Error('apply must be of type string.'); + } + } + } catch (error) { + return callback(error); + } // Construct URL let baseUrl = this.client.baseUri; @@ -324,6 +367,9 @@ function _listByBillingPeriod(billingPeriodName, options, callback) { queryParameters.push('$top=' + encodeURIComponent(top.toString())); } queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (apply !== null && apply !== undefined) { + queryParameters.push('$apply=' + encodeURIComponent(apply)); + } if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); } @@ -693,9 +739,10 @@ class UsageDetails { * * @param {string} [options.filter] May be used to filter usageDetails by * properties/usageEnd (Utc time), properties/usageStart (Utc time), - * properties/resourceGroup, properties/instanceName or properties/instanceId. - * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not - * currently support 'ne', 'or', or 'not'. + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). * * @param {string} [options.skiptoken] Skiptoken is only used if a previous * operation returned a partial result. If a previous response contains a @@ -705,6 +752,12 @@ class UsageDetails { * @param {number} [options.top] May be used to limit the number of results to * the most recent N usageDetails. * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregatie usageDetails by tags or (tags and properties/usageStart) + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -741,9 +794,10 @@ class UsageDetails { * * @param {string} [options.filter] May be used to filter usageDetails by * properties/usageEnd (Utc time), properties/usageStart (Utc time), - * properties/resourceGroup, properties/instanceName or properties/instanceId. - * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not - * currently support 'ne', 'or', or 'not'. + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). * * @param {string} [options.skiptoken] Skiptoken is only used if a previous * operation returned a partial result. If a previous response contains a @@ -753,6 +807,12 @@ class UsageDetails { * @param {number} [options.top] May be used to limit the number of results to * the most recent N usageDetails. * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregatie usageDetails by tags or (tags and properties/usageStart) + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -816,7 +876,8 @@ class UsageDetails { * properties/usageEnd (Utc time), properties/usageStart (Utc time), * properties/resourceGroup, properties/instanceName or properties/instanceId. * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not - * currently support 'ne', 'or', or 'not'. + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). * * @param {string} [options.skiptoken] Skiptoken is only used if a previous * operation returned a partial result. If a previous response contains a @@ -826,6 +887,12 @@ class UsageDetails { * @param {number} [options.top] May be used to limit the number of results to * the most recent N usageDetails. * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregatie usageDetails by tags or (tags and properties/usageStart) + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -866,7 +933,8 @@ class UsageDetails { * properties/usageEnd (Utc time), properties/usageStart (Utc time), * properties/resourceGroup, properties/instanceName or properties/instanceId. * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not - * currently support 'ne', 'or', or 'not'. + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). * * @param {string} [options.skiptoken] Skiptoken is only used if a previous * operation returned a partial result. If a previous response contains a @@ -876,6 +944,12 @@ class UsageDetails { * @param {number} [options.top] May be used to limit the number of results to * the most recent N usageDetails. * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregatie usageDetails by tags or (tags and properties/usageStart) + * * @param {object} [options.customHeaders] Headers that will be added to the * request * diff --git a/lib/services/consumptionManagement/lib/package.json b/lib/services/consumptionManagement/lib/package.json new file mode 100644 index 0000000000..11e5ed5d76 --- /dev/null +++ b/lib/services/consumptionManagement/lib/package.json @@ -0,0 +1,22 @@ +{ + "name": "azure-arm-consumption", + "author": "Microsoft Corporation", + "description": "ConsumptionManagementClient Library with typescript type definitions for node", + "version": "", + "dependencies": { + "ms-rest": "^2.3.2", + "ms-rest-azure": "^2.5.5" + }, + "keywords": [ "node", "azure" ], + "license": "MIT", + "main": "./lib/consumptionManagementClient.js", + "types": "./lib/consumptionManagementClient.d.ts", + "homepage": "http://github.com/azure/azure-sdk-for-node", + "repository": { + "type": "git", + "url": "https://github.com/azure/azure-sdk-for-node.git" + }, + "bugs": { + "url": "http://github.com/Azure/azure-sdk-for-node/issues" + } +} From 4e3af14714f5da7fcc0e328e536f0659ade68748 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Fri, 13 Apr 2018 15:12:40 -0700 Subject: [PATCH 2/5] [AutoPR consumption/resource-manager] Renamed cost allocation tags to cost tags and added schema for get list of all available tag keys (#2727) * Generated from 1f2de0f37c163aa960c824541bb9094f41418b45 Renamed cost allocation tags to cost tags and added schema for get list of all available tag keys Renamed cost allocation tags to cost tags and added schema for get list of all available tag keys * Generated from 7f53393ed97f6918aed8a574dc62a42fd1e36011 Incorporated review comments Incorporated review comments --- .../consumptionManagement/LICENSE.txt | 42 +- lib/services/consumptionManagement/README.md | 83 +-- .../lib/consumptionManagementClient.d.ts | 3 +- .../lib/consumptionManagementClient.js | 3 +- .../lib/models/costTag.js | 52 ++ .../lib/models/costTags.js | 95 ++++ .../lib/models/index.d.ts | 82 ++- .../consumptionManagement/lib/models/index.js | 8 +- .../consumptionManagement/lib/models/tag.js | 52 ++ .../consumptionManagement/lib/models/tags.js | 95 ++++ .../lib/operations/costTagsOperations.js | 537 ++++++++++++++++++ .../lib/operations/index.d.ts | 132 +++-- .../lib/operations/index.js | 3 +- .../lib/operations/tagsOperations.js | 248 ++++++++ .../consumptionManagement/package.json | 31 +- 15 files changed, 1316 insertions(+), 150 deletions(-) create mode 100644 lib/services/consumptionManagement/lib/models/costTag.js create mode 100644 lib/services/consumptionManagement/lib/models/costTags.js create mode 100644 lib/services/consumptionManagement/lib/models/tag.js create mode 100644 lib/services/consumptionManagement/lib/models/tags.js create mode 100644 lib/services/consumptionManagement/lib/operations/costTagsOperations.js create mode 100644 lib/services/consumptionManagement/lib/operations/tagsOperations.js diff --git a/lib/services/consumptionManagement/LICENSE.txt b/lib/services/consumptionManagement/LICENSE.txt index 0313a903d7..5431ba98b9 100644 --- a/lib/services/consumptionManagement/LICENSE.txt +++ b/lib/services/consumptionManagement/LICENSE.txt @@ -1,21 +1,21 @@ -The MIT License (MIT) - -Copyright (c) 2017 Microsoft - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +The MIT License (MIT) + +Copyright (c) 2018 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/lib/services/consumptionManagement/README.md b/lib/services/consumptionManagement/README.md index 1e8c9863ee..fa6d0fd678 100644 --- a/lib/services/consumptionManagement/README.md +++ b/lib/services/consumptionManagement/README.md @@ -1,38 +1,45 @@ -# Microsoft Azure SDK for Node.js - ConsumptionManagement - -This project provides a Node.js package for accessing the Azure PAS. Right now it supports: -- **Node.js version: 6.x.x or higher** - -## How to Install - -```bash -npm install azure-arm-consumption -``` - -## How to Use - -### Authentication, client creation and listing usageDetails as an example - - ```javascript - var msRestAzure = require('ms-rest-azure'); - var ConsumptionManagementClient = require("azure-arm-consumption"); - - // Interactive Login - // It provides a url and code that needs to be copied and pasted in a browser and authenticated over there. If successful, - // the user will get a DeviceTokenCredentials object. - msRestAzure.interactiveLogin(function(err, credentials) { - let client = new ConsumptionManagementClient(credentials, 'your-subscription-id'); - client.usageDetails.list().then((usageDetails) => { - console.log('List of usageDetails:'); - console.dir(usageDetails, {depth: null, colors: true}); - }); - }).catch((err) => { - console.log('An error ocurred'); - console.dir(err, {depth: null, colors: true}); - }); -}); -``` - -## Related projects - -- [Microsoft Azure SDK for Node.js](https://github.com/Azure/azure-sdk-for-node) +--- +uid: azure-arm-consumption +summary: *content + +--- +# Microsoft Azure SDK for Node.js - ConsumptionManagementClient +This project provides a Node.js package for accessing Azure. Right now it supports: +- **Node.js version 6.x.x or higher** + +## Features + + +## How to Install + +```bash +npm install azure-arm-consumption +``` + +## How to use + +### Authentication, client creation and list usageDetails as an example. + +```javascript +const msRestAzure = require("ms-rest-azure"); +const ConsumptionManagementClient = require("azure-arm-consumption"); +msRestAzure.interactiveLogin().then((creds) => { + const subscriptionId = ""; + const client = new ConsumptionManagementClient(creds, subscriptionId); + const expand = "testexpand"; + const filter = "testfilter"; + const skiptoken = "testskiptoken"; + const top = 1; + const apply = "testapply"; + return client.usageDetails.list(expand, filter, skiptoken, top, apply).then((result) => { + console.log("The result is:"); + console.log(result); + }); +}).catch((err) => { + console.log('An error occurred:'); + console.dir(err, {depth: null, colors: true}); +}); + +## Related projects + +- [Microsoft Azure SDK for Node.js](https://github.com/Azure/azure-sdk-for-node) diff --git a/lib/services/consumptionManagement/lib/consumptionManagementClient.d.ts b/lib/services/consumptionManagement/lib/consumptionManagementClient.d.ts index 507a6fc1b0..872911c5e1 100644 --- a/lib/services/consumptionManagement/lib/consumptionManagementClient.d.ts +++ b/lib/services/consumptionManagement/lib/consumptionManagementClient.d.ts @@ -64,7 +64,8 @@ export default class ConsumptionManagementClient extends AzureServiceClient { budgets: operations.Budgets; operations: operations.Operations; priceSheet: operations.PriceSheet; - costAllocationTagsOperations: operations.CostAllocationTagsOperations; + costTagsOperations: operations.CostTagsOperations; + tagsOperations: operations.TagsOperations; } export { ConsumptionManagementClient, models as ConsumptionManagementModels }; diff --git a/lib/services/consumptionManagement/lib/consumptionManagementClient.js b/lib/services/consumptionManagement/lib/consumptionManagementClient.js index 7174ea58fc..98c1b22386 100644 --- a/lib/services/consumptionManagement/lib/consumptionManagementClient.js +++ b/lib/services/consumptionManagement/lib/consumptionManagementClient.js @@ -80,7 +80,8 @@ class ConsumptionManagementClient extends ServiceClient { this.budgets = new operations.Budgets(this); this.operations = new operations.Operations(this); this.priceSheet = new operations.PriceSheet(this); - this.costAllocationTagsOperations = new operations.CostAllocationTagsOperations(this); + this.costTagsOperations = new operations.CostTagsOperations(this); + this.tagsOperations = new operations.TagsOperations(this); this.models = models; msRest.addSerializationMixin(this); } diff --git a/lib/services/consumptionManagement/lib/models/costTag.js b/lib/services/consumptionManagement/lib/models/costTag.js new file mode 100644 index 0000000000..29a8e275c7 --- /dev/null +++ b/lib/services/consumptionManagement/lib/models/costTag.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The cost tag. + * + */ +class CostTag { + /** + * Create a CostTag. + * @member {string} [key] Cost tag key. + */ + constructor() { + } + + /** + * Defines the metadata of CostTag + * + * @returns {object} metadata of CostTag + * + */ + mapper() { + return { + required: false, + serializedName: 'CostTag', + type: { + name: 'Composite', + className: 'CostTag', + modelProperties: { + key: { + required: false, + serializedName: 'key', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = CostTag; diff --git a/lib/services/consumptionManagement/lib/models/costTags.js b/lib/services/consumptionManagement/lib/models/costTags.js new file mode 100644 index 0000000000..7b3f162b79 --- /dev/null +++ b/lib/services/consumptionManagement/lib/models/costTags.js @@ -0,0 +1,95 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * A cost tag resource. + * + * @extends models['ProxyResource'] + */ +class CostTags extends models['ProxyResource'] { + /** + * Create a CostTags. + * @member {array} [costTags] Cost tags. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of CostTags + * + * @returns {object} metadata of CostTags + * + */ + mapper() { + return { + required: false, + serializedName: 'CostTags', + type: { + name: 'Composite', + className: 'CostTags', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + eTag: { + required: false, + serializedName: 'eTag', + type: { + name: 'String' + } + }, + costTags: { + required: false, + serializedName: 'properties.costTags', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'CostTagElementType', + type: { + name: 'Composite', + className: 'CostTag' + } + } + } + } + } + } + }; + } +} + +module.exports = CostTags; diff --git a/lib/services/consumptionManagement/lib/models/index.d.ts b/lib/services/consumptionManagement/lib/models/index.d.ts index 06dd4174d6..e98fac3993 100644 --- a/lib/services/consumptionManagement/lib/models/index.d.ts +++ b/lib/services/consumptionManagement/lib/models/index.d.ts @@ -335,6 +335,50 @@ export interface ReservationRecommendations { readonly scope?: string; } +/** + * @class + * Initializes a new instance of the Tag class. + * @constructor + * The tag resource. + * + * @member {string} [key] Tag key. + */ +export interface Tag { + key?: string; +} + +/** + * @class + * Initializes a new instance of the ProxyResource class. + * @constructor + * The Resource model definition. + * + * @member {string} [id] Resource Id. + * @member {string} [name] Resource name. + * @member {string} [type] Resource type. + * @member {string} [eTag] eTag of the resource. To handle concurrent update + * scenarion, this field will be used to determine whether the user is updating + * the latest version or not. + */ +export interface ProxyResource extends BaseResource { + readonly id?: string; + readonly name?: string; + readonly type?: string; + eTag?: string; +} + +/** + * @class + * Initializes a new instance of the Tags class. + * @constructor + * A resource listing all tags. + * + * @member {array} [tags] A list of Tag. + */ +export interface Tags extends ProxyResource { + tags?: Tag[]; +} + /** * @class * Initializes a new instance of the BudgetTimePeriod class. @@ -413,26 +457,6 @@ export interface Notification { contactGroups?: string[]; } -/** - * @class - * Initializes a new instance of the ProxyResource class. - * @constructor - * The Resource model definition. - * - * @member {string} [id] Resource Id. - * @member {string} [name] Resource name. - * @member {string} [type] Resource type. - * @member {string} [eTag] eTag of the resource. To handle concurrent update - * scenarion, this field will be used to determine whether the user is updating - * the latest version or not. - */ -export interface ProxyResource extends BaseResource { - readonly id?: string; - readonly name?: string; - readonly type?: string; - eTag?: string; -} - /** * @class * Initializes a new instance of the Budget class. @@ -482,26 +506,26 @@ export interface Budget extends ProxyResource { /** * @class - * Initializes a new instance of the CostAllocationTag class. + * Initializes a new instance of the CostTag class. * @constructor - * The cost allocation tag. + * The cost tag. * - * @member {string} [key] Cost allocation tag key. + * @member {string} [key] Cost tag key. */ -export interface CostAllocationTag { +export interface CostTag { key?: string; } /** * @class - * Initializes a new instance of the CostAllocationTags class. + * Initializes a new instance of the CostTags class. * @constructor - * A cost allocation tag resource. + * A cost tag resource. * - * @member {array} [costAllocationTags] Cost allocation tags. + * @member {array} [costTags] Cost tags. */ -export interface CostAllocationTags extends ProxyResource { - costAllocationTags?: CostAllocationTag[]; +export interface CostTags extends ProxyResource { + costTags?: CostTag[]; } /** diff --git a/lib/services/consumptionManagement/lib/models/index.js b/lib/services/consumptionManagement/lib/models/index.js index 35476b9bf0..4ec0f1ec43 100644 --- a/lib/services/consumptionManagement/lib/models/index.js +++ b/lib/services/consumptionManagement/lib/models/index.js @@ -25,14 +25,16 @@ exports.Marketplace = require('./marketplace'); exports.ReservationSummaries = require('./reservationSummaries'); exports.ReservationDetails = require('./reservationDetails'); exports.ReservationRecommendations = require('./reservationRecommendations'); +exports.Tag = require('./tag'); +exports.ProxyResource = require('./proxyResource'); +exports.Tags = require('./tags'); exports.BudgetTimePeriod = require('./budgetTimePeriod'); exports.Filters = require('./filters'); exports.CurrentSpend = require('./currentSpend'); exports.Notification = require('./notification'); -exports.ProxyResource = require('./proxyResource'); exports.Budget = require('./budget'); -exports.CostAllocationTag = require('./costAllocationTag'); -exports.CostAllocationTags = require('./costAllocationTags'); +exports.CostTag = require('./costTag'); +exports.CostTags = require('./costTags'); exports.ErrorDetails = require('./errorDetails'); exports.ErrorResponse = require('./errorResponse'); exports.OperationDisplay = require('./operationDisplay'); diff --git a/lib/services/consumptionManagement/lib/models/tag.js b/lib/services/consumptionManagement/lib/models/tag.js new file mode 100644 index 0000000000..2424fd6383 --- /dev/null +++ b/lib/services/consumptionManagement/lib/models/tag.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The tag resource. + * + */ +class Tag { + /** + * Create a Tag. + * @member {string} [key] Tag key. + */ + constructor() { + } + + /** + * Defines the metadata of Tag + * + * @returns {object} metadata of Tag + * + */ + mapper() { + return { + required: false, + serializedName: 'Tag', + type: { + name: 'Composite', + className: 'Tag', + modelProperties: { + key: { + required: false, + serializedName: 'key', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = Tag; diff --git a/lib/services/consumptionManagement/lib/models/tags.js b/lib/services/consumptionManagement/lib/models/tags.js new file mode 100644 index 0000000000..c7a6c39a59 --- /dev/null +++ b/lib/services/consumptionManagement/lib/models/tags.js @@ -0,0 +1,95 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * A resource listing all tags. + * + * @extends models['ProxyResource'] + */ +class Tags extends models['ProxyResource'] { + /** + * Create a Tags. + * @member {array} [tags] A list of Tag. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Tags + * + * @returns {object} metadata of Tags + * + */ + mapper() { + return { + required: false, + serializedName: 'Tags', + type: { + name: 'Composite', + className: 'Tags', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + eTag: { + required: false, + serializedName: 'eTag', + type: { + name: 'String' + } + }, + tags: { + required: false, + serializedName: 'properties.tags', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'TagElementType', + type: { + name: 'Composite', + className: 'Tag' + } + } + } + } + } + } + }; + } +} + +module.exports = Tags; diff --git a/lib/services/consumptionManagement/lib/operations/costTagsOperations.js b/lib/services/consumptionManagement/lib/operations/costTagsOperations.js new file mode 100644 index 0000000000..0f611d849a --- /dev/null +++ b/lib/services/consumptionManagement/lib/operations/costTagsOperations.js @@ -0,0 +1,537 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Get cost tags for a billing account. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link CostTags} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(billingAccountId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.CostManagement/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/costTags'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['CostTags']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * The operation to create or update cost tags assiciated with a billing + * account. Update operation requires latest eTag to be set in the request + * mandatorily. You may obtain the latest eTag by performing a get operation. + * Create operation does not require eTag. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} parameters Parameters supplied to the Create cost tags + * operation. + * + * @param {array} [parameters.costTags] Cost tags. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link CostTags} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(billingAccountId, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.CostManagement/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/costTags'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['CostTags']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['CostTags']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['CostTags']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a CostTagsOperations. */ +class CostTagsOperations { + /** + * Create a CostTagsOperations. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + } + + /** + * Get cost tags for a billing account. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(billingAccountId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get cost tags for a billing account. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {CostTags} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link CostTags} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(billingAccountId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(billingAccountId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountId, options, optionalCallback); + } + } + + /** + * The operation to create or update cost tags assiciated with a billing + * account. Update operation requires latest eTag to be set in the request + * mandatorily. You may obtain the latest eTag by performing a get operation. + * Create operation does not require eTag. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} parameters Parameters supplied to the Create cost tags + * operation. + * + * @param {array} [parameters.costTags] Cost tags. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createOrUpdateWithHttpOperationResponse(billingAccountId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(billingAccountId, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * The operation to create or update cost tags assiciated with a billing + * account. Update operation requires latest eTag to be set in the request + * mandatorily. You may obtain the latest eTag by performing a get operation. + * Create operation does not require eTag. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} parameters Parameters supplied to the Create cost tags + * operation. + * + * @param {array} [parameters.costTags] Cost tags. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {CostTags} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link CostTags} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(billingAccountId, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(billingAccountId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(billingAccountId, parameters, options, optionalCallback); + } + } + +} + +module.exports = CostTagsOperations; diff --git a/lib/services/consumptionManagement/lib/operations/index.d.ts b/lib/services/consumptionManagement/lib/operations/index.d.ts index 6835239a43..b10afb5c8f 100644 --- a/lib/services/consumptionManagement/lib/operations/index.d.ts +++ b/lib/services/consumptionManagement/lib/operations/index.d.ts @@ -2350,15 +2350,15 @@ export interface PriceSheet { /** * @class - * CostAllocationTagsOperations + * CostTagsOperations * __NOTE__: An instance of this class is automatically created for an * instance of the ConsumptionManagementClient. */ -export interface CostAllocationTagsOperations { +export interface CostTagsOperations { /** - * Get cost allocation tags for a billing account. + * Get cost tags for a billing account. * * @param {string} billingAccountId Azure Billing Account ID. * @@ -2369,14 +2369,14 @@ export interface CostAllocationTagsOperations { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - getWithHttpOperationResponse(billingAccountId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + getWithHttpOperationResponse(billingAccountId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Get cost allocation tags for a billing account. + * Get cost tags for a billing account. * * @param {string} billingAccountId Azure Billing Account ID. * @@ -2392,7 +2392,7 @@ export interface CostAllocationTagsOperations { * * {Promise} A promise is returned. * - * @resolve {CostAllocationTags} - The deserialized result object. + * @resolve {CostTags} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -2400,30 +2400,30 @@ export interface CostAllocationTagsOperations { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {CostAllocationTags} [result] - The deserialized result object if an error did not occur. - * See {@link CostAllocationTags} for more information. + * {CostTags} [result] - The deserialized result object if an error did not occur. + * See {@link CostTags} for more information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - get(billingAccountId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - get(billingAccountId: string, callback: ServiceCallback): void; - get(billingAccountId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + get(billingAccountId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountId: string, callback: ServiceCallback): void; + get(billingAccountId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * The operation to create or update cost allocation tags assiciated with a - * billing account. Update operation requires latest eTag to be set in the - * request mandatorily. You may obtain the latest eTag by performing a get - * operation. Create operation does not require eTag. + * The operation to create or update cost tags assiciated with a billing + * account. Update operation requires latest eTag to be set in the request + * mandatorily. You may obtain the latest eTag by performing a get operation. + * Create operation does not require eTag. * * @param {string} billingAccountId Azure Billing Account ID. * - * @param {object} parameters Parameters supplied to the Create cost allocation - * tags operation. + * @param {object} parameters Parameters supplied to the Create cost tags + * operation. * - * @param {array} [parameters.costAllocationTags] Cost allocation tags. + * @param {array} [parameters.costTags] Cost tags. * * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent * update scenarion, this field will be used to determine whether the user is @@ -2436,24 +2436,24 @@ export interface CostAllocationTagsOperations { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - createOrUpdateWithHttpOperationResponse(billingAccountId: string, parameters: models.CostAllocationTags, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + createOrUpdateWithHttpOperationResponse(billingAccountId: string, parameters: models.CostTags, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * The operation to create or update cost allocation tags assiciated with a - * billing account. Update operation requires latest eTag to be set in the - * request mandatorily. You may obtain the latest eTag by performing a get - * operation. Create operation does not require eTag. + * The operation to create or update cost tags assiciated with a billing + * account. Update operation requires latest eTag to be set in the request + * mandatorily. You may obtain the latest eTag by performing a get operation. + * Create operation does not require eTag. * * @param {string} billingAccountId Azure Billing Account ID. * - * @param {object} parameters Parameters supplied to the Create cost allocation - * tags operation. + * @param {object} parameters Parameters supplied to the Create cost tags + * operation. * - * @param {array} [parameters.costAllocationTags] Cost allocation tags. + * @param {array} [parameters.costTags] Cost tags. * * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent * update scenarion, this field will be used to determine whether the user is @@ -2471,7 +2471,71 @@ export interface CostAllocationTagsOperations { * * {Promise} A promise is returned. * - * @resolve {CostAllocationTags} - The deserialized result object. + * @resolve {CostTags} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {CostTags} [result] - The deserialized result object if an error did not occur. + * See {@link CostTags} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(billingAccountId: string, parameters: models.CostTags, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(billingAccountId: string, parameters: models.CostTags, callback: ServiceCallback): void; + createOrUpdate(billingAccountId: string, parameters: models.CostTags, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * TagsOperations + * __NOTE__: An instance of this class is automatically created for an + * instance of the ConsumptionManagementClient. + */ +export interface TagsOperations { + + + /** + * Get all available tag keys for a billing account. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(billingAccountId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get all available tag keys for a billing account. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Tags} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -2479,14 +2543,14 @@ export interface CostAllocationTagsOperations { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {CostAllocationTags} [result] - The deserialized result object if an error did not occur. - * See {@link CostAllocationTags} for more information. + * {Tags} [result] - The deserialized result object if an error did not occur. + * See {@link Tags} for more information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - createOrUpdate(billingAccountId: string, parameters: models.CostAllocationTags, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - createOrUpdate(billingAccountId: string, parameters: models.CostAllocationTags, callback: ServiceCallback): void; - createOrUpdate(billingAccountId: string, parameters: models.CostAllocationTags, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + get(billingAccountId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountId: string, callback: ServiceCallback): void; + get(billingAccountId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } diff --git a/lib/services/consumptionManagement/lib/operations/index.js b/lib/services/consumptionManagement/lib/operations/index.js index 252d834305..02121b8f57 100644 --- a/lib/services/consumptionManagement/lib/operations/index.js +++ b/lib/services/consumptionManagement/lib/operations/index.js @@ -22,4 +22,5 @@ exports.ReservationRecommendationsOperations = require('./reservationRecommendat exports.Budgets = require('./budgets'); exports.Operations = require('./operations'); exports.PriceSheet = require('./priceSheet'); -exports.CostAllocationTagsOperations = require('./costAllocationTagsOperations'); +exports.CostTagsOperations = require('./costTagsOperations'); +exports.TagsOperations = require('./tagsOperations'); diff --git a/lib/services/consumptionManagement/lib/operations/tagsOperations.js b/lib/services/consumptionManagement/lib/operations/tagsOperations.js new file mode 100644 index 0000000000..5b50ec1792 --- /dev/null +++ b/lib/services/consumptionManagement/lib/operations/tagsOperations.js @@ -0,0 +1,248 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Get all available tag keys for a billing account. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Tags} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(billingAccountId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.CostManagement/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/tags'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Tags']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a TagsOperations. */ +class TagsOperations { + /** + * Create a TagsOperations. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + } + + /** + * Get all available tag keys for a billing account. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(billingAccountId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get all available tag keys for a billing account. + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Tags} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Tags} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(billingAccountId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(billingAccountId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountId, options, optionalCallback); + } + } + +} + +module.exports = TagsOperations; diff --git a/lib/services/consumptionManagement/package.json b/lib/services/consumptionManagement/package.json index e1e34fa462..ec4c66f026 100644 --- a/lib/services/consumptionManagement/package.json +++ b/lib/services/consumptionManagement/package.json @@ -1,35 +1,22 @@ { "name": "azure-arm-consumption", "author": "Microsoft Corporation", - "contributors": [ - "Zavery, Amar " - ], + "description": "ConsumptionManagementClient Library with typescript type definitions for node", "version": "3.1.0", - "description": "Microsoft Azure Consumption Management Client Library for node", - "tags": [ - "azure", - "sdk" - ], - "keywords": [ - "node", - "azure" - ], - "main": "./lib/consumptionManagementClient.js", - "types": "./lib/consumptionManagementClient.d.ts", - "license": "MIT", "dependencies": { - "ms-rest": "^2.3.0", - "ms-rest-azure": "^2.5.2" + "ms-rest": "^2.3.2", + "ms-rest-azure": "^2.5.5" }, - "homepage": "http://github.com/Azure/azure-sdk-for-node", + "keywords": [ "node", "azure" ], + "license": "MIT", + "main": "./lib/consumptionManagementClient.js", + "types": "./lib/consumptionManagementClient.d.ts", + "homepage": "http://github.com/azure/azure-sdk-for-node", "repository": { "type": "git", - "url": "git@github.com:Azure/azure-sdk-for-node.git" + "url": "https://github.com/azure/azure-sdk-for-node.git" }, "bugs": { "url": "http://github.com/Azure/azure-sdk-for-node/issues" - }, - "scripts": { - "test": "npm -s run-script jshint" } } From d9fe6410503d3b4f9033e22cdb775494485a975a Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 29 May 2018 23:55:56 -0700 Subject: [PATCH 3/5] [AutoPR consumption/resource-manager] Adding swagger for new api-version consumption 2018-05-31, introducing new Forecast api swagger (#2888) * Generated from 25b0d1453bdaa98490469e256ae818f67a4472c0 Forecast Api swagger * Generated from b837fe768eb097b3fc2e90f3a4e1f393ff6831dc consumption readme file update for the new swagger version * Generated from 75834e902cf575b384abc67d9934b74f8e2b64f0 addressing review comment on adding nextLink * Generated from a40766016116112dbd0d8c66b60a117c3e20fc9d fixing build error * Generated from eadf28195eb82433cf2003d9f5c42640d3b6e80e Addressed feedback on enum and fixed a typo --- lib/services/consumptionManagement/README.md | 8 +- .../lib/consumptionManagementClient.d.ts | 10 +- .../lib/consumptionManagementClient.js | 12 +- .../lib/models/balance.js | 243 ++ .../balancePropertiesAdjustmentDetailsItem.js | 61 + ...alancePropertiesNewPurchasesDetailsItem.js | 61 + .../lib/models/forecast.js | 151 ++ .../forecastPropertiesConfidenceLevelsItem.js | 71 + .../lib/models/forecastsListResult.js | 60 + .../lib/models/index.d.ts | 685 +---- .../consumptionManagement/lib/models/index.js | 31 +- .../lib/models/queryOptions.js | 5 +- .../lib/operations/costTagsOperations.js | 16 +- .../lib/operations/forecasts.js | 264 ++ .../operations/getBalancesByBillingAccount.js | 261 ++ .../lib/operations/index.d.ts | 2396 +---------------- .../lib/operations/index.js | 10 +- .../lib/operations/marketplaces.js | 30 +- .../marketplacesByBillingAccount.js | 1075 ++++++++ .../operations/marketplacesByDepartment.js | 1075 ++++++++ .../marketplacesByEnrollmentAccounts.js | 1081 ++++++++ .../lib/operations/tagsOperations.js | 6 +- .../lib/operations/usageDetails.js | 36 +- .../usageDetailsByBillingAccount.js | 1199 +++++++++ .../operations/usageDetailsByDepartment.js | 1199 +++++++++ .../usageDetailsByEnrollmentAccount.js | 1199 +++++++++ .../consumptionManagement/package.json | 7 +- 27 files changed, 8126 insertions(+), 3126 deletions(-) create mode 100644 lib/services/consumptionManagement/lib/models/balance.js create mode 100644 lib/services/consumptionManagement/lib/models/balancePropertiesAdjustmentDetailsItem.js create mode 100644 lib/services/consumptionManagement/lib/models/balancePropertiesNewPurchasesDetailsItem.js create mode 100644 lib/services/consumptionManagement/lib/models/forecast.js create mode 100644 lib/services/consumptionManagement/lib/models/forecastPropertiesConfidenceLevelsItem.js create mode 100644 lib/services/consumptionManagement/lib/models/forecastsListResult.js create mode 100644 lib/services/consumptionManagement/lib/operations/forecasts.js create mode 100644 lib/services/consumptionManagement/lib/operations/getBalancesByBillingAccount.js create mode 100644 lib/services/consumptionManagement/lib/operations/marketplacesByBillingAccount.js create mode 100644 lib/services/consumptionManagement/lib/operations/marketplacesByDepartment.js create mode 100644 lib/services/consumptionManagement/lib/operations/marketplacesByEnrollmentAccounts.js create mode 100644 lib/services/consumptionManagement/lib/operations/usageDetailsByBillingAccount.js create mode 100644 lib/services/consumptionManagement/lib/operations/usageDetailsByDepartment.js create mode 100644 lib/services/consumptionManagement/lib/operations/usageDetailsByEnrollmentAccount.js diff --git a/lib/services/consumptionManagement/README.md b/lib/services/consumptionManagement/README.md index fa6d0fd678..c1457c7e45 100644 --- a/lib/services/consumptionManagement/README.md +++ b/lib/services/consumptionManagement/README.md @@ -18,7 +18,7 @@ npm install azure-arm-consumption ## How to use -### Authentication, client creation and list usageDetails as an example. +### Authentication, client creation and list forecasts as an example. ```javascript const msRestAzure = require("ms-rest-azure"); @@ -26,12 +26,8 @@ const ConsumptionManagementClient = require("azure-arm-consumption"); msRestAzure.interactiveLogin().then((creds) => { const subscriptionId = ""; const client = new ConsumptionManagementClient(creds, subscriptionId); - const expand = "testexpand"; const filter = "testfilter"; - const skiptoken = "testskiptoken"; - const top = 1; - const apply = "testapply"; - return client.usageDetails.list(expand, filter, skiptoken, top, apply).then((result) => { + return client.forecasts.list(filter).then((result) => { console.log("The result is:"); console.log(result); }); diff --git a/lib/services/consumptionManagement/lib/consumptionManagementClient.d.ts b/lib/services/consumptionManagement/lib/consumptionManagementClient.d.ts index 872911c5e1..41286db70f 100644 --- a/lib/services/consumptionManagement/lib/consumptionManagementClient.d.ts +++ b/lib/services/consumptionManagement/lib/consumptionManagementClient.d.ts @@ -56,16 +56,8 @@ export default class ConsumptionManagementClient extends AzureServiceClient { generateClientRequestId: boolean; // Operation groups - usageDetails: operations.UsageDetails; - marketplaces: operations.Marketplaces; - reservationsSummaries: operations.ReservationsSummaries; - reservationsDetails: operations.ReservationsDetails; - reservationRecommendationsOperations: operations.ReservationRecommendationsOperations; - budgets: operations.Budgets; + forecasts: operations.Forecasts; operations: operations.Operations; - priceSheet: operations.PriceSheet; - costTagsOperations: operations.CostTagsOperations; - tagsOperations: operations.TagsOperations; } export { ConsumptionManagementClient, models as ConsumptionManagementModels }; diff --git a/lib/services/consumptionManagement/lib/consumptionManagementClient.js b/lib/services/consumptionManagement/lib/consumptionManagementClient.js index 98c1b22386..31bb8c5667 100644 --- a/lib/services/consumptionManagement/lib/consumptionManagementClient.js +++ b/lib/services/consumptionManagement/lib/consumptionManagementClient.js @@ -50,7 +50,7 @@ class ConsumptionManagementClient extends ServiceClient { super(credentials, options); - this.apiVersion = '2018-03-31'; + this.apiVersion = '2018-05-31'; this.acceptLanguage = 'en-US'; this.longRunningOperationRetryTimeout = 30; this.generateClientRequestId = true; @@ -72,16 +72,8 @@ class ConsumptionManagementClient extends ServiceClient { if(options.generateClientRequestId !== null && options.generateClientRequestId !== undefined) { this.generateClientRequestId = options.generateClientRequestId; } - this.usageDetails = new operations.UsageDetails(this); - this.marketplaces = new operations.Marketplaces(this); - this.reservationsSummaries = new operations.ReservationsSummaries(this); - this.reservationsDetails = new operations.ReservationsDetails(this); - this.reservationRecommendationsOperations = new operations.ReservationRecommendationsOperations(this); - this.budgets = new operations.Budgets(this); + this.forecasts = new operations.Forecasts(this); this.operations = new operations.Operations(this); - this.priceSheet = new operations.PriceSheet(this); - this.costTagsOperations = new operations.CostTagsOperations(this); - this.tagsOperations = new operations.TagsOperations(this); this.models = models; msRest.addSerializationMixin(this); } diff --git a/lib/services/consumptionManagement/lib/models/balance.js b/lib/services/consumptionManagement/lib/models/balance.js new file mode 100644 index 0000000000..2f4ca9afbf --- /dev/null +++ b/lib/services/consumptionManagement/lib/models/balance.js @@ -0,0 +1,243 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * A balance resource. + * + * @extends models['Resource'] + */ +class Balance extends models['Resource'] { + /** + * Create a Balance. + * @member {string} [currency] The ISO currency in which the meter is + * charged, for example, USD. + * @member {number} [beginningBalance] The beginning balance for the billing + * period. + * @member {number} [endingBalance] The ending balance for the billing period + * (for open periods this will be updated daily). + * @member {number} [newPurchases] Total new purchase amount. + * @member {number} [adjustments] Total adjustment amount. + * @member {number} [utilized] Total Commitment usage. + * @member {number} [serviceOverage] Overage for Azure services. + * @member {number} [chargesBilledSeparately] Charges Billed separately. + * @member {number} [totalOverage] serviceOverage + chargesBilledSeparately. + * @member {number} [totalUsage] Azure service commitment + total Overage. + * @member {number} [azureMarketplaceServiceCharges] Total charges for Azure + * Marketplace. + * @member {string} [billingFrequency] The billing frequency. Possible values + * include: 'Month', 'Quarter', 'Year' + * @member {boolean} [priceHidden] Price is hidden or not. + * @member {array} [newPurchasesDetails] List of new purchases. + * @member {array} [adjustmentDetails] List of Adjustments (Promo credit, SIE + * credit etc.). + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Balance + * + * @returns {object} metadata of Balance + * + */ + mapper() { + return { + required: false, + serializedName: 'Balance', + type: { + name: 'Composite', + className: 'Balance', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + tags: { + required: false, + readOnly: true, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + currency: { + required: false, + readOnly: true, + serializedName: 'properties.currency', + type: { + name: 'String' + } + }, + beginningBalance: { + required: false, + readOnly: true, + serializedName: 'properties.beginningBalance', + type: { + name: 'Number' + } + }, + endingBalance: { + required: false, + readOnly: true, + serializedName: 'properties.endingBalance', + type: { + name: 'Number' + } + }, + newPurchases: { + required: false, + readOnly: true, + serializedName: 'properties.newPurchases', + type: { + name: 'Number' + } + }, + adjustments: { + required: false, + readOnly: true, + serializedName: 'properties.adjustments', + type: { + name: 'Number' + } + }, + utilized: { + required: false, + readOnly: true, + serializedName: 'properties.utilized', + type: { + name: 'Number' + } + }, + serviceOverage: { + required: false, + readOnly: true, + serializedName: 'properties.serviceOverage', + type: { + name: 'Number' + } + }, + chargesBilledSeparately: { + required: false, + readOnly: true, + serializedName: 'properties.chargesBilledSeparately', + type: { + name: 'Number' + } + }, + totalOverage: { + required: false, + readOnly: true, + serializedName: 'properties.totalOverage', + type: { + name: 'Number' + } + }, + totalUsage: { + required: false, + readOnly: true, + serializedName: 'properties.totalUsage', + type: { + name: 'Number' + } + }, + azureMarketplaceServiceCharges: { + required: false, + readOnly: true, + serializedName: 'properties.azureMarketplaceServiceCharges', + type: { + name: 'Number' + } + }, + billingFrequency: { + required: false, + serializedName: 'properties.billingFrequency', + type: { + name: 'String' + } + }, + priceHidden: { + required: false, + readOnly: true, + serializedName: 'properties.priceHidden', + type: { + name: 'Boolean' + } + }, + newPurchasesDetails: { + required: false, + readOnly: true, + serializedName: 'properties.newPurchasesDetails', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'BalancePropertiesNewPurchasesDetailsItemElementType', + type: { + name: 'Composite', + className: 'BalancePropertiesNewPurchasesDetailsItem' + } + } + } + }, + adjustmentDetails: { + required: false, + readOnly: true, + serializedName: 'properties.adjustmentDetails', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'BalancePropertiesAdjustmentDetailsItemElementType', + type: { + name: 'Composite', + className: 'BalancePropertiesAdjustmentDetailsItem' + } + } + } + } + } + } + }; + } +} + +module.exports = Balance; diff --git a/lib/services/consumptionManagement/lib/models/balancePropertiesAdjustmentDetailsItem.js b/lib/services/consumptionManagement/lib/models/balancePropertiesAdjustmentDetailsItem.js new file mode 100644 index 0000000000..f3c1544c66 --- /dev/null +++ b/lib/services/consumptionManagement/lib/models/balancePropertiesAdjustmentDetailsItem.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Class representing a BalancePropertiesAdjustmentDetailsItem. + */ +class BalancePropertiesAdjustmentDetailsItem { + /** + * Create a BalancePropertiesAdjustmentDetailsItem. + * @member {string} [name] the name of new adjustment. + * @member {number} [value] the value of new adjustment. + */ + constructor() { + } + + /** + * Defines the metadata of BalancePropertiesAdjustmentDetailsItem + * + * @returns {object} metadata of BalancePropertiesAdjustmentDetailsItem + * + */ + mapper() { + return { + required: false, + serializedName: 'BalanceProperties_adjustmentDetailsItem', + type: { + name: 'Composite', + className: 'BalancePropertiesAdjustmentDetailsItem', + modelProperties: { + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + value: { + required: false, + readOnly: true, + serializedName: 'value', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = BalancePropertiesAdjustmentDetailsItem; diff --git a/lib/services/consumptionManagement/lib/models/balancePropertiesNewPurchasesDetailsItem.js b/lib/services/consumptionManagement/lib/models/balancePropertiesNewPurchasesDetailsItem.js new file mode 100644 index 0000000000..dbe1bcbc70 --- /dev/null +++ b/lib/services/consumptionManagement/lib/models/balancePropertiesNewPurchasesDetailsItem.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Class representing a BalancePropertiesNewPurchasesDetailsItem. + */ +class BalancePropertiesNewPurchasesDetailsItem { + /** + * Create a BalancePropertiesNewPurchasesDetailsItem. + * @member {string} [name] the name of new purchase. + * @member {number} [value] the value of new purchase. + */ + constructor() { + } + + /** + * Defines the metadata of BalancePropertiesNewPurchasesDetailsItem + * + * @returns {object} metadata of BalancePropertiesNewPurchasesDetailsItem + * + */ + mapper() { + return { + required: false, + serializedName: 'BalanceProperties_newPurchasesDetailsItem', + type: { + name: 'Composite', + className: 'BalancePropertiesNewPurchasesDetailsItem', + modelProperties: { + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + value: { + required: false, + readOnly: true, + serializedName: 'value', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = BalancePropertiesNewPurchasesDetailsItem; diff --git a/lib/services/consumptionManagement/lib/models/forecast.js b/lib/services/consumptionManagement/lib/models/forecast.js new file mode 100644 index 0000000000..73ac2c7191 --- /dev/null +++ b/lib/services/consumptionManagement/lib/models/forecast.js @@ -0,0 +1,151 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * A forecast resource. + * + * @extends models['Resource'] + */ +class Forecast extends models['Resource'] { + /** + * Create a Forecast. + * @member {string} [usageDate] The usage date of the forecast. + * @member {string} [grain] The granularity of forecast. Possible values + * include: 'Daily', 'Monthly', 'Yearly' + * @member {number} [charge] The amount of charge + * @member {string} [currency] The ISO currency in which the meter is + * charged, for example, USD. + * @member {string} [chargeType] The type of the charge. Could be actual or + * forecast. Possible values include: 'Actual', 'Forecast' + * @member {array} [confidenceLevels] The details about the forecast + * confidence levels. This is populated only when chargeType is Forecast. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Forecast + * + * @returns {object} metadata of Forecast + * + */ + mapper() { + return { + required: false, + serializedName: 'Forecast', + type: { + name: 'Composite', + className: 'Forecast', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + tags: { + required: false, + readOnly: true, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + usageDate: { + required: false, + readOnly: true, + serializedName: 'properties.usageDate', + type: { + name: 'String' + } + }, + grain: { + required: false, + serializedName: 'properties.grain', + type: { + name: 'String' + } + }, + charge: { + required: false, + readOnly: true, + serializedName: 'properties.charge', + type: { + name: 'Number' + } + }, + currency: { + required: false, + readOnly: true, + serializedName: 'properties.currency', + type: { + name: 'String' + } + }, + chargeType: { + required: false, + serializedName: 'properties.chargeType', + type: { + name: 'String' + } + }, + confidenceLevels: { + required: false, + readOnly: true, + serializedName: 'properties.confidenceLevels', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ForecastPropertiesConfidenceLevelsItemElementType', + type: { + name: 'Composite', + className: 'ForecastPropertiesConfidenceLevelsItem' + } + } + } + } + } + } + }; + } +} + +module.exports = Forecast; diff --git a/lib/services/consumptionManagement/lib/models/forecastPropertiesConfidenceLevelsItem.js b/lib/services/consumptionManagement/lib/models/forecastPropertiesConfidenceLevelsItem.js new file mode 100644 index 0000000000..d20b45d961 --- /dev/null +++ b/lib/services/consumptionManagement/lib/models/forecastPropertiesConfidenceLevelsItem.js @@ -0,0 +1,71 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Class representing a ForecastPropertiesConfidenceLevelsItem. + */ +class ForecastPropertiesConfidenceLevelsItem { + /** + * Create a ForecastPropertiesConfidenceLevelsItem. + * @member {number} [percentage] The percentage level of the confidence + * @member {string} [bound] The boundary of the percentage, values could be + * 'Upper' or 'Lower'. Possible values include: 'Upper', 'Lower' + * @member {number} [value] The amount of forecast within the percentage + * level + */ + constructor() { + } + + /** + * Defines the metadata of ForecastPropertiesConfidenceLevelsItem + * + * @returns {object} metadata of ForecastPropertiesConfidenceLevelsItem + * + */ + mapper() { + return { + required: false, + serializedName: 'ForecastProperties_confidenceLevelsItem', + type: { + name: 'Composite', + className: 'ForecastPropertiesConfidenceLevelsItem', + modelProperties: { + percentage: { + required: false, + readOnly: true, + serializedName: 'percentage', + type: { + name: 'Number' + } + }, + bound: { + required: false, + serializedName: 'bound', + type: { + name: 'String' + } + }, + value: { + required: false, + readOnly: true, + serializedName: 'value', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = ForecastPropertiesConfidenceLevelsItem; diff --git a/lib/services/consumptionManagement/lib/models/forecastsListResult.js b/lib/services/consumptionManagement/lib/models/forecastsListResult.js new file mode 100644 index 0000000000..ed3654ae64 --- /dev/null +++ b/lib/services/consumptionManagement/lib/models/forecastsListResult.js @@ -0,0 +1,60 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Result of listing forecasts. It contains a list of available forecasts. + */ +class ForecastsListResult extends Array { + /** + * Create a ForecastsListResult. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ForecastsListResult + * + * @returns {object} metadata of ForecastsListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'ForecastsListResult', + type: { + name: 'Composite', + className: 'ForecastsListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ForecastElementType', + type: { + name: 'Composite', + className: 'Forecast' + } + } + } + } + } + } + }; + } +} + +module.exports = ForecastsListResult; diff --git a/lib/services/consumptionManagement/lib/models/index.d.ts b/lib/services/consumptionManagement/lib/models/index.d.ts index e98fac3993..ea10d9f528 100644 --- a/lib/services/consumptionManagement/lib/models/index.d.ts +++ b/lib/services/consumptionManagement/lib/models/index.d.ts @@ -16,518 +16,6 @@ export { BaseResource } from 'ms-rest-azure'; export { CloudError } from 'ms-rest-azure'; -/** - * @class - * Initializes a new instance of the MeterDetails class. - * @constructor - * The properties of the meter detail. - * - * @member {string} [meterName] The name of the meter, within the given meter - * category - * @member {string} [meterCategory] The category of the meter, for example, - * 'Cloud services', 'Networking', etc.. - * @member {string} [meterSubCategory] The subcategory of the meter, for - * example, 'A6 Cloud services', 'ExpressRoute (IXP)', etc.. - * @member {string} [unit] The unit in which the meter consumption is charged, - * for example, 'Hours', 'GB', etc. - * @member {string} [meterLocation] The location in which the Azure service is - * available. - * @member {number} [totalIncludedQuantity] The total included quantity - * associated with the offer. - * @member {number} [pretaxStandardRate] The pretax listing price. - */ -export interface MeterDetails { - readonly meterName?: string; - readonly meterCategory?: string; - readonly meterSubCategory?: string; - readonly unit?: string; - readonly meterLocation?: string; - readonly totalIncludedQuantity?: number; - readonly pretaxStandardRate?: number; -} - -/** - * @class - * Initializes a new instance of the Resource class. - * @constructor - * The Resource model definition. - * - * @member {string} [id] Resource Id. - * @member {string} [name] Resource name. - * @member {string} [type] Resource type. - * @member {object} [tags] Resource tags. - */ -export interface Resource extends BaseResource { - readonly id?: string; - readonly name?: string; - readonly type?: string; - readonly tags?: { [propertyName: string]: string }; -} - -/** - * @class - * Initializes a new instance of the UsageDetail class. - * @constructor - * An usage detail resource. - * - * @member {string} [billingPeriodId] The id of the billing period resource - * that the usage belongs to. - * @member {string} [invoiceId] The id of the invoice resource that the usage - * belongs to. - * @member {date} [usageStart] The start of the date time range covered by the - * usage detail. - * @member {date} [usageEnd] The end of the date time range covered by the - * usage detail. - * @member {string} [instanceName] The name of the resource instance that the - * usage is about. - * @member {string} [instanceId] The uri of the resource instance that the - * usage is about. - * @member {string} [instanceLocation] The location of the resource instance - * that the usage is about. - * @member {string} [currency] The ISO currency in which the meter is charged, - * for example, USD. - * @member {number} [usageQuantity] The quantity of usage. - * @member {number} [billableQuantity] The billable usage quantity. - * @member {number} [pretaxCost] The amount of cost before tax. - * @member {boolean} [isEstimated] The estimated usage is subject to change. - * @member {uuid} [meterId] The meter id (GUID). - * @member {object} [meterDetails] The details about the meter. By default this - * is not populated, unless it's specified in $expand. - * @member {string} [meterDetails.meterName] The name of the meter, within the - * given meter category - * @member {string} [meterDetails.meterCategory] The category of the meter, for - * example, 'Cloud services', 'Networking', etc.. - * @member {string} [meterDetails.meterSubCategory] The subcategory of the - * meter, for example, 'A6 Cloud services', 'ExpressRoute (IXP)', etc.. - * @member {string} [meterDetails.unit] The unit in which the meter consumption - * is charged, for example, 'Hours', 'GB', etc. - * @member {string} [meterDetails.meterLocation] The location in which the - * Azure service is available. - * @member {number} [meterDetails.totalIncludedQuantity] The total included - * quantity associated with the offer. - * @member {number} [meterDetails.pretaxStandardRate] The pretax listing price. - * @member {uuid} [subscriptionGuid] Subscription guid. - * @member {string} [subscriptionName] Subscription name. - * @member {string} [accountName] Account name. - * @member {string} [departmentName] Department name. - * @member {string} [product] Product name. - * @member {string} [consumedService] Consumed service name. - * @member {string} [costCenter] The cost center of this department if it is a - * department and a costcenter exists - * @member {string} [additionalProperties] Additional details of this usage - * item. By default this is not populated, unless it's specified in $expand. - */ -export interface UsageDetail extends Resource { - readonly billingPeriodId?: string; - readonly invoiceId?: string; - readonly usageStart?: Date; - readonly usageEnd?: Date; - readonly instanceName?: string; - readonly instanceId?: string; - readonly instanceLocation?: string; - readonly currency?: string; - readonly usageQuantity?: number; - readonly billableQuantity?: number; - readonly pretaxCost?: number; - readonly isEstimated?: boolean; - readonly meterId?: string; - readonly meterDetails?: MeterDetails; - readonly subscriptionGuid?: string; - readonly subscriptionName?: string; - readonly accountName?: string; - readonly departmentName?: string; - readonly product?: string; - readonly consumedService?: string; - readonly costCenter?: string; - readonly additionalProperties?: string; -} - -/** - * @class - * Initializes a new instance of the Marketplace class. - * @constructor - * An marketplace resource. - * - * @member {string} [billingPeriodId] The id of the billing period resource - * that the usage belongs to. - * @member {date} [usageStart] The start of the date time range covered by the - * usage detail. - * @member {date} [usageEnd] The end of the date time range covered by the - * usage detail. - * @member {number} [resourceRate] The marketplace resource rate. - * @member {string} [offerName] The type of offer. - * @member {string} [resourceGroup] The name of resource group. - * @member {string} [orderNumber] The order number. - * @member {string} [instanceName] The name of the resource instance that the - * usage is about. - * @member {string} [instanceId] The uri of the resource instance that the - * usage is about. - * @member {string} [currency] The ISO currency in which the meter is charged, - * for example, USD. - * @member {number} [consumedQuantity] The quantity of usage. - * @member {string} [unitOfMeasure] The unit of measure. - * @member {number} [pretaxCost] The amount of cost before tax. - * @member {boolean} [isEstimated] The estimated usage is subject to change. - * @member {uuid} [meterId] The meter id (GUID). - * @member {uuid} [subscriptionGuid] Subscription guid. - * @member {string} [subscriptionName] Subscription name. - * @member {string} [accountName] Account name. - * @member {string} [departmentName] Department name. - * @member {string} [consumedService] Consumed service name. - * @member {string} [costCenter] The cost center of this department if it is a - * department and a costcenter exists - * @member {string} [additionalProperties] Additional details of this usage - * item. By default this is not populated, unless it's specified in $expand. - * @member {string} [publisherName] The name of publisher. - * @member {string} [planName] The name of plan. - */ -export interface Marketplace extends Resource { - readonly billingPeriodId?: string; - readonly usageStart?: Date; - readonly usageEnd?: Date; - readonly resourceRate?: number; - readonly offerName?: string; - readonly resourceGroup?: string; - readonly orderNumber?: string; - readonly instanceName?: string; - readonly instanceId?: string; - readonly currency?: string; - readonly consumedQuantity?: number; - readonly unitOfMeasure?: string; - readonly pretaxCost?: number; - readonly isEstimated?: boolean; - readonly meterId?: string; - readonly subscriptionGuid?: string; - readonly subscriptionName?: string; - readonly accountName?: string; - readonly departmentName?: string; - readonly consumedService?: string; - readonly costCenter?: string; - readonly additionalProperties?: string; - readonly publisherName?: string; - readonly planName?: string; -} - -/** - * @class - * Initializes a new instance of the ReservationSummaries class. - * @constructor - * reservation summaries resource. - * - * @member {string} [reservationOrderId] The reservation order ID is the - * identifier for a reservation purchase. Each reservation order ID represents - * a single purchase transaction. A reservation order contains reservations. - * The reservation order specifies the VM size and region for the reservations. - * @member {string} [reservationId] The reservation ID is the identifier of a - * reservation within a reservation order. Each reservation is the grouping for - * applying the benefit scope and also specifies the number of instances to - * which the reservation benefit can be applied to. - * @member {string} [skuName] This is the ARM Sku name. It can be used to join - * with the servicetype field in additoinalinfo in usage records. - * @member {number} [reservedHours] This is the total hours reserved. E.g. if - * reservation for 1 instance was made on 1 PM, this will be 11 hours for that - * day and 24 hours from subsequent days - * @member {date} [usageDate] Data corresponding to the utilization record. If - * the grain of data is monthly, it will be first day of month. - * @member {number} [usedHours] Total used hours by the reservation - * @member {number} [minUtilizationPercentage] This is the minimum hourly - * utilization in the usage time (day or month). E.g. if usage record - * corresponds to 12/10/2017 and on that for hour 4 and 5, utilization was 10%, - * this field will return 10% for that day - * @member {number} [avgUtilizationPercentage] This is average utilization for - * the entire time range. (day or month depending on the grain) - * @member {number} [maxUtilizationPercentage] This is the maximum hourly - * utilization in the usage time (day or month). E.g. if usage record - * corresponds to 12/10/2017 and on that for hour 4 and 5, utilization was - * 100%, this field will return 100% for that day. - */ -export interface ReservationSummaries extends Resource { - readonly reservationOrderId?: string; - readonly reservationId?: string; - readonly skuName?: string; - readonly reservedHours?: number; - readonly usageDate?: Date; - readonly usedHours?: number; - readonly minUtilizationPercentage?: number; - readonly avgUtilizationPercentage?: number; - readonly maxUtilizationPercentage?: number; -} - -/** - * @class - * Initializes a new instance of the ReservationDetails class. - * @constructor - * reservation details resource. - * - * @member {string} [reservationOrderId] The reservation order ID is the - * identifier for a reservation purchase. Each reservation order ID represents - * a single purchase transaction. A reservation order contains reservations. - * The reservation order specifies the VM size and region for the reservations. - * @member {string} [reservationId] The reservation ID is the identifier of a - * reservation within a reservation order. Each reservation is the grouping for - * applying the benefit scope and also specifies the number of instances to - * which the reservation benefit can be applied to. - * @member {string} [skuName] This is the ARM Sku name. It can be used to join - * with the servicetype field in additoinalinfo in usage records. - * @member {number} [reservedHours] This is the total hours reserved for the - * day. E.g. if reservation for 1 instance was made on 1 PM, this will be 11 - * hours for that day and 24 hours from subsequent days. - * @member {date} [usageDate] The date on which consumption occurred. - * @member {number} [usedHours] This is the total hours used by the instance. - * @member {string} [instanceId] This identifier is the name of the resource or - * the fully qualified Resource ID. - * @member {number} [totalReservedQuantity] This is the total count of - * instances that are reserved for the reservationid. - */ -export interface ReservationDetails extends Resource { - readonly reservationOrderId?: string; - readonly reservationId?: string; - readonly skuName?: string; - readonly reservedHours?: number; - readonly usageDate?: Date; - readonly usedHours?: number; - readonly instanceId?: string; - readonly totalReservedQuantity?: number; -} - -/** - * @class - * Initializes a new instance of the ReservationRecommendations class. - * @constructor - * Reservation recommendations resource. - * - * @member {string} [id] Resource Id. - * @member {string} [name] Resource name. - * @member {string} [type] Resource type. - * @member {object} [tags] Resource tags. - * @member {string} [location] Resource location - * @member {string} [sku] Resource sku - * @member {string} [lookBackPeriod] The number of days of usage to look back - * for recommendations. - * @member {uuid} [meterId] The meter id (GUID) - * @member {string} [term] RI recommendations in one or three year terms. - * @member {number} [costWithNoReservedInstances] The total amount of cost - * without reserved instances. - * @member {number} [recommendedQuantity] Recomended quality for reserved - * instances. - * @member {number} [totalCostWithReservedInstances] The total amount of cost - * with reserved instances. - * @member {number} [netSavings] Total estimated savings with reserved - * instances. - * @member {date} [firstUsageDate] The usage date for looking back. - * @member {string} [scope] Shared or single recommendation. - */ -export interface ReservationRecommendations { - readonly id?: string; - readonly name?: string; - readonly type?: string; - readonly tags?: { [propertyName: string]: string }; - readonly location?: string; - readonly sku?: string; - readonly lookBackPeriod?: string; - readonly meterId?: string; - readonly term?: string; - readonly costWithNoReservedInstances?: number; - readonly recommendedQuantity?: number; - readonly totalCostWithReservedInstances?: number; - readonly netSavings?: number; - readonly firstUsageDate?: Date; - readonly scope?: string; -} - -/** - * @class - * Initializes a new instance of the Tag class. - * @constructor - * The tag resource. - * - * @member {string} [key] Tag key. - */ -export interface Tag { - key?: string; -} - -/** - * @class - * Initializes a new instance of the ProxyResource class. - * @constructor - * The Resource model definition. - * - * @member {string} [id] Resource Id. - * @member {string} [name] Resource name. - * @member {string} [type] Resource type. - * @member {string} [eTag] eTag of the resource. To handle concurrent update - * scenarion, this field will be used to determine whether the user is updating - * the latest version or not. - */ -export interface ProxyResource extends BaseResource { - readonly id?: string; - readonly name?: string; - readonly type?: string; - eTag?: string; -} - -/** - * @class - * Initializes a new instance of the Tags class. - * @constructor - * A resource listing all tags. - * - * @member {array} [tags] A list of Tag. - */ -export interface Tags extends ProxyResource { - tags?: Tag[]; -} - -/** - * @class - * Initializes a new instance of the BudgetTimePeriod class. - * @constructor - * The start and end date for a budget. - * - * @member {date} startDate The start date for the budget. - * @member {date} [endDate] The end date for the budget. If not provided, we - * default this to 10 years from the start date. - */ -export interface BudgetTimePeriod { - startDate: Date; - endDate?: Date; -} - -/** - * @class - * Initializes a new instance of the Filters class. - * @constructor - * May be used to filter budgets by resource group, resource, or meter. - * - * @member {array} [resourceGroups] The list of filters on resource groups, - * allowed at subscription level only. - * @member {array} [resources] The list of filters on resources. - * @member {array} [meters] The list of filters on meters (GUID), mandatory for - * budgets of usage category. - * @member {object} [tags] The dictionary of filters on tags. - */ -export interface Filters { - resourceGroups?: string[]; - resources?: string[]; - meters?: string[]; - tags?: { [propertyName: string]: string[] }; -} - -/** - * @class - * Initializes a new instance of the CurrentSpend class. - * @constructor - * The current amount of cost which is being tracked for a budget. - * - * @member {number} [amount] The total amount of cost which is being tracked by - * the budget. - * @member {string} [unit] The unit of measure for the budget amount. - */ -export interface CurrentSpend { - readonly amount?: number; - readonly unit?: string; -} - -/** - * @class - * Initializes a new instance of the Notification class. - * @constructor - * The notification associated with a budget. - * - * @member {boolean} enabled The notification is enabled or not. - * @member {string} operator The comparison operator. Possible values include: - * 'EqualTo', 'GreaterThan', 'GreaterThanOrEqualTo' - * @member {number} threshold Threshold value associated with a notification. - * Notification is sent when the cost exceeded the threshold. It is always - * percent and has to be between 0 and 1000. - * @member {array} contactEmails Email addresses to send the budget - * notification to when the threshold is exceeded. - * @member {array} [contactRoles] Contact roles to send the budget notification - * to when the threshold is exceeded. - * @member {array} [contactGroups] Action groups to send the budget - * notification to when the threshold is exceeded. - */ -export interface Notification { - enabled: boolean; - operator: string; - threshold: number; - contactEmails: string[]; - contactRoles?: string[]; - contactGroups?: string[]; -} - -/** - * @class - * Initializes a new instance of the Budget class. - * @constructor - * A budget resource. - * - * @member {string} category The category of the budget, whether the budget - * tracks cost or usage. Possible values include: 'Cost', 'Usage' - * @member {number} amount The total amount of cost to track with the budget - * @member {string} timeGrain The time covered by a budget. Tracking of the - * amount will be reset based on the time grain. Possible values include: - * 'Monthly', 'Quarterly', 'Annually' - * @member {object} timePeriod Has start and end date of the budget. The start - * date must be first of the month and should be less than the end date. Budget - * start date must be on or after June 1, 2017. Future start date should not be - * more than three months. Past start date should be selected within the - * timegrain preiod. There are no restrictions on the end date. - * @member {date} [timePeriod.startDate] The start date for the budget. - * @member {date} [timePeriod.endDate] The end date for the budget. If not - * provided, we default this to 10 years from the start date. - * @member {object} [filters] May be used to filter budgets by resource group, - * resource, or meter. - * @member {array} [filters.resourceGroups] The list of filters on resource - * groups, allowed at subscription level only. - * @member {array} [filters.resources] The list of filters on resources. - * @member {array} [filters.meters] The list of filters on meters (GUID), - * mandatory for budgets of usage category. - * @member {object} [filters.tags] The dictionary of filters on tags. - * @member {object} [currentSpend] The current amount of cost which is being - * tracked for a budget. - * @member {number} [currentSpend.amount] The total amount of cost which is - * being tracked by the budget. - * @member {string} [currentSpend.unit] The unit of measure for the budget - * amount. - * @member {object} [notifications] Dictionary of notifications associated with - * the budget. Budget can have up to five notifications. - */ -export interface Budget extends ProxyResource { - category: string; - amount: number; - timeGrain: string; - timePeriod: BudgetTimePeriod; - filters?: Filters; - readonly currentSpend?: CurrentSpend; - notifications?: { [propertyName: string]: Notification }; -} - -/** - * @class - * Initializes a new instance of the CostTag class. - * @constructor - * The cost tag. - * - * @member {string} [key] Cost tag key. - */ -export interface CostTag { - key?: string; -} - -/** - * @class - * Initializes a new instance of the CostTags class. - * @constructor - * A cost tag resource. - * - * @member {array} [costTags] Cost tags. - */ -export interface CostTags extends ProxyResource { - costTags?: CostTag[]; -} - /** * @class * Initializes a new instance of the ErrorDetails class. @@ -597,161 +85,72 @@ export interface Operation { /** * @class - * Initializes a new instance of the ResourceAttributes class. + * Initializes a new instance of the Resource class. * @constructor * The Resource model definition. * - * @member {string} [location] Resource location - * @member {string} [sku] Resource sku - */ -export interface ResourceAttributes { - readonly location?: string; - readonly sku?: string; -} - -/** - * @class - * Initializes a new instance of the PriceSheetProperties class. - * @constructor - * The properties of the price sheet. - * - * @member {string} [billingPeriodId] The id of the billing period resource - * that the usage belongs to. - * @member {uuid} [meterId] The meter id (GUID) - * @member {object} [meterDetails] The details about the meter. By default this - * is not populated, unless it's specified in $expand. - * @member {string} [meterDetails.meterName] The name of the meter, within the - * given meter category - * @member {string} [meterDetails.meterCategory] The category of the meter, for - * example, 'Cloud services', 'Networking', etc.. - * @member {string} [meterDetails.meterSubCategory] The subcategory of the - * meter, for example, 'A6 Cloud services', 'ExpressRoute (IXP)', etc.. - * @member {string} [meterDetails.unit] The unit in which the meter consumption - * is charged, for example, 'Hours', 'GB', etc. - * @member {string} [meterDetails.meterLocation] The location in which the - * Azure service is available. - * @member {number} [meterDetails.totalIncludedQuantity] The total included - * quantity associated with the offer. - * @member {number} [meterDetails.pretaxStandardRate] The pretax listing price. - * @member {string} [unitOfMeasure] Unit of measure - * @member {number} [includedQuantity] Included quality for an offer - * @member {string} [partNumber] Part Number - * @member {number} [unitPrice] Unit Price - * @member {string} [currencyCode] Currency Code - */ -export interface PriceSheetProperties { - readonly billingPeriodId?: string; - readonly meterId?: string; - readonly meterDetails?: MeterDetails; - readonly unitOfMeasure?: string; - readonly includedQuantity?: number; - readonly partNumber?: string; - readonly unitPrice?: number; - readonly currencyCode?: string; -} - -/** - * @class - * Initializes a new instance of the PriceSheetResult class. - * @constructor - * An pricesheet resource. - * - * @member {array} [pricesheets] Price sheet - * @member {string} [nextLink] The link (url) to the next page of results. - */ -export interface PriceSheetResult extends Resource { - readonly pricesheets?: PriceSheetProperties[]; - readonly nextLink?: string; -} - -/** - * @class - * Initializes a new instance of the QueryOptions class. - * @constructor - * Additional parameters for a set of operations, such as: UsageDetails_list, - * UsageDetails_listByBillingPeriod. - * - * @member {string} [apply] OData apply expression to aggregatie usageDetails - * by tags or (tags and properties/usageStart) - */ -export interface QueryOptions { - apply?: string; -} - - -/** - * @class - * Initializes a new instance of the UsageDetailsListResult class. - * @constructor - * Result of listing usage details. It contains a list of available usage - * details in reverse chronological order by billing period. - * - * @member {string} [nextLink] The link (url) to the next page of results. - */ -export interface UsageDetailsListResult extends Array { - readonly nextLink?: string; -} - -/** - * @class - * Initializes a new instance of the MarketplacesListResult class. - * @constructor - * Result of listing marketplaces. It contains a list of available marketplaces - * in reverse chronological order by billing period. - * - * @member {string} [nextLink] The link (url) to the next page of results. + * @member {string} [id] Resource Id. + * @member {string} [name] Resource name. + * @member {string} [type] Resource type. + * @member {object} [tags] Resource tags. */ -export interface MarketplacesListResult extends Array { - readonly nextLink?: string; +export interface Resource extends BaseResource { + readonly id?: string; + readonly name?: string; + readonly type?: string; + readonly tags?: { [propertyName: string]: string }; } /** * @class - * Initializes a new instance of the ReservationSummariesListResult class. + * Initializes a new instance of the ForecastPropertiesConfidenceLevelsItem class. * @constructor - * Result of listing reservation summaries. - * - * @member {string} [nextLink] The link (url) to the next page of results. + * @member {number} [percentage] The percentage level of the confidence + * @member {string} [bound] The boundary of the percentage, values could be + * 'Upper' or 'Lower'. Possible values include: 'Upper', 'Lower' + * @member {number} [value] The amount of forecast within the percentage level */ -export interface ReservationSummariesListResult extends Array { - readonly nextLink?: string; +export interface ForecastPropertiesConfidenceLevelsItem { + readonly percentage?: number; + bound?: string; + readonly value?: number; } /** * @class - * Initializes a new instance of the ReservationDetailsListResult class. + * Initializes a new instance of the Forecast class. * @constructor - * Result of listing reservation details. + * A forecast resource. * - * @member {string} [nextLink] The link (url) to the next page of results. - */ -export interface ReservationDetailsListResult extends Array { - readonly nextLink?: string; + * @member {string} [usageDate] The usage date of the forecast. + * @member {string} [grain] The granularity of forecast. Possible values + * include: 'Daily', 'Monthly', 'Yearly' + * @member {number} [charge] The amount of charge + * @member {string} [currency] The ISO currency in which the meter is charged, + * for example, USD. + * @member {string} [chargeType] The type of the charge. Could be actual or + * forecast. Possible values include: 'Actual', 'Forecast' + * @member {array} [confidenceLevels] The details about the forecast confidence + * levels. This is populated only when chargeType is Forecast. + */ +export interface Forecast extends Resource { + readonly usageDate?: string; + grain?: string; + readonly charge?: number; + readonly currency?: string; + chargeType?: string; + readonly confidenceLevels?: ForecastPropertiesConfidenceLevelsItem[]; } -/** - * @class - * Initializes a new instance of the ReservationRecommendationsListResult class. - * @constructor - * Result of listing reservation recommendations. - * - * @member {string} [nextLink] The link (url) to the next page of results. - */ -export interface ReservationRecommendationsListResult extends Array { - readonly nextLink?: string; -} /** * @class - * Initializes a new instance of the BudgetsListResult class. + * Initializes a new instance of the ForecastsListResult class. * @constructor - * Result of listing budgets. It contains a list of available budgets in the - * scope provided. + * Result of listing forecasts. It contains a list of available forecasts. * - * @member {string} [nextLink] The link (url) to the next page of results. */ -export interface BudgetsListResult extends Array { - readonly nextLink?: string; +export interface ForecastsListResult extends Array { } /** diff --git a/lib/services/consumptionManagement/lib/models/index.js b/lib/services/consumptionManagement/lib/models/index.js index 4ec0f1ec43..5d0e4ce9fd 100644 --- a/lib/services/consumptionManagement/lib/models/index.js +++ b/lib/services/consumptionManagement/lib/models/index.js @@ -18,35 +18,12 @@ var msRestAzure = require('ms-rest-azure'); exports.BaseResource = msRestAzure.BaseResource; exports.CloudError = msRestAzure.CloudError; -exports.MeterDetails = require('./meterDetails'); -exports.Resource = require('./resource'); -exports.UsageDetail = require('./usageDetail'); -exports.Marketplace = require('./marketplace'); -exports.ReservationSummaries = require('./reservationSummaries'); -exports.ReservationDetails = require('./reservationDetails'); -exports.ReservationRecommendations = require('./reservationRecommendations'); -exports.Tag = require('./tag'); -exports.ProxyResource = require('./proxyResource'); -exports.Tags = require('./tags'); -exports.BudgetTimePeriod = require('./budgetTimePeriod'); -exports.Filters = require('./filters'); -exports.CurrentSpend = require('./currentSpend'); -exports.Notification = require('./notification'); -exports.Budget = require('./budget'); -exports.CostTag = require('./costTag'); -exports.CostTags = require('./costTags'); exports.ErrorDetails = require('./errorDetails'); exports.ErrorResponse = require('./errorResponse'); exports.OperationDisplay = require('./operationDisplay'); exports.Operation = require('./operation'); -exports.ResourceAttributes = require('./resourceAttributes'); -exports.PriceSheetProperties = require('./priceSheetProperties'); -exports.PriceSheetResult = require('./priceSheetResult'); -exports.QueryOptions = require('./queryOptions'); -exports.UsageDetailsListResult = require('./usageDetailsListResult'); -exports.MarketplacesListResult = require('./marketplacesListResult'); -exports.ReservationSummariesListResult = require('./reservationSummariesListResult'); -exports.ReservationDetailsListResult = require('./reservationDetailsListResult'); -exports.ReservationRecommendationsListResult = require('./reservationRecommendationsListResult'); -exports.BudgetsListResult = require('./budgetsListResult'); +exports.Resource = require('./resource'); +exports.ForecastPropertiesConfidenceLevelsItem = require('./forecastPropertiesConfidenceLevelsItem'); +exports.Forecast = require('./forecast'); +exports.ForecastsListResult = require('./forecastsListResult'); exports.OperationListResult = require('./operationListResult'); diff --git a/lib/services/consumptionManagement/lib/models/queryOptions.js b/lib/services/consumptionManagement/lib/models/queryOptions.js index f06ccd1be2..604f164fa1 100644 --- a/lib/services/consumptionManagement/lib/models/queryOptions.js +++ b/lib/services/consumptionManagement/lib/models/queryOptions.js @@ -11,14 +11,13 @@ 'use strict'; /** - * Additional parameters for a set of operations, such as: UsageDetails_list, - * UsageDetails_listByBillingPeriod. + * Additional parameters for a set of operations. * */ class QueryOptions { /** * Create a QueryOptions. - * @member {string} [apply] OData apply expression to aggregatie usageDetails + * @member {string} [apply] OData apply expression to aggregate usageDetails * by tags or (tags and properties/usageStart) */ constructor() { diff --git a/lib/services/consumptionManagement/lib/operations/costTagsOperations.js b/lib/services/consumptionManagement/lib/operations/costTagsOperations.js index 0f611d849a..0ecb2f63ce 100644 --- a/lib/services/consumptionManagement/lib/operations/costTagsOperations.js +++ b/lib/services/consumptionManagement/lib/operations/costTagsOperations.js @@ -17,7 +17,7 @@ const WebResource = msRest.WebResource; /** * Get cost tags for a billing account. * - * @param {string} billingAccountId Azure Billing Account ID. + * @param {string} billingAccountId BillingAccount ID * * @param {object} [options] Optional Parameters. * @@ -64,7 +64,7 @@ function _get(billingAccountId, options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.CostManagement/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/costTags'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/costTags'; requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); let queryParameters = []; queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); @@ -156,7 +156,7 @@ function _get(billingAccountId, options, callback) { * mandatorily. You may obtain the latest eTag by performing a get operation. * Create operation does not require eTag. * - * @param {string} billingAccountId Azure Billing Account ID. + * @param {string} billingAccountId BillingAccount ID * * @param {object} parameters Parameters supplied to the Create cost tags * operation. @@ -215,7 +215,7 @@ function _createOrUpdate(billingAccountId, parameters, options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.CostManagement/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/costTags'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/costTags'; requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); let queryParameters = []; queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); @@ -347,7 +347,7 @@ class CostTagsOperations { /** * Get cost tags for a billing account. * - * @param {string} billingAccountId Azure Billing Account ID. + * @param {string} billingAccountId BillingAccount ID * * @param {object} [options] Optional Parameters. * @@ -377,7 +377,7 @@ class CostTagsOperations { /** * Get cost tags for a billing account. * - * @param {string} billingAccountId Azure Billing Account ID. + * @param {string} billingAccountId BillingAccount ID * * @param {object} [options] Optional Parameters. * @@ -432,7 +432,7 @@ class CostTagsOperations { * mandatorily. You may obtain the latest eTag by performing a get operation. * Create operation does not require eTag. * - * @param {string} billingAccountId Azure Billing Account ID. + * @param {string} billingAccountId BillingAccount ID * * @param {object} parameters Parameters supplied to the Create cost tags * operation. @@ -474,7 +474,7 @@ class CostTagsOperations { * mandatorily. You may obtain the latest eTag by performing a get operation. * Create operation does not require eTag. * - * @param {string} billingAccountId Azure Billing Account ID. + * @param {string} billingAccountId BillingAccount ID * * @param {object} parameters Parameters supplied to the Create cost tags * operation. diff --git a/lib/services/consumptionManagement/lib/operations/forecasts.js b/lib/services/consumptionManagement/lib/operations/forecasts.js new file mode 100644 index 0000000000..9049ec26ba --- /dev/null +++ b/lib/services/consumptionManagement/lib/operations/forecasts.js @@ -0,0 +1,264 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists the forecast charges by subscriptionId. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter forecasts by + * properties/usageDate (Utc time), properties/chargeType or properties/grain. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ForecastsListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + // Validate + try { + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Consumption/forecasts'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ForecastsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a Forecasts. */ +class Forecasts { + /** + * Create a Forecasts. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + } + + /** + * Lists the forecast charges by subscriptionId. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter forecasts by + * properties/usageDate (Utc time), properties/chargeType or properties/grain. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the forecast charges by subscriptionId. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter forecasts by + * properties/usageDate (Utc time), properties/chargeType or properties/grain. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ForecastsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ForecastsListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(options, optionalCallback); + } + } + +} + +module.exports = Forecasts; diff --git a/lib/services/consumptionManagement/lib/operations/getBalancesByBillingAccount.js b/lib/services/consumptionManagement/lib/operations/getBalancesByBillingAccount.js new file mode 100644 index 0000000000..b98db9c568 --- /dev/null +++ b/lib/services/consumptionManagement/lib/operations/getBalancesByBillingAccount.js @@ -0,0 +1,261 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets the balances for a scope by billing period and billingAccountId. + * Balances are available via this API only for May 1, 2014 or later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Balance} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _byBillingPeriod(billingAccountId, billingPeriodName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (billingPeriodName === null || billingPeriodName === undefined || typeof billingPeriodName.valueOf() !== 'string') { + throw new Error('billingPeriodName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/balances'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{billingPeriodName}', encodeURIComponent(billingPeriodName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Balance']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a GetBalancesByBillingAccount. */ +class GetBalancesByBillingAccount { + /** + * Create a GetBalancesByBillingAccount. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._byBillingPeriod = _byBillingPeriod; + } + + /** + * Gets the balances for a scope by billing period and billingAccountId. + * Balances are available via this API only for May 1, 2014 or later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + byBillingPeriodWithHttpOperationResponse(billingAccountId, billingPeriodName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._byBillingPeriod(billingAccountId, billingPeriodName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the balances for a scope by billing period and billingAccountId. + * Balances are available via this API only for May 1, 2014 or later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Balance} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Balance} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + byBillingPeriod(billingAccountId, billingPeriodName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._byBillingPeriod(billingAccountId, billingPeriodName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._byBillingPeriod(billingAccountId, billingPeriodName, options, optionalCallback); + } + } + +} + +module.exports = GetBalancesByBillingAccount; diff --git a/lib/services/consumptionManagement/lib/operations/index.d.ts b/lib/services/consumptionManagement/lib/operations/index.d.ts index b10afb5c8f..937b2962e7 100644 --- a/lib/services/consumptionManagement/lib/operations/index.d.ts +++ b/lib/services/consumptionManagement/lib/operations/index.d.ts @@ -14,2026 +14,44 @@ import * as models from '../models'; /** * @class - * UsageDetails + * Forecasts * __NOTE__: An instance of this class is automatically created for an * instance of the ConsumptionManagementClient. */ -export interface UsageDetails { +export interface Forecasts { /** - * Lists the usage details for a scope by billing period. Usage details are - * available via this API only for May 1, 2014 or later. + * Lists the forecast charges by subscriptionId. * * @param {object} [options] Optional Parameters. * - * @param {string} [options.expand] May be used to expand the - * properties/additionalProperties or properties/meterDetails within a list of - * usage details. By default, these fields are not included when listing usage - * details. - * - * @param {string} [options.filter] May be used to filter usageDetails by - * properties/usageEnd (Utc time), properties/usageStart (Utc time), - * properties/resourceGroup, properties/instanceName, properties/instanceId or - * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does - * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair - * string where key and value is separated by a colon (:). - * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. - * - * @param {number} [options.top] May be used to limit the number of results to - * the most recent N usageDetails. - * - * @param {object} [options.queryOptions] Additional parameters for the - * operation - * - * @param {string} [options.queryOptions.apply] OData apply expression to - * aggregatie usageDetails by tags or (tags and properties/usageStart) - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - listWithHttpOperationResponse(options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Lists the usage details for a scope by billing period. Usage details are - * available via this API only for May 1, 2014 or later. - * - * @param {object} [options] Optional Parameters. - * - * @param {string} [options.expand] May be used to expand the - * properties/additionalProperties or properties/meterDetails within a list of - * usage details. By default, these fields are not included when listing usage - * details. - * - * @param {string} [options.filter] May be used to filter usageDetails by - * properties/usageEnd (Utc time), properties/usageStart (Utc time), - * properties/resourceGroup, properties/instanceName, properties/instanceId or - * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does - * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair - * string where key and value is separated by a colon (:). - * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. - * - * @param {number} [options.top] May be used to limit the number of results to - * the most recent N usageDetails. - * - * @param {object} [options.queryOptions] Additional parameters for the - * operation - * - * @param {string} [options.queryOptions.apply] OData apply expression to - * aggregatie usageDetails by tags or (tags and properties/usageStart) - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {UsageDetailsListResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. - * See {@link UsageDetailsListResult} for more - * information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - list(options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise; - list(callback: ServiceCallback): void; - list(options: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * Lists the usage details for a scope by billing period. Usage details are - * available via this API only for May 1, 2014 or later. - * - * @param {string} billingPeriodName Billing Period Name. - * - * @param {object} [options] Optional Parameters. - * - * @param {string} [options.expand] May be used to expand the - * properties/additionalProperties or properties/meterDetails within a list of - * usage details. By default, these fields are not included when listing usage - * details. - * - * @param {string} [options.filter] May be used to filter usageDetails by - * properties/usageEnd (Utc time), properties/usageStart (Utc time), - * properties/resourceGroup, properties/instanceName or properties/instanceId. - * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not - * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair - * string where key and value is separated by a colon (:). - * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. - * - * @param {number} [options.top] May be used to limit the number of results to - * the most recent N usageDetails. - * - * @param {object} [options.queryOptions] Additional parameters for the - * operation - * - * @param {string} [options.queryOptions.apply] OData apply expression to - * aggregatie usageDetails by tags or (tags and properties/usageStart) - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - listByBillingPeriodWithHttpOperationResponse(billingPeriodName: string, options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Lists the usage details for a scope by billing period. Usage details are - * available via this API only for May 1, 2014 or later. - * - * @param {string} billingPeriodName Billing Period Name. - * - * @param {object} [options] Optional Parameters. - * - * @param {string} [options.expand] May be used to expand the - * properties/additionalProperties or properties/meterDetails within a list of - * usage details. By default, these fields are not included when listing usage - * details. - * - * @param {string} [options.filter] May be used to filter usageDetails by - * properties/usageEnd (Utc time), properties/usageStart (Utc time), - * properties/resourceGroup, properties/instanceName or properties/instanceId. - * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not - * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair - * string where key and value is separated by a colon (:). - * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. - * - * @param {number} [options.top] May be used to limit the number of results to - * the most recent N usageDetails. - * - * @param {object} [options.queryOptions] Additional parameters for the - * operation - * - * @param {string} [options.queryOptions.apply] OData apply expression to - * aggregatie usageDetails by tags or (tags and properties/usageStart) - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {UsageDetailsListResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. - * See {@link UsageDetailsListResult} for more - * information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - listByBillingPeriod(billingPeriodName: string, options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise; - listByBillingPeriod(billingPeriodName: string, callback: ServiceCallback): void; - listByBillingPeriod(billingPeriodName: string, options: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * Lists the usage details for a scope by billing period. Usage details are - * available via this API only for May 1, 2014 or later. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Lists the usage details for a scope by billing period. Usage details are - * available via this API only for May 1, 2014 or later. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {UsageDetailsListResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. - * See {@link UsageDetailsListResult} for more - * information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listNext(nextPageLink: string, callback: ServiceCallback): void; - listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * Lists the usage details for a scope by billing period. Usage details are - * available via this API only for May 1, 2014 or later. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - listByBillingPeriodNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Lists the usage details for a scope by billing period. Usage details are - * available via this API only for May 1, 2014 or later. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {UsageDetailsListResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. - * See {@link UsageDetailsListResult} for more - * information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - listByBillingPeriodNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByBillingPeriodNext(nextPageLink: string, callback: ServiceCallback): void; - listByBillingPeriodNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; -} - -/** - * @class - * Marketplaces - * __NOTE__: An instance of this class is automatically created for an - * instance of the ConsumptionManagementClient. - */ -export interface Marketplaces { - - - /** - * Lists the marketplaces for a scope by subscriptionId. Marketplaces are - * available via this API only for May 1, 2014 or later. - * - * @param {object} [options] Optional Parameters. - * - * @param {string} [options.filter] May be used to filter marketplaces by - * properties/usageEnd (Utc time), properties/usageStart (Utc time), - * properties/resourceGroup, properties/instanceName or properties/instanceId. + * @param {string} [options.filter] May be used to filter forecasts by + * properties/usageDate (Utc time), properties/chargeType or properties/grain. * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not * currently support 'ne', 'or', or 'not'. * - * @param {number} [options.top] May be used to limit the number of results to - * the most recent N marketplaces. - * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. - * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listWithHttpOperationResponse(options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Lists the marketplaces for a scope by subscriptionId. Marketplaces are - * available via this API only for May 1, 2014 or later. - * - * @param {object} [options] Optional Parameters. - * - * @param {string} [options.filter] May be used to filter marketplaces by - * properties/usageEnd (Utc time), properties/usageStart (Utc time), - * properties/resourceGroup, properties/instanceName or properties/instanceId. - * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not - * currently support 'ne', 'or', or 'not'. - * - * @param {number} [options.top] May be used to limit the number of results to - * the most recent N marketplaces. - * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {MarketplacesListResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. - * See {@link MarketplacesListResult} for more - * information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - list(options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise; - list(callback: ServiceCallback): void; - list(options: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - + listWithHttpOperationResponse(options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; - /** - * Lists the marketplaces for a scope by billing period and subscripotionId. - * Marketplaces are available via this API only for May 1, 2014 or later. - * - * @param {string} billingPeriodName Billing Period Name. - * - * @param {object} [options] Optional Parameters. - * - * @param {string} [options.filter] May be used to filter marketplaces by - * properties/usageEnd (Utc time), properties/usageStart (Utc time), - * properties/resourceGroup, properties/instanceName or properties/instanceId. - * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not - * currently support 'ne', 'or', or 'not'. - * - * @param {number} [options.top] May be used to limit the number of results to - * the most recent N marketplaces. - * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - listByBillingPeriodWithHttpOperationResponse(billingPeriodName: string, options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Lists the marketplaces for a scope by billing period and subscripotionId. - * Marketplaces are available via this API only for May 1, 2014 or later. - * - * @param {string} billingPeriodName Billing Period Name. - * - * @param {object} [options] Optional Parameters. - * - * @param {string} [options.filter] May be used to filter marketplaces by - * properties/usageEnd (Utc time), properties/usageStart (Utc time), - * properties/resourceGroup, properties/instanceName or properties/instanceId. - * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not - * currently support 'ne', 'or', or 'not'. - * - * @param {number} [options.top] May be used to limit the number of results to - * the most recent N marketplaces. - * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {MarketplacesListResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. - * See {@link MarketplacesListResult} for more - * information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - listByBillingPeriod(billingPeriodName: string, options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise; - listByBillingPeriod(billingPeriodName: string, callback: ServiceCallback): void; - listByBillingPeriod(billingPeriodName: string, options: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * Lists the marketplaces for a scope by subscriptionId. Marketplaces are - * available via this API only for May 1, 2014 or later. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Lists the marketplaces for a scope by subscriptionId. Marketplaces are - * available via this API only for May 1, 2014 or later. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {MarketplacesListResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. - * See {@link MarketplacesListResult} for more - * information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listNext(nextPageLink: string, callback: ServiceCallback): void; - listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * Lists the marketplaces for a scope by billing period and subscripotionId. - * Marketplaces are available via this API only for May 1, 2014 or later. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - listByBillingPeriodNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Lists the marketplaces for a scope by billing period and subscripotionId. - * Marketplaces are available via this API only for May 1, 2014 or later. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {MarketplacesListResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. - * See {@link MarketplacesListResult} for more - * information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - listByBillingPeriodNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByBillingPeriodNext(nextPageLink: string, callback: ServiceCallback): void; - listByBillingPeriodNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; -} - -/** - * @class - * ReservationsSummaries - * __NOTE__: An instance of this class is automatically created for an - * instance of the ConsumptionManagementClient. - */ -export interface ReservationsSummaries { - - - /** - * Lists the reservations summaries for daily or monthly grain. - * - * @param {string} reservationOrderId Order Id of the reservation - * - * @param {string} grain Can be daily or monthly. Possible values include: - * 'DailyGrain', 'MonthlyGrain' - * - * @param {object} [options] Optional Parameters. - * - * @param {string} [options.filter] Required only for daily grain. The - * properties/UsageDate for start date and end date. The filter supports 'le' - * and 'ge' - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - listByReservationOrderWithHttpOperationResponse(reservationOrderId: string, grain: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Lists the reservations summaries for daily or monthly grain. - * - * @param {string} reservationOrderId Order Id of the reservation - * - * @param {string} grain Can be daily or monthly. Possible values include: - * 'DailyGrain', 'MonthlyGrain' - * - * @param {object} [options] Optional Parameters. - * - * @param {string} [options.filter] Required only for daily grain. The - * properties/UsageDate for start date and end date. The filter supports 'le' - * and 'ge' - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {ReservationSummariesListResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {ReservationSummariesListResult} [result] - The deserialized result object if an error did not occur. - * See {@link ReservationSummariesListResult} for more - * information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - listByReservationOrder(reservationOrderId: string, grain: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; - listByReservationOrder(reservationOrderId: string, grain: string, callback: ServiceCallback): void; - listByReservationOrder(reservationOrderId: string, grain: string, options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * Lists the reservations summaries for daily or monthly grain. - * - * @param {string} reservationOrderId Order Id of the reservation - * - * @param {string} reservationId Id of the reservation - * - * @param {string} grain Can be daily or monthly. Possible values include: - * 'DailyGrain', 'MonthlyGrain' - * - * @param {object} [options] Optional Parameters. - * - * @param {string} [options.filter] Required only for daily grain. The - * properties/UsageDate for start date and end date. The filter supports 'le' - * and 'ge' - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - listByReservationOrderAndReservationWithHttpOperationResponse(reservationOrderId: string, reservationId: string, grain: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Lists the reservations summaries for daily or monthly grain. - * - * @param {string} reservationOrderId Order Id of the reservation - * - * @param {string} reservationId Id of the reservation - * - * @param {string} grain Can be daily or monthly. Possible values include: - * 'DailyGrain', 'MonthlyGrain' - * - * @param {object} [options] Optional Parameters. - * - * @param {string} [options.filter] Required only for daily grain. The - * properties/UsageDate for start date and end date. The filter supports 'le' - * and 'ge' - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {ReservationSummariesListResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {ReservationSummariesListResult} [result] - The deserialized result object if an error did not occur. - * See {@link ReservationSummariesListResult} for more - * information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - listByReservationOrderAndReservation(reservationOrderId: string, reservationId: string, grain: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; - listByReservationOrderAndReservation(reservationOrderId: string, reservationId: string, grain: string, callback: ServiceCallback): void; - listByReservationOrderAndReservation(reservationOrderId: string, reservationId: string, grain: string, options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * Lists the reservations summaries for daily or monthly grain. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - listByReservationOrderNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Lists the reservations summaries for daily or monthly grain. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {ReservationSummariesListResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {ReservationSummariesListResult} [result] - The deserialized result object if an error did not occur. - * See {@link ReservationSummariesListResult} for more - * information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - listByReservationOrderNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByReservationOrderNext(nextPageLink: string, callback: ServiceCallback): void; - listByReservationOrderNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * Lists the reservations summaries for daily or monthly grain. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - listByReservationOrderAndReservationNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Lists the reservations summaries for daily or monthly grain. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {ReservationSummariesListResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {ReservationSummariesListResult} [result] - The deserialized result object if an error did not occur. - * See {@link ReservationSummariesListResult} for more - * information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - listByReservationOrderAndReservationNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByReservationOrderAndReservationNext(nextPageLink: string, callback: ServiceCallback): void; - listByReservationOrderAndReservationNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; -} - -/** - * @class - * ReservationsDetails - * __NOTE__: An instance of this class is automatically created for an - * instance of the ConsumptionManagementClient. - */ -export interface ReservationsDetails { - - - /** - * Lists the reservations details for provided date range. - * - * @param {string} reservationOrderId Order Id of the reservation - * - * @param {string} filter Filter reservation details by date range. The - * properties/UsageDate for start date and end date. The filter supports 'le' - * and 'ge' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - listByReservationOrderWithHttpOperationResponse(reservationOrderId: string, filter: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Lists the reservations details for provided date range. - * - * @param {string} reservationOrderId Order Id of the reservation - * - * @param {string} filter Filter reservation details by date range. The - * properties/UsageDate for start date and end date. The filter supports 'le' - * and 'ge' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {ReservationDetailsListResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {ReservationDetailsListResult} [result] - The deserialized result object if an error did not occur. - * See {@link ReservationDetailsListResult} for more - * information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - listByReservationOrder(reservationOrderId: string, filter: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByReservationOrder(reservationOrderId: string, filter: string, callback: ServiceCallback): void; - listByReservationOrder(reservationOrderId: string, filter: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * Lists the reservations details for provided date range. - * - * @param {string} reservationOrderId Order Id of the reservation - * - * @param {string} reservationId Id of the reservation - * - * @param {string} filter Filter reservation details by date range. The - * properties/UsageDate for start date and end date. The filter supports 'le' - * and 'ge' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - listByReservationOrderAndReservationWithHttpOperationResponse(reservationOrderId: string, reservationId: string, filter: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Lists the reservations details for provided date range. - * - * @param {string} reservationOrderId Order Id of the reservation - * - * @param {string} reservationId Id of the reservation - * - * @param {string} filter Filter reservation details by date range. The - * properties/UsageDate for start date and end date. The filter supports 'le' - * and 'ge' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {ReservationDetailsListResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {ReservationDetailsListResult} [result] - The deserialized result object if an error did not occur. - * See {@link ReservationDetailsListResult} for more - * information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - listByReservationOrderAndReservation(reservationOrderId: string, reservationId: string, filter: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByReservationOrderAndReservation(reservationOrderId: string, reservationId: string, filter: string, callback: ServiceCallback): void; - listByReservationOrderAndReservation(reservationOrderId: string, reservationId: string, filter: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * Lists the reservations details for provided date range. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - listByReservationOrderNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Lists the reservations details for provided date range. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {ReservationDetailsListResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {ReservationDetailsListResult} [result] - The deserialized result object if an error did not occur. - * See {@link ReservationDetailsListResult} for more - * information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - listByReservationOrderNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByReservationOrderNext(nextPageLink: string, callback: ServiceCallback): void; - listByReservationOrderNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * Lists the reservations details for provided date range. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - listByReservationOrderAndReservationNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Lists the reservations details for provided date range. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {ReservationDetailsListResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {ReservationDetailsListResult} [result] - The deserialized result object if an error did not occur. - * See {@link ReservationDetailsListResult} for more - * information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - listByReservationOrderAndReservationNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByReservationOrderAndReservationNext(nextPageLink: string, callback: ServiceCallback): void; - listByReservationOrderAndReservationNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; -} - -/** - * @class - * ReservationRecommendationsOperations - * __NOTE__: An instance of this class is automatically created for an - * instance of the ConsumptionManagementClient. - */ -export interface ReservationRecommendationsOperations { - - - /** - * List of recomendations for purchasing reserved instances. - * - * @param {object} [options] Optional Parameters. - * - * @param {string} [options.filter] May be used to filter - * reservationRecommendations by properties/scope and - * properties/lookBackPeriod. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - listWithHttpOperationResponse(options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * List of recomendations for purchasing reserved instances. - * - * @param {object} [options] Optional Parameters. - * - * @param {string} [options.filter] May be used to filter - * reservationRecommendations by properties/scope and - * properties/lookBackPeriod. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {ReservationRecommendationsListResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {ReservationRecommendationsListResult} [result] - The deserialized result object if an error did not occur. - * See {@link ReservationRecommendationsListResult} for - * more information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - list(options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; - list(callback: ServiceCallback): void; - list(options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * List of recomendations for purchasing reserved instances. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * List of recomendations for purchasing reserved instances. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {ReservationRecommendationsListResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {ReservationRecommendationsListResult} [result] - The deserialized result object if an error did not occur. - * See {@link ReservationRecommendationsListResult} for - * more information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listNext(nextPageLink: string, callback: ServiceCallback): void; - listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; -} - -/** - * @class - * Budgets - * __NOTE__: An instance of this class is automatically created for an - * instance of the ConsumptionManagementClient. - */ -export interface Budgets { - - - /** - * Lists all budgets for a subscription. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - listWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Lists all budgets for a subscription. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {BudgetsListResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {BudgetsListResult} [result] - The deserialized result object if an error did not occur. - * See {@link BudgetsListResult} for more information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - list(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - list(callback: ServiceCallback): void; - list(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * Lists all budgets for a resource group under a subscription. - * - * @param {string} resourceGroupName Azure Resource Group Name. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - listByResourceGroupNameWithHttpOperationResponse(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Lists all budgets for a resource group under a subscription. - * - * @param {string} resourceGroupName Azure Resource Group Name. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {BudgetsListResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {BudgetsListResult} [result] - The deserialized result object if an error did not occur. - * See {@link BudgetsListResult} for more information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - listByResourceGroupName(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByResourceGroupName(resourceGroupName: string, callback: ServiceCallback): void; - listByResourceGroupName(resourceGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * Gets the budget for a subscription by budget name. - * - * @param {string} budgetName Budget Name. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - getWithHttpOperationResponse(budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Gets the budget for a subscription by budget name. - * - * @param {string} budgetName Budget Name. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {Budget} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {Budget} [result] - The deserialized result object if an error did not occur. - * See {@link Budget} for more information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - get(budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - get(budgetName: string, callback: ServiceCallback): void; - get(budgetName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * The operation to create or update a budget. Update operation requires latest - * eTag to be set in the request mandatorily. You may obtain the latest eTag by - * performing a get operation. Create operation does not require eTag. - * - * @param {string} budgetName Budget Name. - * - * @param {object} parameters Parameters supplied to the Create Budget - * operation. - * - * @param {string} parameters.category The category of the budget, whether the - * budget tracks cost or usage. Possible values include: 'Cost', 'Usage' - * - * @param {number} parameters.amount The total amount of cost to track with the - * budget - * - * @param {string} parameters.timeGrain The time covered by a budget. Tracking - * of the amount will be reset based on the time grain. Possible values - * include: 'Monthly', 'Quarterly', 'Annually' - * - * @param {object} parameters.timePeriod Has start and end date of the budget. - * The start date must be first of the month and should be less than the end - * date. Budget start date must be on or after June 1, 2017. Future start date - * should not be more than three months. Past start date should be selected - * within the timegrain preiod. There are no restrictions on the end date. - * - * @param {date} parameters.timePeriod.startDate The start date for the budget. - * - * @param {date} [parameters.timePeriod.endDate] The end date for the budget. - * If not provided, we default this to 10 years from the start date. - * - * @param {object} [parameters.filters] May be used to filter budgets by - * resource group, resource, or meter. - * - * @param {array} [parameters.filters.resourceGroups] The list of filters on - * resource groups, allowed at subscription level only. - * - * @param {array} [parameters.filters.resources] The list of filters on - * resources. - * - * @param {array} [parameters.filters.meters] The list of filters on meters - * (GUID), mandatory for budgets of usage category. - * - * @param {object} [parameters.filters.tags] The dictionary of filters on tags. - * - * @param {object} [parameters.notifications] Dictionary of notifications - * associated with the budget. Budget can have up to five notifications. - * - * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent - * update scenarion, this field will be used to determine whether the user is - * updating the latest version or not. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - createOrUpdateWithHttpOperationResponse(budgetName: string, parameters: models.Budget, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * The operation to create or update a budget. Update operation requires latest - * eTag to be set in the request mandatorily. You may obtain the latest eTag by - * performing a get operation. Create operation does not require eTag. - * - * @param {string} budgetName Budget Name. - * - * @param {object} parameters Parameters supplied to the Create Budget - * operation. - * - * @param {string} parameters.category The category of the budget, whether the - * budget tracks cost or usage. Possible values include: 'Cost', 'Usage' - * - * @param {number} parameters.amount The total amount of cost to track with the - * budget - * - * @param {string} parameters.timeGrain The time covered by a budget. Tracking - * of the amount will be reset based on the time grain. Possible values - * include: 'Monthly', 'Quarterly', 'Annually' - * - * @param {object} parameters.timePeriod Has start and end date of the budget. - * The start date must be first of the month and should be less than the end - * date. Budget start date must be on or after June 1, 2017. Future start date - * should not be more than three months. Past start date should be selected - * within the timegrain preiod. There are no restrictions on the end date. - * - * @param {date} parameters.timePeriod.startDate The start date for the budget. - * - * @param {date} [parameters.timePeriod.endDate] The end date for the budget. - * If not provided, we default this to 10 years from the start date. - * - * @param {object} [parameters.filters] May be used to filter budgets by - * resource group, resource, or meter. - * - * @param {array} [parameters.filters.resourceGroups] The list of filters on - * resource groups, allowed at subscription level only. - * - * @param {array} [parameters.filters.resources] The list of filters on - * resources. - * - * @param {array} [parameters.filters.meters] The list of filters on meters - * (GUID), mandatory for budgets of usage category. - * - * @param {object} [parameters.filters.tags] The dictionary of filters on tags. - * - * @param {object} [parameters.notifications] Dictionary of notifications - * associated with the budget. Budget can have up to five notifications. - * - * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent - * update scenarion, this field will be used to determine whether the user is - * updating the latest version or not. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {Budget} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {Budget} [result] - The deserialized result object if an error did not occur. - * See {@link Budget} for more information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - createOrUpdate(budgetName: string, parameters: models.Budget, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - createOrUpdate(budgetName: string, parameters: models.Budget, callback: ServiceCallback): void; - createOrUpdate(budgetName: string, parameters: models.Budget, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * The operation to delete a budget. - * - * @param {string} budgetName Budget Name. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - deleteMethodWithHttpOperationResponse(budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * The operation to delete a budget. - * - * @param {string} budgetName Budget Name. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {null} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - deleteMethod(budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - deleteMethod(budgetName: string, callback: ServiceCallback): void; - deleteMethod(budgetName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * Gets the budget for a resource group under a subscription by budget name. - * - * @param {string} resourceGroupName Azure Resource Group Name. - * - * @param {string} budgetName Budget Name. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - getByResourceGroupNameWithHttpOperationResponse(resourceGroupName: string, budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Gets the budget for a resource group under a subscription by budget name. - * - * @param {string} resourceGroupName Azure Resource Group Name. - * - * @param {string} budgetName Budget Name. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {Budget} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {Budget} [result] - The deserialized result object if an error did not occur. - * See {@link Budget} for more information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - getByResourceGroupName(resourceGroupName: string, budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - getByResourceGroupName(resourceGroupName: string, budgetName: string, callback: ServiceCallback): void; - getByResourceGroupName(resourceGroupName: string, budgetName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * The operation to create or update a budget. Update operation requires latest - * eTag to be set in the request mandatorily. You may obtain the latest eTag by - * performing a get operation. Create operation does not require eTag. - * - * @param {string} resourceGroupName Azure Resource Group Name. - * - * @param {string} budgetName Budget Name. - * - * @param {object} parameters Parameters supplied to the Create Budget - * operation. - * - * @param {string} parameters.category The category of the budget, whether the - * budget tracks cost or usage. Possible values include: 'Cost', 'Usage' - * - * @param {number} parameters.amount The total amount of cost to track with the - * budget - * - * @param {string} parameters.timeGrain The time covered by a budget. Tracking - * of the amount will be reset based on the time grain. Possible values - * include: 'Monthly', 'Quarterly', 'Annually' - * - * @param {object} parameters.timePeriod Has start and end date of the budget. - * The start date must be first of the month and should be less than the end - * date. Budget start date must be on or after June 1, 2017. Future start date - * should not be more than three months. Past start date should be selected - * within the timegrain preiod. There are no restrictions on the end date. - * - * @param {date} parameters.timePeriod.startDate The start date for the budget. - * - * @param {date} [parameters.timePeriod.endDate] The end date for the budget. - * If not provided, we default this to 10 years from the start date. - * - * @param {object} [parameters.filters] May be used to filter budgets by - * resource group, resource, or meter. - * - * @param {array} [parameters.filters.resourceGroups] The list of filters on - * resource groups, allowed at subscription level only. - * - * @param {array} [parameters.filters.resources] The list of filters on - * resources. - * - * @param {array} [parameters.filters.meters] The list of filters on meters - * (GUID), mandatory for budgets of usage category. - * - * @param {object} [parameters.filters.tags] The dictionary of filters on tags. - * - * @param {object} [parameters.notifications] Dictionary of notifications - * associated with the budget. Budget can have up to five notifications. - * - * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent - * update scenarion, this field will be used to determine whether the user is - * updating the latest version or not. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - createOrUpdateByResourceGroupNameWithHttpOperationResponse(resourceGroupName: string, budgetName: string, parameters: models.Budget, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * The operation to create or update a budget. Update operation requires latest - * eTag to be set in the request mandatorily. You may obtain the latest eTag by - * performing a get operation. Create operation does not require eTag. - * - * @param {string} resourceGroupName Azure Resource Group Name. - * - * @param {string} budgetName Budget Name. - * - * @param {object} parameters Parameters supplied to the Create Budget - * operation. - * - * @param {string} parameters.category The category of the budget, whether the - * budget tracks cost or usage. Possible values include: 'Cost', 'Usage' - * - * @param {number} parameters.amount The total amount of cost to track with the - * budget - * - * @param {string} parameters.timeGrain The time covered by a budget. Tracking - * of the amount will be reset based on the time grain. Possible values - * include: 'Monthly', 'Quarterly', 'Annually' - * - * @param {object} parameters.timePeriod Has start and end date of the budget. - * The start date must be first of the month and should be less than the end - * date. Budget start date must be on or after June 1, 2017. Future start date - * should not be more than three months. Past start date should be selected - * within the timegrain preiod. There are no restrictions on the end date. - * - * @param {date} parameters.timePeriod.startDate The start date for the budget. - * - * @param {date} [parameters.timePeriod.endDate] The end date for the budget. - * If not provided, we default this to 10 years from the start date. - * - * @param {object} [parameters.filters] May be used to filter budgets by - * resource group, resource, or meter. - * - * @param {array} [parameters.filters.resourceGroups] The list of filters on - * resource groups, allowed at subscription level only. - * - * @param {array} [parameters.filters.resources] The list of filters on - * resources. - * - * @param {array} [parameters.filters.meters] The list of filters on meters - * (GUID), mandatory for budgets of usage category. - * - * @param {object} [parameters.filters.tags] The dictionary of filters on tags. - * - * @param {object} [parameters.notifications] Dictionary of notifications - * associated with the budget. Budget can have up to five notifications. - * - * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent - * update scenarion, this field will be used to determine whether the user is - * updating the latest version or not. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {Budget} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {Budget} [result] - The deserialized result object if an error did not occur. - * See {@link Budget} for more information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - createOrUpdateByResourceGroupName(resourceGroupName: string, budgetName: string, parameters: models.Budget, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - createOrUpdateByResourceGroupName(resourceGroupName: string, budgetName: string, parameters: models.Budget, callback: ServiceCallback): void; - createOrUpdateByResourceGroupName(resourceGroupName: string, budgetName: string, parameters: models.Budget, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * The operation to delete a budget. - * - * @param {string} resourceGroupName Azure Resource Group Name. - * - * @param {string} budgetName Budget Name. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - deleteByResourceGroupNameWithHttpOperationResponse(resourceGroupName: string, budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * The operation to delete a budget. - * - * @param {string} resourceGroupName Azure Resource Group Name. - * - * @param {string} budgetName Budget Name. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {null} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - deleteByResourceGroupName(resourceGroupName: string, budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - deleteByResourceGroupName(resourceGroupName: string, budgetName: string, callback: ServiceCallback): void; - deleteByResourceGroupName(resourceGroupName: string, budgetName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * Lists all budgets for a subscription. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Lists all budgets for a subscription. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {BudgetsListResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {BudgetsListResult} [result] - The deserialized result object if an error did not occur. - * See {@link BudgetsListResult} for more information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listNext(nextPageLink: string, callback: ServiceCallback): void; - listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * Lists all budgets for a resource group under a subscription. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - listByResourceGroupNameNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Lists all budgets for a resource group under a subscription. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + /** + * Lists the forecast charges by subscriptionId. * * @param {object} [options] Optional Parameters. * + * @param {string} [options.filter] May be used to filter forecasts by + * properties/usageDate (Utc time), properties/chargeType or properties/grain. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -2044,7 +62,7 @@ export interface Budgets { * * {Promise} A promise is returned. * - * @resolve {BudgetsListResult} - The deserialized result object. + * @resolve {ForecastsListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -2052,16 +70,16 @@ export interface Budgets { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {BudgetsListResult} [result] - The deserialized result object if an error did not occur. - * See {@link BudgetsListResult} for more information. + * {ForecastsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ForecastsListResult} for more information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - listByResourceGroupNameNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listByResourceGroupNameNext(nextPageLink: string, callback: ServiceCallback): void; - listByResourceGroupNameNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + list(options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } /** @@ -2180,377 +198,3 @@ export interface Operations { listNext(nextPageLink: string, callback: ServiceCallback): void; listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } - -/** - * @class - * PriceSheet - * __NOTE__: An instance of this class is automatically created for an - * instance of the ConsumptionManagementClient. - */ -export interface PriceSheet { - - - /** - * Gets the price sheet for a scope by subscriptionId. Price sheet is available - * via this API only for May 1, 2014 or later. - * - * @param {object} [options] Optional Parameters. - * - * @param {string} [options.expand] May be used to expand the - * properties/meterDetails within a price sheet. By default, these fields are - * not included when returning price sheet. - * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. - * - * @param {number} [options.top] May be used to limit the number of results to - * the top N results. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - getWithHttpOperationResponse(options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Gets the price sheet for a scope by subscriptionId. Price sheet is available - * via this API only for May 1, 2014 or later. - * - * @param {object} [options] Optional Parameters. - * - * @param {string} [options.expand] May be used to expand the - * properties/meterDetails within a price sheet. By default, these fields are - * not included when returning price sheet. - * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. - * - * @param {number} [options.top] May be used to limit the number of results to - * the top N results. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {PriceSheetResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {PriceSheetResult} [result] - The deserialized result object if an error did not occur. - * See {@link PriceSheetResult} for more information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - get(options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; - get(callback: ServiceCallback): void; - get(options: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * Get the price sheet for a scope by subscriptionId and billing period. Price - * sheet is available via this API only for May 1, 2014 or later. - * - * @param {string} billingPeriodName Billing Period Name. - * - * @param {object} [options] Optional Parameters. - * - * @param {string} [options.expand] May be used to expand the - * properties/meterDetails within a price sheet. By default, these fields are - * not included when returning price sheet. - * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. - * - * @param {number} [options.top] May be used to limit the number of results to - * the top N results. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - getByBillingPeriodWithHttpOperationResponse(billingPeriodName: string, options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Get the price sheet for a scope by subscriptionId and billing period. Price - * sheet is available via this API only for May 1, 2014 or later. - * - * @param {string} billingPeriodName Billing Period Name. - * - * @param {object} [options] Optional Parameters. - * - * @param {string} [options.expand] May be used to expand the - * properties/meterDetails within a price sheet. By default, these fields are - * not included when returning price sheet. - * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. - * - * @param {number} [options.top] May be used to limit the number of results to - * the top N results. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {PriceSheetResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {PriceSheetResult} [result] - The deserialized result object if an error did not occur. - * See {@link PriceSheetResult} for more information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - getByBillingPeriod(billingPeriodName: string, options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; - getByBillingPeriod(billingPeriodName: string, callback: ServiceCallback): void; - getByBillingPeriod(billingPeriodName: string, options: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; -} - -/** - * @class - * CostTagsOperations - * __NOTE__: An instance of this class is automatically created for an - * instance of the ConsumptionManagementClient. - */ -export interface CostTagsOperations { - - - /** - * Get cost tags for a billing account. - * - * @param {string} billingAccountId Azure Billing Account ID. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - getWithHttpOperationResponse(billingAccountId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Get cost tags for a billing account. - * - * @param {string} billingAccountId Azure Billing Account ID. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {CostTags} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {CostTags} [result] - The deserialized result object if an error did not occur. - * See {@link CostTags} for more information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - get(billingAccountId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - get(billingAccountId: string, callback: ServiceCallback): void; - get(billingAccountId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * The operation to create or update cost tags assiciated with a billing - * account. Update operation requires latest eTag to be set in the request - * mandatorily. You may obtain the latest eTag by performing a get operation. - * Create operation does not require eTag. - * - * @param {string} billingAccountId Azure Billing Account ID. - * - * @param {object} parameters Parameters supplied to the Create cost tags - * operation. - * - * @param {array} [parameters.costTags] Cost tags. - * - * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent - * update scenarion, this field will be used to determine whether the user is - * updating the latest version or not. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - createOrUpdateWithHttpOperationResponse(billingAccountId: string, parameters: models.CostTags, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * The operation to create or update cost tags assiciated with a billing - * account. Update operation requires latest eTag to be set in the request - * mandatorily. You may obtain the latest eTag by performing a get operation. - * Create operation does not require eTag. - * - * @param {string} billingAccountId Azure Billing Account ID. - * - * @param {object} parameters Parameters supplied to the Create cost tags - * operation. - * - * @param {array} [parameters.costTags] Cost tags. - * - * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent - * update scenarion, this field will be used to determine whether the user is - * updating the latest version or not. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {CostTags} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {CostTags} [result] - The deserialized result object if an error did not occur. - * See {@link CostTags} for more information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - createOrUpdate(billingAccountId: string, parameters: models.CostTags, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - createOrUpdate(billingAccountId: string, parameters: models.CostTags, callback: ServiceCallback): void; - createOrUpdate(billingAccountId: string, parameters: models.CostTags, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; -} - -/** - * @class - * TagsOperations - * __NOTE__: An instance of this class is automatically created for an - * instance of the ConsumptionManagementClient. - */ -export interface TagsOperations { - - - /** - * Get all available tag keys for a billing account. - * - * @param {string} billingAccountId Azure Billing Account ID. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - getWithHttpOperationResponse(billingAccountId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Get all available tag keys for a billing account. - * - * @param {string} billingAccountId Azure Billing Account ID. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {Tags} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {Tags} [result] - The deserialized result object if an error did not occur. - * See {@link Tags} for more information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - get(billingAccountId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - get(billingAccountId: string, callback: ServiceCallback): void; - get(billingAccountId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; -} diff --git a/lib/services/consumptionManagement/lib/operations/index.js b/lib/services/consumptionManagement/lib/operations/index.js index 02121b8f57..eb32309a35 100644 --- a/lib/services/consumptionManagement/lib/operations/index.js +++ b/lib/services/consumptionManagement/lib/operations/index.js @@ -14,13 +14,5 @@ 'use strict'; -exports.UsageDetails = require('./usageDetails'); -exports.Marketplaces = require('./marketplaces'); -exports.ReservationsSummaries = require('./reservationsSummaries'); -exports.ReservationsDetails = require('./reservationsDetails'); -exports.ReservationRecommendationsOperations = require('./reservationRecommendationsOperations'); -exports.Budgets = require('./budgets'); +exports.Forecasts = require('./forecasts'); exports.Operations = require('./operations'); -exports.PriceSheet = require('./priceSheet'); -exports.CostTagsOperations = require('./costTagsOperations'); -exports.TagsOperations = require('./tagsOperations'); diff --git a/lib/services/consumptionManagement/lib/operations/marketplaces.js b/lib/services/consumptionManagement/lib/operations/marketplaces.js index c9313c2057..f0ef834b31 100644 --- a/lib/services/consumptionManagement/lib/operations/marketplaces.js +++ b/lib/services/consumptionManagement/lib/operations/marketplaces.js @@ -15,8 +15,9 @@ const msRestAzure = require('ms-rest-azure'); const WebResource = msRest.WebResource; /** - * Lists the marketplaces for a scope by subscriptionId. Marketplaces are - * available via this API only for May 1, 2014 or later. + * Lists the marketplaces for a scope by subscriptionId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. * * @param {object} [options] Optional Parameters. * @@ -383,8 +384,9 @@ function _listByBillingPeriod(billingPeriodName, options, callback) { } /** - * Lists the marketplaces for a scope by subscriptionId. Marketplaces are - * available via this API only for May 1, 2014 or later. + * Lists the marketplaces for a scope by subscriptionId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -657,8 +659,9 @@ class Marketplaces { } /** - * Lists the marketplaces for a scope by subscriptionId. Marketplaces are - * available via this API only for May 1, 2014 or later. + * Lists the marketplaces for a scope by subscriptionId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. * * @param {object} [options] Optional Parameters. * @@ -700,8 +703,9 @@ class Marketplaces { } /** - * Lists the marketplaces for a scope by subscriptionId. Marketplaces are - * available via this API only for May 1, 2014 or later. + * Lists the marketplaces for a scope by subscriptionId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. * * @param {object} [options] Optional Parameters. * @@ -879,8 +883,9 @@ class Marketplaces { } /** - * Lists the marketplaces for a scope by subscriptionId. Marketplaces are - * available via this API only for May 1, 2014 or later. + * Lists the marketplaces for a scope by subscriptionId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -911,8 +916,9 @@ class Marketplaces { } /** - * Lists the marketplaces for a scope by subscriptionId. Marketplaces are - * available via this API only for May 1, 2014 or later. + * Lists the marketplaces for a scope by subscriptionId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. diff --git a/lib/services/consumptionManagement/lib/operations/marketplacesByBillingAccount.js b/lib/services/consumptionManagement/lib/operations/marketplacesByBillingAccount.js new file mode 100644 index 0000000000..195c9dd600 --- /dev/null +++ b/lib/services/consumptionManagement/lib/operations/marketplacesByBillingAccount.js @@ -0,0 +1,1075 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists the marketplaces for a scope by billingAccountId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(billingAccountId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + // Validate + try { + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/marketplaces'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the marketplaces for a scope by billing period and billingAccountId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByBillingPeriod(billingAccountId, billingPeriodName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + // Validate + try { + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (billingPeriodName === null || billingPeriodName === undefined || typeof billingPeriodName.valueOf() !== 'string') { + throw new Error('billingPeriodName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/marketplaces'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{billingPeriodName}', encodeURIComponent(billingPeriodName)); + let queryParameters = []; + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the marketplaces for a scope by billingAccountId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the marketplaces for a scope by billing period and billingAccountId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByBillingPeriodNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a MarketplacesByBillingAccount. */ +class MarketplacesByBillingAccount { + /** + * Create a MarketplacesByBillingAccount. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listByBillingPeriod = _listByBillingPeriod; + this._listNext = _listNext; + this._listByBillingPeriodNext = _listByBillingPeriodNext; + } + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(billingAccountId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(billingAccountId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(billingAccountId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountId, options, optionalCallback); + } + } + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByBillingPeriodWithHttpOperationResponse(billingAccountId, billingPeriodName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingPeriod(billingAccountId, billingPeriodName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriod(billingAccountId, billingPeriodName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingPeriod(billingAccountId, billingPeriodName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingPeriod(billingAccountId, billingPeriodName, options, optionalCallback); + } + } + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByBillingPeriodNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriodNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingPeriodNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = MarketplacesByBillingAccount; diff --git a/lib/services/consumptionManagement/lib/operations/marketplacesByDepartment.js b/lib/services/consumptionManagement/lib/operations/marketplacesByDepartment.js new file mode 100644 index 0000000000..b5df1ce5b8 --- /dev/null +++ b/lib/services/consumptionManagement/lib/operations/marketplacesByDepartment.js @@ -0,0 +1,1075 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists the marketplaces for a scope by departmentId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} departmentId Department ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(departmentId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + // Validate + try { + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (departmentId === null || departmentId === undefined || typeof departmentId.valueOf() !== 'string') { + throw new Error('departmentId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Consumption/marketplaces'; + requestUrl = requestUrl.replace('{departmentId}', encodeURIComponent(departmentId)); + let queryParameters = []; + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the marketplaces for a scope by billing period and departmentId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} departmentId Department ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByBillingPeriod(departmentId, billingPeriodName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + // Validate + try { + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (departmentId === null || departmentId === undefined || typeof departmentId.valueOf() !== 'string') { + throw new Error('departmentId cannot be null or undefined and it must be of type string.'); + } + if (billingPeriodName === null || billingPeriodName === undefined || typeof billingPeriodName.valueOf() !== 'string') { + throw new Error('billingPeriodName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/marketplaces'; + requestUrl = requestUrl.replace('{departmentId}', encodeURIComponent(departmentId)); + requestUrl = requestUrl.replace('{billingPeriodName}', encodeURIComponent(billingPeriodName)); + let queryParameters = []; + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the marketplaces for a scope by departmentId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the marketplaces for a scope by billing period and departmentId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByBillingPeriodNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a MarketplacesByDepartment. */ +class MarketplacesByDepartment { + /** + * Create a MarketplacesByDepartment. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listByBillingPeriod = _listByBillingPeriod; + this._listNext = _listNext; + this._listByBillingPeriodNext = _listByBillingPeriodNext; + } + + /** + * Lists the marketplaces for a scope by departmentId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} departmentId Department ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(departmentId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(departmentId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by departmentId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} departmentId Department ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(departmentId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(departmentId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(departmentId, options, optionalCallback); + } + } + + /** + * Lists the marketplaces for a scope by billing period and departmentId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} departmentId Department ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByBillingPeriodWithHttpOperationResponse(departmentId, billingPeriodName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingPeriod(departmentId, billingPeriodName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by billing period and departmentId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} departmentId Department ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriod(departmentId, billingPeriodName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingPeriod(departmentId, billingPeriodName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingPeriod(departmentId, billingPeriodName, options, optionalCallback); + } + } + + /** + * Lists the marketplaces for a scope by departmentId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by departmentId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Lists the marketplaces for a scope by billing period and departmentId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByBillingPeriodNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by billing period and departmentId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriodNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingPeriodNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = MarketplacesByDepartment; diff --git a/lib/services/consumptionManagement/lib/operations/marketplacesByEnrollmentAccounts.js b/lib/services/consumptionManagement/lib/operations/marketplacesByEnrollmentAccounts.js new file mode 100644 index 0000000000..402458890f --- /dev/null +++ b/lib/services/consumptionManagement/lib/operations/marketplacesByEnrollmentAccounts.js @@ -0,0 +1,1081 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists the marketplaces for a scope by enrollmentAccountId and current + * billing period. Marketplaces are available via this API only for May 1, 2014 + * or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(enrollmentAccountId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + // Validate + try { + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (enrollmentAccountId === null || enrollmentAccountId === undefined || typeof enrollmentAccountId.valueOf() !== 'string') { + throw new Error('enrollmentAccountId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}/providers/Microsoft.Consumption/marketplaces'; + requestUrl = requestUrl.replace('{enrollmentAccountId}', encodeURIComponent(enrollmentAccountId)); + let queryParameters = []; + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the marketplaces for a scope by billing period and + * enrollmentAccountId. Marketplaces are available via this API only for May 1, + * 2014 or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByBillingPeriod(enrollmentAccountId, billingPeriodName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + // Validate + try { + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (enrollmentAccountId === null || enrollmentAccountId === undefined || typeof enrollmentAccountId.valueOf() !== 'string') { + throw new Error('enrollmentAccountId cannot be null or undefined and it must be of type string.'); + } + if (billingPeriodName === null || billingPeriodName === undefined || typeof billingPeriodName.valueOf() !== 'string') { + throw new Error('billingPeriodName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/marketplaces'; + requestUrl = requestUrl.replace('{enrollmentAccountId}', encodeURIComponent(enrollmentAccountId)); + requestUrl = requestUrl.replace('{billingPeriodName}', encodeURIComponent(billingPeriodName)); + let queryParameters = []; + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the marketplaces for a scope by enrollmentAccountId and current + * billing period. Marketplaces are available via this API only for May 1, 2014 + * or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the marketplaces for a scope by billing period and + * enrollmentAccountId. Marketplaces are available via this API only for May 1, + * 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByBillingPeriodNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a MarketplacesByEnrollmentAccounts. */ +class MarketplacesByEnrollmentAccounts { + /** + * Create a MarketplacesByEnrollmentAccounts. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listByBillingPeriod = _listByBillingPeriod; + this._listNext = _listNext; + this._listByBillingPeriodNext = _listByBillingPeriodNext; + } + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current + * billing period. Marketplaces are available via this API only for May 1, 2014 + * or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(enrollmentAccountId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(enrollmentAccountId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current + * billing period. Marketplaces are available via this API only for May 1, 2014 + * or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(enrollmentAccountId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(enrollmentAccountId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(enrollmentAccountId, options, optionalCallback); + } + } + + /** + * Lists the marketplaces for a scope by billing period and + * enrollmentAccountId. Marketplaces are available via this API only for May 1, + * 2014 or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByBillingPeriodWithHttpOperationResponse(enrollmentAccountId, billingPeriodName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingPeriod(enrollmentAccountId, billingPeriodName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by billing period and + * enrollmentAccountId. Marketplaces are available via this API only for May 1, + * 2014 or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriod(enrollmentAccountId, billingPeriodName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingPeriod(enrollmentAccountId, billingPeriodName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingPeriod(enrollmentAccountId, billingPeriodName, options, optionalCallback); + } + } + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current + * billing period. Marketplaces are available via this API only for May 1, 2014 + * or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current + * billing period. Marketplaces are available via this API only for May 1, 2014 + * or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Lists the marketplaces for a scope by billing period and + * enrollmentAccountId. Marketplaces are available via this API only for May 1, + * 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByBillingPeriodNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by billing period and + * enrollmentAccountId. Marketplaces are available via this API only for May 1, + * 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriodNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingPeriodNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = MarketplacesByEnrollmentAccounts; diff --git a/lib/services/consumptionManagement/lib/operations/tagsOperations.js b/lib/services/consumptionManagement/lib/operations/tagsOperations.js index 5b50ec1792..4f4ebec6cf 100644 --- a/lib/services/consumptionManagement/lib/operations/tagsOperations.js +++ b/lib/services/consumptionManagement/lib/operations/tagsOperations.js @@ -17,7 +17,7 @@ const WebResource = msRest.WebResource; /** * Get all available tag keys for a billing account. * - * @param {string} billingAccountId Azure Billing Account ID. + * @param {string} billingAccountId BillingAccount ID * * @param {object} [options] Optional Parameters. * @@ -164,7 +164,7 @@ class TagsOperations { /** * Get all available tag keys for a billing account. * - * @param {string} billingAccountId Azure Billing Account ID. + * @param {string} billingAccountId BillingAccount ID * * @param {object} [options] Optional Parameters. * @@ -194,7 +194,7 @@ class TagsOperations { /** * Get all available tag keys for a billing account. * - * @param {string} billingAccountId Azure Billing Account ID. + * @param {string} billingAccountId BillingAccount ID * * @param {object} [options] Optional Parameters. * diff --git a/lib/services/consumptionManagement/lib/operations/usageDetails.js b/lib/services/consumptionManagement/lib/operations/usageDetails.js index 2dfbb6cfb5..d77448f597 100644 --- a/lib/services/consumptionManagement/lib/operations/usageDetails.js +++ b/lib/services/consumptionManagement/lib/operations/usageDetails.js @@ -15,8 +15,8 @@ const msRestAzure = require('ms-rest-azure'); const WebResource = msRest.WebResource; /** - * Lists the usage details for a scope by billing period. Usage details are - * available via this API only for May 1, 2014 or later. + * Lists the usage details for a scope by current billing period. Usage details + * are available via this API only for May 1, 2014 or later. * * @param {object} [options] Optional Parameters. * @@ -44,7 +44,7 @@ const WebResource = msRest.WebResource; * operation * * @param {string} [options.queryOptions.apply] OData apply expression to - * aggregatie usageDetails by tags or (tags and properties/usageStart) + * aggregate usageDetails by tags or (tags and properties/usageStart) * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -262,7 +262,7 @@ function _list(options, callback) { * operation * * @param {string} [options.queryOptions.apply] OData apply expression to - * aggregatie usageDetails by tags or (tags and properties/usageStart) + * aggregate usageDetails by tags or (tags and properties/usageStart) * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -453,8 +453,8 @@ function _listByBillingPeriod(billingPeriodName, options, callback) { } /** - * Lists the usage details for a scope by billing period. Usage details are - * available via this API only for May 1, 2014 or later. + * Lists the usage details for a scope by current billing period. Usage details + * are available via this API only for May 1, 2014 or later. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -727,8 +727,8 @@ class UsageDetails { } /** - * Lists the usage details for a scope by billing period. Usage details are - * available via this API only for May 1, 2014 or later. + * Lists the usage details for a scope by current billing period. Usage details + * are available via this API only for May 1, 2014 or later. * * @param {object} [options] Optional Parameters. * @@ -756,7 +756,7 @@ class UsageDetails { * operation * * @param {string} [options.queryOptions.apply] OData apply expression to - * aggregatie usageDetails by tags or (tags and properties/usageStart) + * aggregate usageDetails by tags or (tags and properties/usageStart) * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -782,8 +782,8 @@ class UsageDetails { } /** - * Lists the usage details for a scope by billing period. Usage details are - * available via this API only for May 1, 2014 or later. + * Lists the usage details for a scope by current billing period. Usage details + * are available via this API only for May 1, 2014 or later. * * @param {object} [options] Optional Parameters. * @@ -811,7 +811,7 @@ class UsageDetails { * operation * * @param {string} [options.queryOptions.apply] OData apply expression to - * aggregatie usageDetails by tags or (tags and properties/usageStart) + * aggregate usageDetails by tags or (tags and properties/usageStart) * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -891,7 +891,7 @@ class UsageDetails { * operation * * @param {string} [options.queryOptions.apply] OData apply expression to - * aggregatie usageDetails by tags or (tags and properties/usageStart) + * aggregate usageDetails by tags or (tags and properties/usageStart) * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -948,7 +948,7 @@ class UsageDetails { * operation * * @param {string} [options.queryOptions.apply] OData apply expression to - * aggregatie usageDetails by tags or (tags and properties/usageStart) + * aggregate usageDetails by tags or (tags and properties/usageStart) * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -997,8 +997,8 @@ class UsageDetails { } /** - * Lists the usage details for a scope by billing period. Usage details are - * available via this API only for May 1, 2014 or later. + * Lists the usage details for a scope by current billing period. Usage details + * are available via this API only for May 1, 2014 or later. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -1029,8 +1029,8 @@ class UsageDetails { } /** - * Lists the usage details for a scope by billing period. Usage details are - * available via this API only for May 1, 2014 or later. + * Lists the usage details for a scope by current billing period. Usage details + * are available via this API only for May 1, 2014 or later. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. diff --git a/lib/services/consumptionManagement/lib/operations/usageDetailsByBillingAccount.js b/lib/services/consumptionManagement/lib/operations/usageDetailsByBillingAccount.js new file mode 100644 index 0000000000..7c0d138633 --- /dev/null +++ b/lib/services/consumptionManagement/lib/operations/usageDetailsByBillingAccount.js @@ -0,0 +1,1199 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists the usage details by billingAccountId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(billingAccountId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let queryOptions = (options && options.queryOptions !== undefined) ? options.queryOptions : undefined; + // Validate + try { + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + let apply; + try { + if (queryOptions !== null && queryOptions !== undefined) + { + apply = queryOptions.apply; + if (apply !== null && apply !== undefined && typeof apply.valueOf() !== 'string') { + throw new Error('apply must be of type string.'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/usageDetails'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (apply !== null && apply !== undefined) { + queryParameters.push('$apply=' + encodeURIComponent(apply)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the usage details based on billingAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByBillingPeriod(billingAccountId, billingPeriodName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let queryOptions = (options && options.queryOptions !== undefined) ? options.queryOptions : undefined; + // Validate + try { + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (billingPeriodName === null || billingPeriodName === undefined || typeof billingPeriodName.valueOf() !== 'string') { + throw new Error('billingPeriodName cannot be null or undefined and it must be of type string.'); + } + if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + let apply; + try { + if (queryOptions !== null && queryOptions !== undefined) + { + apply = queryOptions.apply; + if (apply !== null && apply !== undefined && typeof apply.valueOf() !== 'string') { + throw new Error('apply must be of type string.'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/usageDetails'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{billingPeriodName}', encodeURIComponent(billingPeriodName)); + let queryParameters = []; + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (apply !== null && apply !== undefined) { + queryParameters.push('$apply=' + encodeURIComponent(apply)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the usage details by billingAccountId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the usage details based on billingAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByBillingPeriodNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a UsageDetailsByBillingAccount. */ +class UsageDetailsByBillingAccount { + /** + * Create a UsageDetailsByBillingAccount. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listByBillingPeriod = _listByBillingPeriod; + this._listNext = _listNext; + this._listByBillingPeriodNext = _listByBillingPeriodNext; + } + + /** + * Lists the usage details by billingAccountId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(billingAccountId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details by billingAccountId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(billingAccountId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(billingAccountId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountId, options, optionalCallback); + } + } + + /** + * Lists the usage details based on billingAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByBillingPeriodWithHttpOperationResponse(billingAccountId, billingPeriodName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingPeriod(billingAccountId, billingPeriodName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details based on billingAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriod(billingAccountId, billingPeriodName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingPeriod(billingAccountId, billingPeriodName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingPeriod(billingAccountId, billingPeriodName, options, optionalCallback); + } + } + + /** + * Lists the usage details by billingAccountId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details by billingAccountId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Lists the usage details based on billingAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByBillingPeriodNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details based on billingAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriodNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingPeriodNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = UsageDetailsByBillingAccount; diff --git a/lib/services/consumptionManagement/lib/operations/usageDetailsByDepartment.js b/lib/services/consumptionManagement/lib/operations/usageDetailsByDepartment.js new file mode 100644 index 0000000000..67ce79bd6d --- /dev/null +++ b/lib/services/consumptionManagement/lib/operations/usageDetailsByDepartment.js @@ -0,0 +1,1199 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists the usage details by departmentId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} departmentId Department ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(departmentId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let queryOptions = (options && options.queryOptions !== undefined) ? options.queryOptions : undefined; + // Validate + try { + if (departmentId === null || departmentId === undefined || typeof departmentId.valueOf() !== 'string') { + throw new Error('departmentId cannot be null or undefined and it must be of type string.'); + } + if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + let apply; + try { + if (queryOptions !== null && queryOptions !== undefined) + { + apply = queryOptions.apply; + if (apply !== null && apply !== undefined && typeof apply.valueOf() !== 'string') { + throw new Error('apply must be of type string.'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Consumption/usageDetails'; + requestUrl = requestUrl.replace('{departmentId}', encodeURIComponent(departmentId)); + let queryParameters = []; + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (apply !== null && apply !== undefined) { + queryParameters.push('$apply=' + encodeURIComponent(apply)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the usage details based on departmentId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} departmentId Department ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByBillingPeriod(departmentId, billingPeriodName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let queryOptions = (options && options.queryOptions !== undefined) ? options.queryOptions : undefined; + // Validate + try { + if (departmentId === null || departmentId === undefined || typeof departmentId.valueOf() !== 'string') { + throw new Error('departmentId cannot be null or undefined and it must be of type string.'); + } + if (billingPeriodName === null || billingPeriodName === undefined || typeof billingPeriodName.valueOf() !== 'string') { + throw new Error('billingPeriodName cannot be null or undefined and it must be of type string.'); + } + if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + let apply; + try { + if (queryOptions !== null && queryOptions !== undefined) + { + apply = queryOptions.apply; + if (apply !== null && apply !== undefined && typeof apply.valueOf() !== 'string') { + throw new Error('apply must be of type string.'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/usageDetails'; + requestUrl = requestUrl.replace('{departmentId}', encodeURIComponent(departmentId)); + requestUrl = requestUrl.replace('{billingPeriodName}', encodeURIComponent(billingPeriodName)); + let queryParameters = []; + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (apply !== null && apply !== undefined) { + queryParameters.push('$apply=' + encodeURIComponent(apply)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the usage details by departmentId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the usage details based on departmentId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByBillingPeriodNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a UsageDetailsByDepartment. */ +class UsageDetailsByDepartment { + /** + * Create a UsageDetailsByDepartment. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listByBillingPeriod = _listByBillingPeriod; + this._listNext = _listNext; + this._listByBillingPeriodNext = _listByBillingPeriodNext; + } + + /** + * Lists the usage details by departmentId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} departmentId Department ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(departmentId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(departmentId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details by departmentId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} departmentId Department ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(departmentId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(departmentId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(departmentId, options, optionalCallback); + } + } + + /** + * Lists the usage details based on departmentId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} departmentId Department ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByBillingPeriodWithHttpOperationResponse(departmentId, billingPeriodName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingPeriod(departmentId, billingPeriodName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details based on departmentId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} departmentId Department ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriod(departmentId, billingPeriodName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingPeriod(departmentId, billingPeriodName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingPeriod(departmentId, billingPeriodName, options, optionalCallback); + } + } + + /** + * Lists the usage details by departmentId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details by departmentId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Lists the usage details based on departmentId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByBillingPeriodNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details based on departmentId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriodNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingPeriodNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = UsageDetailsByDepartment; diff --git a/lib/services/consumptionManagement/lib/operations/usageDetailsByEnrollmentAccount.js b/lib/services/consumptionManagement/lib/operations/usageDetailsByEnrollmentAccount.js new file mode 100644 index 0000000000..a1d153ecbf --- /dev/null +++ b/lib/services/consumptionManagement/lib/operations/usageDetailsByEnrollmentAccount.js @@ -0,0 +1,1199 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists the usage details by enrollmentAccountId for a scope by current + * billing period. Usage details are available via this API only for May 1, + * 2014 or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(enrollmentAccountId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let queryOptions = (options && options.queryOptions !== undefined) ? options.queryOptions : undefined; + // Validate + try { + if (enrollmentAccountId === null || enrollmentAccountId === undefined || typeof enrollmentAccountId.valueOf() !== 'string') { + throw new Error('enrollmentAccountId cannot be null or undefined and it must be of type string.'); + } + if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + let apply; + try { + if (queryOptions !== null && queryOptions !== undefined) + { + apply = queryOptions.apply; + if (apply !== null && apply !== undefined && typeof apply.valueOf() !== 'string') { + throw new Error('apply must be of type string.'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}/providers/Microsoft.Consumption/usageDetails'; + requestUrl = requestUrl.replace('{enrollmentAccountId}', encodeURIComponent(enrollmentAccountId)); + let queryParameters = []; + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (apply !== null && apply !== undefined) { + queryParameters.push('$apply=' + encodeURIComponent(apply)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the usage details based on enrollmentAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByBillingPeriod(enrollmentAccountId, billingPeriodName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let queryOptions = (options && options.queryOptions !== undefined) ? options.queryOptions : undefined; + // Validate + try { + if (enrollmentAccountId === null || enrollmentAccountId === undefined || typeof enrollmentAccountId.valueOf() !== 'string') { + throw new Error('enrollmentAccountId cannot be null or undefined and it must be of type string.'); + } + if (billingPeriodName === null || billingPeriodName === undefined || typeof billingPeriodName.valueOf() !== 'string') { + throw new Error('billingPeriodName cannot be null or undefined and it must be of type string.'); + } + if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + let apply; + try { + if (queryOptions !== null && queryOptions !== undefined) + { + apply = queryOptions.apply; + if (apply !== null && apply !== undefined && typeof apply.valueOf() !== 'string') { + throw new Error('apply must be of type string.'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/usageDetails'; + requestUrl = requestUrl.replace('{enrollmentAccountId}', encodeURIComponent(enrollmentAccountId)); + requestUrl = requestUrl.replace('{billingPeriodName}', encodeURIComponent(billingPeriodName)); + let queryParameters = []; + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (apply !== null && apply !== undefined) { + queryParameters.push('$apply=' + encodeURIComponent(apply)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the usage details by enrollmentAccountId for a scope by current + * billing period. Usage details are available via this API only for May 1, + * 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the usage details based on enrollmentAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByBillingPeriodNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a UsageDetailsByEnrollmentAccount. */ +class UsageDetailsByEnrollmentAccount { + /** + * Create a UsageDetailsByEnrollmentAccount. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listByBillingPeriod = _listByBillingPeriod; + this._listNext = _listNext; + this._listByBillingPeriodNext = _listByBillingPeriodNext; + } + + /** + * Lists the usage details by enrollmentAccountId for a scope by current + * billing period. Usage details are available via this API only for May 1, + * 2014 or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(enrollmentAccountId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(enrollmentAccountId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details by enrollmentAccountId for a scope by current + * billing period. Usage details are available via this API only for May 1, + * 2014 or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(enrollmentAccountId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(enrollmentAccountId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(enrollmentAccountId, options, optionalCallback); + } + } + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByBillingPeriodWithHttpOperationResponse(enrollmentAccountId, billingPeriodName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingPeriod(enrollmentAccountId, billingPeriodName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriod(enrollmentAccountId, billingPeriodName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingPeriod(enrollmentAccountId, billingPeriodName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingPeriod(enrollmentAccountId, billingPeriodName, options, optionalCallback); + } + } + + /** + * Lists the usage details by enrollmentAccountId for a scope by current + * billing period. Usage details are available via this API only for May 1, + * 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details by enrollmentAccountId for a scope by current + * billing period. Usage details are available via this API only for May 1, + * 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByBillingPeriodNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriodNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingPeriodNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = UsageDetailsByEnrollmentAccount; diff --git a/lib/services/consumptionManagement/package.json b/lib/services/consumptionManagement/package.json index ec4c66f026..100f3a4216 100644 --- a/lib/services/consumptionManagement/package.json +++ b/lib/services/consumptionManagement/package.json @@ -4,10 +4,13 @@ "description": "ConsumptionManagementClient Library with typescript type definitions for node", "version": "3.1.0", "dependencies": { - "ms-rest": "^2.3.2", + "ms-rest": "^2.3.3", "ms-rest-azure": "^2.5.5" }, - "keywords": [ "node", "azure" ], + "keywords": [ + "node", + "azure" + ], "license": "MIT", "main": "./lib/consumptionManagementClient.js", "types": "./lib/consumptionManagementClient.d.ts", From 0914101c6d931fb2a5ce3946a050fce529a5df78 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Mon, 11 Jun 2018 12:02:06 -0700 Subject: [PATCH 4/5] [AutoPR consumption/resource-manager] Added new api versions for PriceSheet and UsageDetail (#2951) * Generated from 0f5512a3c534b877d238e57f41c9f0ef21a38119 Added new api versions for PriceSheet and UsageDetail * Generated from 900a52724a80781934651db97154547762681c5e consolidating the operation groups based on code review. --- lib/services/consumptionManagement/README.md | 8 +- .../lib/consumptionManagementClient.d.ts | 2 + .../lib/consumptionManagementClient.js | 2 + .../lib/models/index.d.ts | 199 + .../consumptionManagement/lib/models/index.js | 6 + .../lib/models/priceSheetProperties.js | 9 + .../lib/models/usageDetail.js | 36 + .../lib/operations/index.d.ts | 1564 +++++++ .../lib/operations/index.js | 2 + .../lib/operations/usageDetails.js | 3824 ++++++++++++++++- 10 files changed, 5489 insertions(+), 163 deletions(-) diff --git a/lib/services/consumptionManagement/README.md b/lib/services/consumptionManagement/README.md index c1457c7e45..07b41f3f8c 100644 --- a/lib/services/consumptionManagement/README.md +++ b/lib/services/consumptionManagement/README.md @@ -18,7 +18,7 @@ npm install azure-arm-consumption ## How to use -### Authentication, client creation and list forecasts as an example. +### Authentication, client creation and get priceSheet as an example. ```javascript const msRestAzure = require("ms-rest-azure"); @@ -26,8 +26,10 @@ const ConsumptionManagementClient = require("azure-arm-consumption"); msRestAzure.interactiveLogin().then((creds) => { const subscriptionId = ""; const client = new ConsumptionManagementClient(creds, subscriptionId); - const filter = "testfilter"; - return client.forecasts.list(filter).then((result) => { + const expand = "testexpand"; + const skiptoken = "testskiptoken"; + const top = 1; + return client.priceSheet.get(expand, skiptoken, top).then((result) => { console.log("The result is:"); console.log(result); }); diff --git a/lib/services/consumptionManagement/lib/consumptionManagementClient.d.ts b/lib/services/consumptionManagement/lib/consumptionManagementClient.d.ts index 41286db70f..bbbcb3e035 100644 --- a/lib/services/consumptionManagement/lib/consumptionManagementClient.d.ts +++ b/lib/services/consumptionManagement/lib/consumptionManagementClient.d.ts @@ -56,6 +56,8 @@ export default class ConsumptionManagementClient extends AzureServiceClient { generateClientRequestId: boolean; // Operation groups + priceSheet: operations.PriceSheet; + usageDetails: operations.UsageDetails; forecasts: operations.Forecasts; operations: operations.Operations; } diff --git a/lib/services/consumptionManagement/lib/consumptionManagementClient.js b/lib/services/consumptionManagement/lib/consumptionManagementClient.js index 31bb8c5667..10be56690e 100644 --- a/lib/services/consumptionManagement/lib/consumptionManagementClient.js +++ b/lib/services/consumptionManagement/lib/consumptionManagementClient.js @@ -72,6 +72,8 @@ class ConsumptionManagementClient extends ServiceClient { if(options.generateClientRequestId !== null && options.generateClientRequestId !== undefined) { this.generateClientRequestId = options.generateClientRequestId; } + this.priceSheet = new operations.PriceSheet(this); + this.usageDetails = new operations.UsageDetails(this); this.forecasts = new operations.Forecasts(this); this.operations = new operations.Operations(this); this.models = models; diff --git a/lib/services/consumptionManagement/lib/models/index.d.ts b/lib/services/consumptionManagement/lib/models/index.d.ts index ea10d9f528..4030a06ba8 100644 --- a/lib/services/consumptionManagement/lib/models/index.d.ts +++ b/lib/services/consumptionManagement/lib/models/index.d.ts @@ -101,6 +101,93 @@ export interface Resource extends BaseResource { readonly tags?: { [propertyName: string]: string }; } +/** + * @class + * Initializes a new instance of the MeterDetails class. + * @constructor + * The properties of the meter detail. + * + * @member {string} [meterName] The name of the meter, within the given meter + * category + * @member {string} [meterCategory] The category of the meter, for example, + * 'Cloud services', 'Networking', etc.. + * @member {string} [meterSubCategory] The subcategory of the meter, for + * example, 'A6 Cloud services', 'ExpressRoute (IXP)', etc.. + * @member {string} [unit] The unit in which the meter consumption is charged, + * for example, 'Hours', 'GB', etc. + * @member {string} [meterLocation] The location in which the Azure service is + * available. + * @member {number} [totalIncludedQuantity] The total included quantity + * associated with the offer. + * @member {number} [pretaxStandardRate] The pretax listing price. + */ +export interface MeterDetails { + readonly meterName?: string; + readonly meterCategory?: string; + readonly meterSubCategory?: string; + readonly unit?: string; + readonly meterLocation?: string; + readonly totalIncludedQuantity?: number; + readonly pretaxStandardRate?: number; +} + +/** + * @class + * Initializes a new instance of the PriceSheetProperties class. + * @constructor + * The properties of the price sheet. + * + * @member {string} [billingPeriodId] The id of the billing period resource + * that the usage belongs to. + * @member {uuid} [meterId] The meter id (GUID) + * @member {object} [meterDetails] The details about the meter. By default this + * is not populated, unless it's specified in $expand. + * @member {string} [meterDetails.meterName] The name of the meter, within the + * given meter category + * @member {string} [meterDetails.meterCategory] The category of the meter, for + * example, 'Cloud services', 'Networking', etc.. + * @member {string} [meterDetails.meterSubCategory] The subcategory of the + * meter, for example, 'A6 Cloud services', 'ExpressRoute (IXP)', etc.. + * @member {string} [meterDetails.unit] The unit in which the meter consumption + * is charged, for example, 'Hours', 'GB', etc. + * @member {string} [meterDetails.meterLocation] The location in which the + * Azure service is available. + * @member {number} [meterDetails.totalIncludedQuantity] The total included + * quantity associated with the offer. + * @member {number} [meterDetails.pretaxStandardRate] The pretax listing price. + * @member {string} [unitOfMeasure] Unit of measure + * @member {number} [includedQuantity] Included quality for an offer + * @member {string} [partNumber] Part Number + * @member {number} [unitPrice] Unit Price + * @member {string} [currencyCode] Currency Code + * @member {string} [offerId] Offer Id + */ +export interface PriceSheetProperties { + readonly billingPeriodId?: string; + readonly meterId?: string; + readonly meterDetails?: MeterDetails; + readonly unitOfMeasure?: string; + readonly includedQuantity?: number; + readonly partNumber?: string; + readonly unitPrice?: number; + readonly currencyCode?: string; + readonly offerId?: string; +} + +/** + * @class + * Initializes a new instance of the PriceSheetResult class. + * @constructor + * An pricesheet resource. + * + * @member {array} [pricesheets] Price sheet + * @member {string} [nextLink] The link (url) to the next page of results. + */ +export interface PriceSheetResult extends Resource { + readonly pricesheets?: PriceSheetProperties[]; + readonly nextLink?: string; +} + /** * @class * Initializes a new instance of the ForecastPropertiesConfidenceLevelsItem class. @@ -142,6 +229,118 @@ export interface Forecast extends Resource { readonly confidenceLevels?: ForecastPropertiesConfidenceLevelsItem[]; } +/** + * @class + * Initializes a new instance of the UsageDetail class. + * @constructor + * An usage detail resource. + * + * @member {string} [billingPeriodId] The id of the billing period resource + * that the usage belongs to. + * @member {string} [invoiceId] The id of the invoice resource that the usage + * belongs to. + * @member {date} [usageStart] The start of the date time range covered by the + * usage detail. + * @member {date} [usageEnd] The end of the date time range covered by the + * usage detail. + * @member {string} [instanceName] The name of the resource instance that the + * usage is about. + * @member {string} [instanceId] The uri of the resource instance that the + * usage is about. + * @member {string} [instanceLocation] The location of the resource instance + * that the usage is about. + * @member {string} [currency] The ISO currency in which the meter is charged, + * for example, USD. + * @member {number} [usageQuantity] The quantity of usage. + * @member {number} [billableQuantity] The billable usage quantity. + * @member {number} [pretaxCost] The amount of cost before tax. + * @member {boolean} [isEstimated] The estimated usage is subject to change. + * @member {uuid} [meterId] The meter id (GUID). + * @member {object} [meterDetails] The details about the meter. By default this + * is not populated, unless it's specified in $expand. + * @member {string} [meterDetails.meterName] The name of the meter, within the + * given meter category + * @member {string} [meterDetails.meterCategory] The category of the meter, for + * example, 'Cloud services', 'Networking', etc.. + * @member {string} [meterDetails.meterSubCategory] The subcategory of the + * meter, for example, 'A6 Cloud services', 'ExpressRoute (IXP)', etc.. + * @member {string} [meterDetails.unit] The unit in which the meter consumption + * is charged, for example, 'Hours', 'GB', etc. + * @member {string} [meterDetails.meterLocation] The location in which the + * Azure service is available. + * @member {number} [meterDetails.totalIncludedQuantity] The total included + * quantity associated with the offer. + * @member {number} [meterDetails.pretaxStandardRate] The pretax listing price. + * @member {uuid} [subscriptionGuid] Subscription guid. + * @member {string} [subscriptionName] Subscription name. + * @member {string} [accountName] Account name. + * @member {string} [departmentName] Department name. + * @member {string} [product] Product name. + * @member {string} [consumedService] Consumed service name. + * @member {string} [costCenter] The cost center of this department if it is a + * department and a costcenter exists + * @member {string} [partNumber] Part Number + * @member {string} [resourceGuid] Resource Guid + * @member {string} [offerId] Offer Id + * @member {boolean} [chargesBilledSeparately] Charges billed separately + * @member {string} [additionalProperties] Additional details of this usage + * item. By default this is not populated, unless it's specified in $expand. + */ +export interface UsageDetail extends Resource { + readonly billingPeriodId?: string; + readonly invoiceId?: string; + readonly usageStart?: Date; + readonly usageEnd?: Date; + readonly instanceName?: string; + readonly instanceId?: string; + readonly instanceLocation?: string; + readonly currency?: string; + readonly usageQuantity?: number; + readonly billableQuantity?: number; + readonly pretaxCost?: number; + readonly isEstimated?: boolean; + readonly meterId?: string; + readonly meterDetails?: MeterDetails; + readonly subscriptionGuid?: string; + readonly subscriptionName?: string; + readonly accountName?: string; + readonly departmentName?: string; + readonly product?: string; + readonly consumedService?: string; + readonly costCenter?: string; + readonly partNumber?: string; + readonly resourceGuid?: string; + readonly offerId?: string; + readonly chargesBilledSeparately?: boolean; + readonly additionalProperties?: string; +} + +/** + * @class + * Initializes a new instance of the QueryOptions class. + * @constructor + * Additional parameters for a set of operations. + * + * @member {string} [apply] OData apply expression to aggregate usageDetails by + * tags or (tags and properties/usageStart) + */ +export interface QueryOptions { + apply?: string; +} + + +/** + * @class + * Initializes a new instance of the UsageDetailsListResult class. + * @constructor + * Result of listing usage details. It contains a list of available usage + * details in reverse chronological order by billing period. + * + * @member {string} [nextLink] The link (url) to the next page of results. + */ +export interface UsageDetailsListResult extends Array { + readonly nextLink?: string; +} /** * @class diff --git a/lib/services/consumptionManagement/lib/models/index.js b/lib/services/consumptionManagement/lib/models/index.js index 5d0e4ce9fd..72a500dca9 100644 --- a/lib/services/consumptionManagement/lib/models/index.js +++ b/lib/services/consumptionManagement/lib/models/index.js @@ -23,7 +23,13 @@ exports.ErrorResponse = require('./errorResponse'); exports.OperationDisplay = require('./operationDisplay'); exports.Operation = require('./operation'); exports.Resource = require('./resource'); +exports.MeterDetails = require('./meterDetails'); +exports.PriceSheetProperties = require('./priceSheetProperties'); +exports.PriceSheetResult = require('./priceSheetResult'); exports.ForecastPropertiesConfidenceLevelsItem = require('./forecastPropertiesConfidenceLevelsItem'); exports.Forecast = require('./forecast'); +exports.UsageDetail = require('./usageDetail'); +exports.QueryOptions = require('./queryOptions'); +exports.UsageDetailsListResult = require('./usageDetailsListResult'); exports.ForecastsListResult = require('./forecastsListResult'); exports.OperationListResult = require('./operationListResult'); diff --git a/lib/services/consumptionManagement/lib/models/priceSheetProperties.js b/lib/services/consumptionManagement/lib/models/priceSheetProperties.js index b40d0a6a23..42cec9de79 100644 --- a/lib/services/consumptionManagement/lib/models/priceSheetProperties.js +++ b/lib/services/consumptionManagement/lib/models/priceSheetProperties.js @@ -43,6 +43,7 @@ class PriceSheetProperties { * @member {string} [partNumber] Part Number * @member {number} [unitPrice] Unit Price * @member {string} [currencyCode] Currency Code + * @member {string} [offerId] Offer Id */ constructor() { } @@ -125,6 +126,14 @@ class PriceSheetProperties { type: { name: 'String' } + }, + offerId: { + required: false, + readOnly: true, + serializedName: 'offerId', + type: { + name: 'String' + } } } } diff --git a/lib/services/consumptionManagement/lib/models/usageDetail.js b/lib/services/consumptionManagement/lib/models/usageDetail.js index 787e10d164..5fbbcdaa37 100644 --- a/lib/services/consumptionManagement/lib/models/usageDetail.js +++ b/lib/services/consumptionManagement/lib/models/usageDetail.js @@ -65,6 +65,10 @@ class UsageDetail extends models['Resource'] { * @member {string} [consumedService] Consumed service name. * @member {string} [costCenter] The cost center of this department if it is * a department and a costcenter exists + * @member {string} [partNumber] Part Number + * @member {string} [resourceGuid] Resource Guid + * @member {string} [offerId] Offer Id + * @member {boolean} [chargesBilledSeparately] Charges billed separately * @member {string} [additionalProperties] Additional details of this usage * item. By default this is not populated, unless it's specified in $expand. */ @@ -294,6 +298,38 @@ class UsageDetail extends models['Resource'] { name: 'String' } }, + partNumber: { + required: false, + readOnly: true, + serializedName: 'properties.partNumber', + type: { + name: 'String' + } + }, + resourceGuid: { + required: false, + readOnly: true, + serializedName: 'properties.resourceGuid', + type: { + name: 'String' + } + }, + offerId: { + required: false, + readOnly: true, + serializedName: 'properties.offerId', + type: { + name: 'String' + } + }, + chargesBilledSeparately: { + required: false, + readOnly: true, + serializedName: 'properties.chargesBilledSeparately', + type: { + name: 'Boolean' + } + }, additionalProperties: { required: false, readOnly: true, diff --git a/lib/services/consumptionManagement/lib/operations/index.d.ts b/lib/services/consumptionManagement/lib/operations/index.d.ts index 937b2962e7..c56b27cd21 100644 --- a/lib/services/consumptionManagement/lib/operations/index.d.ts +++ b/lib/services/consumptionManagement/lib/operations/index.d.ts @@ -12,6 +12,1570 @@ import { ServiceClientOptions, RequestOptions, ServiceCallback, HttpOperationRes import * as models from '../models'; +/** + * @class + * PriceSheet + * __NOTE__: An instance of this class is automatically created for an + * instance of the ConsumptionManagementClient. + */ +export interface PriceSheet { + + + /** + * Gets the price sheet for a scope by subscriptionId. Price sheet is available + * via this API only for May 1, 2014 or later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/meterDetails within a price sheet. By default, these fields are + * not included when returning price sheet. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the price sheet for a scope by subscriptionId. Price sheet is available + * via this API only for May 1, 2014 or later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/meterDetails within a price sheet. By default, these fields are + * not included when returning price sheet. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {PriceSheetResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {PriceSheetResult} [result] - The deserialized result object if an error did not occur. + * See {@link PriceSheetResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; + get(callback: ServiceCallback): void; + get(options: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get the price sheet for a scope by subscriptionId and billing period. Price + * sheet is available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/meterDetails within a price sheet. By default, these fields are + * not included when returning price sheet. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getByBillingPeriodWithHttpOperationResponse(billingPeriodName: string, options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the price sheet for a scope by subscriptionId and billing period. Price + * sheet is available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/meterDetails within a price sheet. By default, these fields are + * not included when returning price sheet. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {PriceSheetResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {PriceSheetResult} [result] - The deserialized result object if an error did not occur. + * See {@link PriceSheetResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + getByBillingPeriod(billingPeriodName: string, options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; + getByBillingPeriod(billingPeriodName: string, callback: ServiceCallback): void; + getByBillingPeriod(billingPeriodName: string, options: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * UsageDetails + * __NOTE__: An instance of this class is automatically created for an + * instance of the ConsumptionManagementClient. + */ +export interface UsageDetails { + + + /** + * Lists the usage details for a scope by current billing period. Usage details + * are available via this API only for May 1, 2014 or later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the usage details for a scope by current billing period. Usage details + * are available via this API only for May 1, 2014 or later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByBillingPeriodWithHttpOperationResponse(billingPeriodName: string, options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriod(billingPeriodName: string, options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise; + listByBillingPeriod(billingPeriodName: string, callback: ServiceCallback): void; + listByBillingPeriod(billingPeriodName: string, options: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the usage details by billingAccountId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByBillingAccountWithHttpOperationResponse(billingAccountId: string, options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the usage details by billingAccountId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingAccount(billingAccountId: string, options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise; + listByBillingAccount(billingAccountId: string, callback: ServiceCallback): void; + listByBillingAccount(billingAccountId: string, options: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the usage details based on billingAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listForBillingPeriodByBillingAccountWithHttpOperationResponse(billingAccountId: string, billingPeriodName: string, options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the usage details based on billingAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listForBillingPeriodByBillingAccount(billingAccountId: string, billingPeriodName: string, options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise; + listForBillingPeriodByBillingAccount(billingAccountId: string, billingPeriodName: string, callback: ServiceCallback): void; + listForBillingPeriodByBillingAccount(billingAccountId: string, billingPeriodName: string, options: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the usage details by departmentId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} departmentId Department ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByDepartmentWithHttpOperationResponse(departmentId: string, options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the usage details by departmentId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} departmentId Department ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByDepartment(departmentId: string, options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise; + listByDepartment(departmentId: string, callback: ServiceCallback): void; + listByDepartment(departmentId: string, options: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the usage details based on departmentId for a scope by billing period. + * Usage details are available via this API only for May 1, 2014 or later. + * + * @param {string} departmentId Department ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listForBillingPeriodByDepartmentWithHttpOperationResponse(departmentId: string, billingPeriodName: string, options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the usage details based on departmentId for a scope by billing period. + * Usage details are available via this API only for May 1, 2014 or later. + * + * @param {string} departmentId Department ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listForBillingPeriodByDepartment(departmentId: string, billingPeriodName: string, options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise; + listForBillingPeriodByDepartment(departmentId: string, billingPeriodName: string, callback: ServiceCallback): void; + listForBillingPeriodByDepartment(departmentId: string, billingPeriodName: string, options: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the usage details by enrollmentAccountId for a scope by current + * billing period. Usage details are available via this API only for May 1, + * 2014 or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByEnrollmentAccountWithHttpOperationResponse(enrollmentAccountId: string, options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the usage details by enrollmentAccountId for a scope by current + * billing period. Usage details are available via this API only for May 1, + * 2014 or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByEnrollmentAccount(enrollmentAccountId: string, options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise; + listByEnrollmentAccount(enrollmentAccountId: string, callback: ServiceCallback): void; + listByEnrollmentAccount(enrollmentAccountId: string, options: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listForBillingPeriodByEnrollmentAccountWithHttpOperationResponse(enrollmentAccountId: string, billingPeriodName: string, options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listForBillingPeriodByEnrollmentAccount(enrollmentAccountId: string, billingPeriodName: string, options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }): Promise; + listForBillingPeriodByEnrollmentAccount(enrollmentAccountId: string, billingPeriodName: string, callback: ServiceCallback): void; + listForBillingPeriodByEnrollmentAccount(enrollmentAccountId: string, billingPeriodName: string, options: { expand? : string, filter? : string, skiptoken? : string, top? : number, queryOptions? : models.QueryOptions, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the usage details for a scope by current billing period. Usage details + * are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the usage details for a scope by current billing period. Usage details + * are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextPageLink: string, callback: ServiceCallback): void; + listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByBillingPeriodNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriodNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByBillingPeriodNext(nextPageLink: string, callback: ServiceCallback): void; + listByBillingPeriodNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the usage details by billingAccountId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByBillingAccountNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the usage details by billingAccountId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingAccountNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByBillingAccountNext(nextPageLink: string, callback: ServiceCallback): void; + listByBillingAccountNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the usage details based on billingAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listForBillingPeriodByBillingAccountNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the usage details based on billingAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listForBillingPeriodByBillingAccountNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listForBillingPeriodByBillingAccountNext(nextPageLink: string, callback: ServiceCallback): void; + listForBillingPeriodByBillingAccountNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the usage details by departmentId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByDepartmentNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the usage details by departmentId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByDepartmentNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByDepartmentNext(nextPageLink: string, callback: ServiceCallback): void; + listByDepartmentNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the usage details based on departmentId for a scope by billing period. + * Usage details are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listForBillingPeriodByDepartmentNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the usage details based on departmentId for a scope by billing period. + * Usage details are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listForBillingPeriodByDepartmentNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listForBillingPeriodByDepartmentNext(nextPageLink: string, callback: ServiceCallback): void; + listForBillingPeriodByDepartmentNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the usage details by enrollmentAccountId for a scope by current + * billing period. Usage details are available via this API only for May 1, + * 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByEnrollmentAccountNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the usage details by enrollmentAccountId for a scope by current + * billing period. Usage details are available via this API only for May 1, + * 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByEnrollmentAccountNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByEnrollmentAccountNext(nextPageLink: string, callback: ServiceCallback): void; + listByEnrollmentAccountNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listForBillingPeriodByEnrollmentAccountNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {UsageDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listForBillingPeriodByEnrollmentAccountNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listForBillingPeriodByEnrollmentAccountNext(nextPageLink: string, callback: ServiceCallback): void; + listForBillingPeriodByEnrollmentAccountNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + /** * @class * Forecasts diff --git a/lib/services/consumptionManagement/lib/operations/index.js b/lib/services/consumptionManagement/lib/operations/index.js index eb32309a35..483623b162 100644 --- a/lib/services/consumptionManagement/lib/operations/index.js +++ b/lib/services/consumptionManagement/lib/operations/index.js @@ -14,5 +14,7 @@ 'use strict'; +exports.PriceSheet = require('./priceSheet'); +exports.UsageDetails = require('./usageDetails'); exports.Forecasts = require('./forecasts'); exports.Operations = require('./operations'); diff --git a/lib/services/consumptionManagement/lib/operations/usageDetails.js b/lib/services/consumptionManagement/lib/operations/usageDetails.js index d77448f597..ee8056bbad 100644 --- a/lib/services/consumptionManagement/lib/operations/usageDetails.js +++ b/lib/services/consumptionManagement/lib/operations/usageDetails.js @@ -453,14 +453,40 @@ function _listByBillingPeriod(billingPeriodName, options, callback) { } /** - * Lists the usage details for a scope by current billing period. Usage details - * are available via this API only for May 1, 2014 or later. + * Lists the usage details by billingAccountId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} billingAccountId BillingAccount ID * * @param {object} [options] Optional Parameters. * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -478,7 +504,7 @@ function _listByBillingPeriod(billingPeriodName, options, callback) { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _listNext(nextPageLink, options, callback) { +function _listByBillingAccount(billingAccountId, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -488,10 +514,40 @@ function _listNext(nextPageLink, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let queryOptions = (options && options.queryOptions !== undefined) ? options.queryOptions : undefined; // Validate try { - if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { - throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); @@ -499,10 +555,43 @@ function _listNext(nextPageLink, options, callback) { } catch (error) { return callback(error); } + let apply; + try { + if (queryOptions !== null && queryOptions !== undefined) + { + apply = queryOptions.apply; + if (apply !== null && apply !== undefined && typeof apply.valueOf() !== 'string') { + throw new Error('apply must be of type string.'); + } + } + } catch (error) { + return callback(error); + } // Construct URL - let requestUrl = '{nextLink}'; - requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/usageDetails'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (apply !== null && apply !== undefined) { + queryParameters.push('$apply=' + encodeURIComponent(apply)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } // Create HTTP transport objects let httpRequest = new WebResource(); @@ -583,14 +672,42 @@ function _listNext(nextPageLink, options, callback) { } /** - * Lists the usage details for a scope by billing period. Usage details are - * available via this API only for May 1, 2014 or later. + * Lists the usage details based on billingAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. * * @param {object} [options] Optional Parameters. * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -608,7 +725,7 @@ function _listNext(nextPageLink, options, callback) { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _listByBillingPeriodNext(nextPageLink, options, callback) { +function _listForBillingPeriodByBillingAccount(billingAccountId, billingPeriodName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -618,10 +735,43 @@ function _listByBillingPeriodNext(nextPageLink, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let queryOptions = (options && options.queryOptions !== undefined) ? options.queryOptions : undefined; // Validate try { - if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { - throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (billingPeriodName === null || billingPeriodName === undefined || typeof billingPeriodName.valueOf() !== 'string') { + throw new Error('billingPeriodName cannot be null or undefined and it must be of type string.'); + } + if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); @@ -629,10 +779,44 @@ function _listByBillingPeriodNext(nextPageLink, options, callback) { } catch (error) { return callback(error); } + let apply; + try { + if (queryOptions !== null && queryOptions !== undefined) + { + apply = queryOptions.apply; + if (apply !== null && apply !== undefined && typeof apply.valueOf() !== 'string') { + throw new Error('apply must be of type string.'); + } + } + } catch (error) { + return callback(error); + } // Construct URL - let requestUrl = '{nextLink}'; - requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/usageDetails'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{billingPeriodName}', encodeURIComponent(billingPeriodName)); + let queryParameters = []; + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (apply !== null && apply !== undefined) { + queryParameters.push('$apply=' + encodeURIComponent(apply)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } // Create HTTP transport objects let httpRequest = new WebResource(); @@ -712,51 +896,3350 @@ function _listByBillingPeriodNext(nextPageLink, options, callback) { }); } -/** Class representing a UsageDetails. */ -class UsageDetails { - /** - * Create a UsageDetails. - * @param {ConsumptionManagementClient} client Reference to the service client. - */ - constructor(client) { - this.client = client; - this._list = _list; - this._listByBillingPeriod = _listByBillingPeriod; - this._listNext = _listNext; - this._listByBillingPeriodNext = _listByBillingPeriodNext; +/** + * Lists the usage details by departmentId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} departmentId Department ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByDepartment(departmentId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let queryOptions = (options && options.queryOptions !== undefined) ? options.queryOptions : undefined; + // Validate + try { + if (departmentId === null || departmentId === undefined || typeof departmentId.valueOf() !== 'string') { + throw new Error('departmentId cannot be null or undefined and it must be of type string.'); + } + if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + let apply; + try { + if (queryOptions !== null && queryOptions !== undefined) + { + apply = queryOptions.apply; + if (apply !== null && apply !== undefined && typeof apply.valueOf() !== 'string') { + throw new Error('apply must be of type string.'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Consumption/usageDetails'; + requestUrl = requestUrl.replace('{departmentId}', encodeURIComponent(departmentId)); + let queryParameters = []; + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (apply !== null && apply !== undefined) { + queryParameters.push('$apply=' + encodeURIComponent(apply)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the usage details based on departmentId for a scope by billing period. + * Usage details are available via this API only for May 1, 2014 or later. + * + * @param {string} departmentId Department ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listForBillingPeriodByDepartment(departmentId, billingPeriodName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let queryOptions = (options && options.queryOptions !== undefined) ? options.queryOptions : undefined; + // Validate + try { + if (departmentId === null || departmentId === undefined || typeof departmentId.valueOf() !== 'string') { + throw new Error('departmentId cannot be null or undefined and it must be of type string.'); + } + if (billingPeriodName === null || billingPeriodName === undefined || typeof billingPeriodName.valueOf() !== 'string') { + throw new Error('billingPeriodName cannot be null or undefined and it must be of type string.'); + } + if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + let apply; + try { + if (queryOptions !== null && queryOptions !== undefined) + { + apply = queryOptions.apply; + if (apply !== null && apply !== undefined && typeof apply.valueOf() !== 'string') { + throw new Error('apply must be of type string.'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/usageDetails'; + requestUrl = requestUrl.replace('{departmentId}', encodeURIComponent(departmentId)); + requestUrl = requestUrl.replace('{billingPeriodName}', encodeURIComponent(billingPeriodName)); + let queryParameters = []; + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (apply !== null && apply !== undefined) { + queryParameters.push('$apply=' + encodeURIComponent(apply)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the usage details by enrollmentAccountId for a scope by current + * billing period. Usage details are available via this API only for May 1, + * 2014 or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByEnrollmentAccount(enrollmentAccountId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let queryOptions = (options && options.queryOptions !== undefined) ? options.queryOptions : undefined; + // Validate + try { + if (enrollmentAccountId === null || enrollmentAccountId === undefined || typeof enrollmentAccountId.valueOf() !== 'string') { + throw new Error('enrollmentAccountId cannot be null or undefined and it must be of type string.'); + } + if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + let apply; + try { + if (queryOptions !== null && queryOptions !== undefined) + { + apply = queryOptions.apply; + if (apply !== null && apply !== undefined && typeof apply.valueOf() !== 'string') { + throw new Error('apply must be of type string.'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}/providers/Microsoft.Consumption/usageDetails'; + requestUrl = requestUrl.replace('{enrollmentAccountId}', encodeURIComponent(enrollmentAccountId)); + let queryParameters = []; + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (apply !== null && apply !== undefined) { + queryParameters.push('$apply=' + encodeURIComponent(apply)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the usage details based on enrollmentAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listForBillingPeriodByEnrollmentAccount(enrollmentAccountId, billingPeriodName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let queryOptions = (options && options.queryOptions !== undefined) ? options.queryOptions : undefined; + // Validate + try { + if (enrollmentAccountId === null || enrollmentAccountId === undefined || typeof enrollmentAccountId.valueOf() !== 'string') { + throw new Error('enrollmentAccountId cannot be null or undefined and it must be of type string.'); + } + if (billingPeriodName === null || billingPeriodName === undefined || typeof billingPeriodName.valueOf() !== 'string') { + throw new Error('billingPeriodName cannot be null or undefined and it must be of type string.'); + } + if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + let apply; + try { + if (queryOptions !== null && queryOptions !== undefined) + { + apply = queryOptions.apply; + if (apply !== null && apply !== undefined && typeof apply.valueOf() !== 'string') { + throw new Error('apply must be of type string.'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/usageDetails'; + requestUrl = requestUrl.replace('{enrollmentAccountId}', encodeURIComponent(enrollmentAccountId)); + requestUrl = requestUrl.replace('{billingPeriodName}', encodeURIComponent(billingPeriodName)); + let queryParameters = []; + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (apply !== null && apply !== undefined) { + queryParameters.push('$apply=' + encodeURIComponent(apply)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the usage details for a scope by current billing period. Usage details + * are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByBillingPeriodNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the usage details by billingAccountId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByBillingAccountNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the usage details based on billingAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listForBillingPeriodByBillingAccountNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the usage details by departmentId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByDepartmentNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the usage details based on departmentId for a scope by billing period. + * Usage details are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listForBillingPeriodByDepartmentNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the usage details by enrollmentAccountId for a scope by current + * billing period. Usage details are available via this API only for May 1, + * 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByEnrollmentAccountNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the usage details based on enrollmentAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listForBillingPeriodByEnrollmentAccountNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['UsageDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a UsageDetails. */ +class UsageDetails { + /** + * Create a UsageDetails. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listByBillingPeriod = _listByBillingPeriod; + this._listByBillingAccount = _listByBillingAccount; + this._listForBillingPeriodByBillingAccount = _listForBillingPeriodByBillingAccount; + this._listByDepartment = _listByDepartment; + this._listForBillingPeriodByDepartment = _listForBillingPeriodByDepartment; + this._listByEnrollmentAccount = _listByEnrollmentAccount; + this._listForBillingPeriodByEnrollmentAccount = _listForBillingPeriodByEnrollmentAccount; + this._listNext = _listNext; + this._listByBillingPeriodNext = _listByBillingPeriodNext; + this._listByBillingAccountNext = _listByBillingAccountNext; + this._listForBillingPeriodByBillingAccountNext = _listForBillingPeriodByBillingAccountNext; + this._listByDepartmentNext = _listByDepartmentNext; + this._listForBillingPeriodByDepartmentNext = _listForBillingPeriodByDepartmentNext; + this._listByEnrollmentAccountNext = _listByEnrollmentAccountNext; + this._listForBillingPeriodByEnrollmentAccountNext = _listForBillingPeriodByEnrollmentAccountNext; + } + + /** + * Lists the usage details for a scope by current billing period. Usage details + * are available via this API only for May 1, 2014 or later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details for a scope by current billing period. Usage details + * are available via this API only for May 1, 2014 or later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(options, optionalCallback); + } + } + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByBillingPeriodWithHttpOperationResponse(billingPeriodName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingPeriod(billingPeriodName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriod(billingPeriodName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingPeriod(billingPeriodName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingPeriod(billingPeriodName, options, optionalCallback); + } + } + + /** + * Lists the usage details by billingAccountId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByBillingAccountWithHttpOperationResponse(billingAccountId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingAccount(billingAccountId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details by billingAccountId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingAccount(billingAccountId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingAccount(billingAccountId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingAccount(billingAccountId, options, optionalCallback); + } + } + + /** + * Lists the usage details based on billingAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listForBillingPeriodByBillingAccountWithHttpOperationResponse(billingAccountId, billingPeriodName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listForBillingPeriodByBillingAccount(billingAccountId, billingPeriodName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details based on billingAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listForBillingPeriodByBillingAccount(billingAccountId, billingPeriodName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listForBillingPeriodByBillingAccount(billingAccountId, billingPeriodName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listForBillingPeriodByBillingAccount(billingAccountId, billingPeriodName, options, optionalCallback); + } + } + + /** + * Lists the usage details by departmentId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} departmentId Department ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByDepartmentWithHttpOperationResponse(departmentId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByDepartment(departmentId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details by departmentId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} departmentId Department ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByDepartment(departmentId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByDepartment(departmentId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByDepartment(departmentId, options, optionalCallback); + } + } + + /** + * Lists the usage details based on departmentId for a scope by billing period. + * Usage details are available via this API only for May 1, 2014 or later. + * + * @param {string} departmentId Department ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listForBillingPeriodByDepartmentWithHttpOperationResponse(departmentId, billingPeriodName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listForBillingPeriodByDepartment(departmentId, billingPeriodName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details based on departmentId for a scope by billing period. + * Usage details are available via this API only for May 1, 2014 or later. + * + * @param {string} departmentId Department ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listForBillingPeriodByDepartment(departmentId, billingPeriodName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listForBillingPeriodByDepartment(departmentId, billingPeriodName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listForBillingPeriodByDepartment(departmentId, billingPeriodName, options, optionalCallback); + } + } + + /** + * Lists the usage details by enrollmentAccountId for a scope by current + * billing period. Usage details are available via this API only for May 1, + * 2014 or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByEnrollmentAccountWithHttpOperationResponse(enrollmentAccountId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByEnrollmentAccount(enrollmentAccountId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details by enrollmentAccountId for a scope by current + * billing period. Usage details are available via this API only for May 1, + * 2014 or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName, properties/instanceId or + * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does + * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByEnrollmentAccount(enrollmentAccountId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByEnrollmentAccount(enrollmentAccountId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByEnrollmentAccount(enrollmentAccountId, options, optionalCallback); + } + } + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listForBillingPeriodByEnrollmentAccountWithHttpOperationResponse(enrollmentAccountId, billingPeriodName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listForBillingPeriodByEnrollmentAccount(enrollmentAccountId, billingPeriodName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details based on enrollmentAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/additionalProperties or properties/meterDetails within a list of + * usage details. By default, these fields are not included when listing usage + * details. + * + * @param {string} [options.filter] May be used to filter usageDetails by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair + * string where key and value is separated by a colon (:). + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N usageDetails. + * + * @param {object} [options.queryOptions] Additional parameters for the + * operation + * + * @param {string} [options.queryOptions.apply] OData apply expression to + * aggregate usageDetails by tags or (tags and properties/usageStart) + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listForBillingPeriodByEnrollmentAccount(enrollmentAccountId, billingPeriodName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listForBillingPeriodByEnrollmentAccount(enrollmentAccountId, billingPeriodName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listForBillingPeriodByEnrollmentAccount(enrollmentAccountId, billingPeriodName, options, optionalCallback); + } + } + + /** + * Lists the usage details for a scope by current billing period. Usage details + * are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details for a scope by current billing period. Usage details + * are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByBillingPeriodNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details for a scope by billing period. Usage details are + * available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {UsageDetailsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriodNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingPeriodNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Lists the usage details by billingAccountId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByBillingAccountNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingAccountNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); } /** - * Lists the usage details for a scope by current billing period. Usage details - * are available via this API only for May 1, 2014 or later. + * Lists the usage details by billingAccountId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. * * @param {object} [options] Optional Parameters. * - * @param {string} [options.expand] May be used to expand the - * properties/additionalProperties or properties/meterDetails within a list of - * usage details. By default, these fields are not included when listing usage - * details. + * @param {object} [options.customHeaders] Headers that will be added to the + * request * - * @param {string} [options.filter] May be used to filter usageDetails by - * properties/usageEnd (Utc time), properties/usageStart (Utc time), - * properties/resourceGroup, properties/instanceName, properties/instanceId or - * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does - * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair - * string where key and value is separated by a colon (:). + * @param {function} [optionalCallback] - The optional callback. * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. * - * @param {number} [options.top] May be used to limit the number of results to - * the most recent N usageDetails. + * {Promise} A promise is returned * - * @param {object} [options.queryOptions] Additional parameters for the - * operation + * @resolve {UsageDetailsListResult} - The deserialized result object. * - * @param {string} [options.queryOptions.apply] OData apply expression to - * aggregate usageDetails by tags or (tags and properties/usageStart) + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingAccountNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingAccountNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingAccountNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Lists the usage details based on billingAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -767,11 +4250,11 @@ class UsageDetails { * * @reject {Error} - The error object. */ - listWithHttpOperationResponse(options) { + listForBillingPeriodByBillingAccountNextWithHttpOperationResponse(nextPageLink, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._list(options, (err, result, request, response) => { + self._listForBillingPeriodByBillingAccountNext(nextPageLink, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -782,36 +4265,14 @@ class UsageDetails { } /** - * Lists the usage details for a scope by current billing period. Usage details - * are available via this API only for May 1, 2014 or later. - * - * @param {object} [options] Optional Parameters. - * - * @param {string} [options.expand] May be used to expand the - * properties/additionalProperties or properties/meterDetails within a list of - * usage details. By default, these fields are not included when listing usage - * details. + * Lists the usage details based on billingAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. * - * @param {string} [options.filter] May be used to filter usageDetails by - * properties/usageEnd (Utc time), properties/usageStart (Utc time), - * properties/resourceGroup, properties/instanceName, properties/instanceId or - * tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does - * not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair - * string where key and value is separated by a colon (:). - * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. - * - * @param {number} [options.top] May be used to limit the number of results to - * the most recent N usageDetails. - * - * @param {object} [options.queryOptions] Additional parameters for the - * operation + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. * - * @param {string} [options.queryOptions.apply] OData apply expression to - * aggregate usageDetails by tags or (tags and properties/usageStart) + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -839,7 +4300,7 @@ class UsageDetails { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - list(options, optionalCallback) { + listForBillingPeriodByBillingAccountNext(nextPageLink, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -848,51 +4309,27 @@ class UsageDetails { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._list(options, (err, result, request, response) => { + self._listForBillingPeriodByBillingAccountNext(nextPageLink, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._list(options, optionalCallback); + return self._listForBillingPeriodByBillingAccountNext(nextPageLink, options, optionalCallback); } } /** - * Lists the usage details for a scope by billing period. Usage details are - * available via this API only for May 1, 2014 or later. + * Lists the usage details by departmentId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. * - * @param {string} billingPeriodName Billing Period Name. + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. * * @param {object} [options] Optional Parameters. * - * @param {string} [options.expand] May be used to expand the - * properties/additionalProperties or properties/meterDetails within a list of - * usage details. By default, these fields are not included when listing usage - * details. - * - * @param {string} [options.filter] May be used to filter usageDetails by - * properties/usageEnd (Utc time), properties/usageStart (Utc time), - * properties/resourceGroup, properties/instanceName or properties/instanceId. - * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not - * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair - * string where key and value is separated by a colon (:). - * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. - * - * @param {number} [options.top] May be used to limit the number of results to - * the most recent N usageDetails. - * - * @param {object} [options.queryOptions] Additional parameters for the - * operation - * - * @param {string} [options.queryOptions.apply] OData apply expression to - * aggregate usageDetails by tags or (tags and properties/usageStart) - * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -902,11 +4339,11 @@ class UsageDetails { * * @reject {Error} - The error object. */ - listByBillingPeriodWithHttpOperationResponse(billingPeriodName, options) { + listByDepartmentNextWithHttpOperationResponse(nextPageLink, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._listByBillingPeriod(billingPeriodName, options, (err, result, request, response) => { + self._listByDepartmentNext(nextPageLink, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -917,38 +4354,101 @@ class UsageDetails { } /** - * Lists the usage details for a scope by billing period. Usage details are - * available via this API only for May 1, 2014 or later. + * Lists the usage details by departmentId for a scope by current billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. * - * @param {string} billingPeriodName Billing Period Name. + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. * * @param {object} [options] Optional Parameters. * - * @param {string} [options.expand] May be used to expand the - * properties/additionalProperties or properties/meterDetails within a list of - * usage details. By default, these fields are not included when listing usage - * details. + * @param {object} [options.customHeaders] Headers that will be added to the + * request * - * @param {string} [options.filter] May be used to filter usageDetails by - * properties/usageEnd (Utc time), properties/usageStart (Utc time), - * properties/resourceGroup, properties/instanceName or properties/instanceId. - * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not - * currently support 'ne', 'or', or 'not'. Tag filter is a key value pair - * string where key and value is separated by a colon (:). + * @param {function} [optionalCallback] - The optional callback. * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. * - * @param {number} [options.top] May be used to limit the number of results to - * the most recent N usageDetails. + * {Promise} A promise is returned * - * @param {object} [options.queryOptions] Additional parameters for the - * operation + * @resolve {UsageDetailsListResult} - The deserialized result object. * - * @param {string} [options.queryOptions.apply] OData apply expression to - * aggregate usageDetails by tags or (tags and properties/usageStart) + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link UsageDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByDepartmentNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByDepartmentNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByDepartmentNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Lists the usage details based on departmentId for a scope by billing period. + * Usage details are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listForBillingPeriodByDepartmentNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listForBillingPeriodByDepartmentNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the usage details based on departmentId for a scope by billing period. + * Usage details are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -976,7 +4476,7 @@ class UsageDetails { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - listByBillingPeriod(billingPeriodName, options, optionalCallback) { + listForBillingPeriodByDepartmentNext(nextPageLink, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -985,20 +4485,21 @@ class UsageDetails { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._listByBillingPeriod(billingPeriodName, options, (err, result, request, response) => { + self._listForBillingPeriodByDepartmentNext(nextPageLink, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._listByBillingPeriod(billingPeriodName, options, optionalCallback); + return self._listForBillingPeriodByDepartmentNext(nextPageLink, options, optionalCallback); } } /** - * Lists the usage details for a scope by current billing period. Usage details - * are available via this API only for May 1, 2014 or later. + * Lists the usage details by enrollmentAccountId for a scope by current + * billing period. Usage details are available via this API only for May 1, + * 2014 or later. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -1014,11 +4515,11 @@ class UsageDetails { * * @reject {Error} - The error object. */ - listNextWithHttpOperationResponse(nextPageLink, options) { + listByEnrollmentAccountNextWithHttpOperationResponse(nextPageLink, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._listNext(nextPageLink, options, (err, result, request, response) => { + self._listByEnrollmentAccountNext(nextPageLink, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -1029,8 +4530,9 @@ class UsageDetails { } /** - * Lists the usage details for a scope by current billing period. Usage details - * are available via this API only for May 1, 2014 or later. + * Lists the usage details by enrollmentAccountId for a scope by current + * billing period. Usage details are available via this API only for May 1, + * 2014 or later. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -1063,7 +4565,7 @@ class UsageDetails { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - listNext(nextPageLink, options, optionalCallback) { + listByEnrollmentAccountNext(nextPageLink, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -1072,20 +4574,21 @@ class UsageDetails { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._listNext(nextPageLink, options, (err, result, request, response) => { + self._listByEnrollmentAccountNext(nextPageLink, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._listNext(nextPageLink, options, optionalCallback); + return self._listByEnrollmentAccountNext(nextPageLink, options, optionalCallback); } } /** - * Lists the usage details for a scope by billing period. Usage details are - * available via this API only for May 1, 2014 or later. + * Lists the usage details based on enrollmentAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -1101,11 +4604,11 @@ class UsageDetails { * * @reject {Error} - The error object. */ - listByBillingPeriodNextWithHttpOperationResponse(nextPageLink, options) { + listForBillingPeriodByEnrollmentAccountNextWithHttpOperationResponse(nextPageLink, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + self._listForBillingPeriodByEnrollmentAccountNext(nextPageLink, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -1116,8 +4619,9 @@ class UsageDetails { } /** - * Lists the usage details for a scope by billing period. Usage details are - * available via this API only for May 1, 2014 or later. + * Lists the usage details based on enrollmentAccountId for a scope by billing + * period. Usage details are available via this API only for May 1, 2014 or + * later. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -1150,7 +4654,7 @@ class UsageDetails { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - listByBillingPeriodNext(nextPageLink, options, optionalCallback) { + listForBillingPeriodByEnrollmentAccountNext(nextPageLink, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -1159,14 +4663,14 @@ class UsageDetails { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + self._listForBillingPeriodByEnrollmentAccountNext(nextPageLink, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._listByBillingPeriodNext(nextPageLink, options, optionalCallback); + return self._listForBillingPeriodByEnrollmentAccountNext(nextPageLink, options, optionalCallback); } } From 62f11c4dd1f44f724261d7b13c75740d8076c312 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Thu, 12 Jul 2018 14:00:20 -0700 Subject: [PATCH 5/5] [AutoPR consumption/resource-manager] Adding new properties to Consumption Usage Details (#3120) * Generated from 4394e3bd84d0e9012dd1acac36ce2a82fd02edd6 Merge branch 'master' of https://github.com/Azure/azure-rest-api-specs * Generated from 8d551a2fd9eb30b4c6b9f38b30924f06fed0b02c Merge branch 'master' of https://github.com/Azure/azure-rest-api-specs * Generated from bac7ebe031f40801bd2aca9a368dd9eeaeaa7509 Merge branch 'master' of https://github.com/Azure/azure-rest-api-specs * Generated from 891beecde5b53a8b2fc5a700670df861cc80b1f0 Modified the Operation Id to follow the best practices. * Generated from b9b62fdf3ee427a1f2c1b71293cc422eedbdbd63 Fixed model namings for - ReservationSummaries (now: ReservationSummary), ReservationDetails (now: ReservationDetail) and ReservationRecommendations (now: ReservationRecommendation) * Generated from 5d36df6e4f6b3ddde06f975bfa42fa095a5ad29e Fixed the naming for model CostTags. * Generated from c5a8c67ddd9601adc30c1a968a85629fbe79ccdf Fixing the SDKViolation error on - model Tags. * Generated from b28e418996a4b847984d198b4c0ccbd003466d0a Changed the CostTagResult to CostTag as per review comments. Also changed operations - Marketplaces_ListByEnrollmentAccount and Marketplaces_ListForBillingPeriodByEnrollmentAccount. --- lib/services/consumptionManagement/README.md | 6 +- .../lib/consumptionManagementClient.d.ts | 10 +- .../lib/consumptionManagementClient.js | 12 +- .../lib/models/costTag.js | 53 +- .../lib/models/costTagProperties.js | 52 + .../lib/models/costTagsResult.js | 95 + .../lib/models/index.d.ts | 846 ++++- .../consumptionManagement/lib/models/index.js | 35 +- .../lib/models/meterDetails.js | 18 + .../lib/models/priceSheetProperties.js | 2 + .../lib/models/reservationDetail.js | 171 + .../models/reservationDetailsListResult.js | 4 +- .../lib/models/reservationRecommendation.js | 191 + .../reservationRecommendationsListResult.js | 4 +- .../models/reservationSummariesListResult.js | 4 +- .../lib/models/reservationSummary.js | 186 + .../lib/models/tagsResult.js | 95 + .../lib/models/usageDetail.js | 11 + .../lib/operations/balances.js | 483 +++ .../lib/operations/costTags.js | 537 +++ .../lib/operations/index.d.ts | 3283 +++++++++++++++- .../lib/operations/index.js | 10 +- .../lib/operations/marketplaces.js | 3368 ++++++++++++++++- .../operations/reservationRecommendations.js | 478 +++ .../lib/operations/tags.js | 248 ++ 25 files changed, 9748 insertions(+), 454 deletions(-) create mode 100644 lib/services/consumptionManagement/lib/models/costTagProperties.js create mode 100644 lib/services/consumptionManagement/lib/models/costTagsResult.js create mode 100644 lib/services/consumptionManagement/lib/models/reservationDetail.js create mode 100644 lib/services/consumptionManagement/lib/models/reservationRecommendation.js create mode 100644 lib/services/consumptionManagement/lib/models/reservationSummary.js create mode 100644 lib/services/consumptionManagement/lib/models/tagsResult.js create mode 100644 lib/services/consumptionManagement/lib/operations/balances.js create mode 100644 lib/services/consumptionManagement/lib/operations/costTags.js create mode 100644 lib/services/consumptionManagement/lib/operations/reservationRecommendations.js create mode 100644 lib/services/consumptionManagement/lib/operations/tags.js diff --git a/lib/services/consumptionManagement/README.md b/lib/services/consumptionManagement/README.md index 07b41f3f8c..fa6d0fd678 100644 --- a/lib/services/consumptionManagement/README.md +++ b/lib/services/consumptionManagement/README.md @@ -18,7 +18,7 @@ npm install azure-arm-consumption ## How to use -### Authentication, client creation and get priceSheet as an example. +### Authentication, client creation and list usageDetails as an example. ```javascript const msRestAzure = require("ms-rest-azure"); @@ -27,9 +27,11 @@ msRestAzure.interactiveLogin().then((creds) => { const subscriptionId = ""; const client = new ConsumptionManagementClient(creds, subscriptionId); const expand = "testexpand"; + const filter = "testfilter"; const skiptoken = "testskiptoken"; const top = 1; - return client.priceSheet.get(expand, skiptoken, top).then((result) => { + const apply = "testapply"; + return client.usageDetails.list(expand, filter, skiptoken, top, apply).then((result) => { console.log("The result is:"); console.log(result); }); diff --git a/lib/services/consumptionManagement/lib/consumptionManagementClient.d.ts b/lib/services/consumptionManagement/lib/consumptionManagementClient.d.ts index bbbcb3e035..8642178873 100644 --- a/lib/services/consumptionManagement/lib/consumptionManagementClient.d.ts +++ b/lib/services/consumptionManagement/lib/consumptionManagementClient.d.ts @@ -56,8 +56,16 @@ export default class ConsumptionManagementClient extends AzureServiceClient { generateClientRequestId: boolean; // Operation groups - priceSheet: operations.PriceSheet; usageDetails: operations.UsageDetails; + marketplaces: operations.Marketplaces; + balances: operations.Balances; + reservationsSummaries: operations.ReservationsSummaries; + reservationsDetails: operations.ReservationsDetails; + reservationRecommendations: operations.ReservationRecommendations; + budgets: operations.Budgets; + priceSheet: operations.PriceSheet; + costTags: operations.CostTags; + tags: operations.Tags; forecasts: operations.Forecasts; operations: operations.Operations; } diff --git a/lib/services/consumptionManagement/lib/consumptionManagementClient.js b/lib/services/consumptionManagement/lib/consumptionManagementClient.js index 10be56690e..43f58b515b 100644 --- a/lib/services/consumptionManagement/lib/consumptionManagementClient.js +++ b/lib/services/consumptionManagement/lib/consumptionManagementClient.js @@ -50,7 +50,7 @@ class ConsumptionManagementClient extends ServiceClient { super(credentials, options); - this.apiVersion = '2018-05-31'; + this.apiVersion = '2018-06-30'; this.acceptLanguage = 'en-US'; this.longRunningOperationRetryTimeout = 30; this.generateClientRequestId = true; @@ -72,8 +72,16 @@ class ConsumptionManagementClient extends ServiceClient { if(options.generateClientRequestId !== null && options.generateClientRequestId !== undefined) { this.generateClientRequestId = options.generateClientRequestId; } - this.priceSheet = new operations.PriceSheet(this); this.usageDetails = new operations.UsageDetails(this); + this.marketplaces = new operations.Marketplaces(this); + this.balances = new operations.Balances(this); + this.reservationsSummaries = new operations.ReservationsSummaries(this); + this.reservationsDetails = new operations.ReservationsDetails(this); + this.reservationRecommendations = new operations.ReservationRecommendations(this); + this.budgets = new operations.Budgets(this); + this.priceSheet = new operations.PriceSheet(this); + this.costTags = new operations.CostTags(this); + this.tags = new operations.Tags(this); this.forecasts = new operations.Forecasts(this); this.operations = new operations.Operations(this); this.models = models; diff --git a/lib/services/consumptionManagement/lib/models/costTag.js b/lib/services/consumptionManagement/lib/models/costTag.js index 29a8e275c7..f2b59005de 100644 --- a/lib/services/consumptionManagement/lib/models/costTag.js +++ b/lib/services/consumptionManagement/lib/models/costTag.js @@ -10,16 +10,20 @@ 'use strict'; +const models = require('./index'); + /** - * The cost tag. + * A cost tag resource. * + * @extends models['ProxyResource'] */ -class CostTag { +class CostTag extends models['ProxyResource'] { /** * Create a CostTag. - * @member {string} [key] Cost tag key. + * @member {array} [costTags] Cost tags. */ constructor() { + super(); } /** @@ -36,12 +40,51 @@ class CostTag { name: 'Composite', className: 'CostTag', modelProperties: { - key: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + eTag: { required: false, - serializedName: 'key', + serializedName: 'eTag', type: { name: 'String' } + }, + costTags: { + required: false, + serializedName: 'properties.costTags', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'CostTagPropertiesElementType', + type: { + name: 'Composite', + className: 'CostTagProperties' + } + } + } } } } diff --git a/lib/services/consumptionManagement/lib/models/costTagProperties.js b/lib/services/consumptionManagement/lib/models/costTagProperties.js new file mode 100644 index 0000000000..62b16f4d3b --- /dev/null +++ b/lib/services/consumptionManagement/lib/models/costTagProperties.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The properties of the cost tag. + * + */ +class CostTagProperties { + /** + * Create a CostTagProperties. + * @member {string} [key] Cost tag key. + */ + constructor() { + } + + /** + * Defines the metadata of CostTagProperties + * + * @returns {object} metadata of CostTagProperties + * + */ + mapper() { + return { + required: false, + serializedName: 'CostTagProperties', + type: { + name: 'Composite', + className: 'CostTagProperties', + modelProperties: { + key: { + required: false, + serializedName: 'key', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = CostTagProperties; diff --git a/lib/services/consumptionManagement/lib/models/costTagsResult.js b/lib/services/consumptionManagement/lib/models/costTagsResult.js new file mode 100644 index 0000000000..ca2cdf5a46 --- /dev/null +++ b/lib/services/consumptionManagement/lib/models/costTagsResult.js @@ -0,0 +1,95 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * A cost tag resource. + * + * @extends models['ProxyResource'] + */ +class CostTagsResult extends models['ProxyResource'] { + /** + * Create a CostTagsResult. + * @member {array} [costTags] Cost tags. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of CostTagsResult + * + * @returns {object} metadata of CostTagsResult + * + */ + mapper() { + return { + required: false, + serializedName: 'CostTagsResult', + type: { + name: 'Composite', + className: 'CostTagsResult', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + eTag: { + required: false, + serializedName: 'eTag', + type: { + name: 'String' + } + }, + costTags: { + required: false, + serializedName: 'properties.costTags', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'CostTagPropertiesElementType', + type: { + name: 'Composite', + className: 'CostTagProperties' + } + } + } + } + } + } + }; + } +} + +module.exports = CostTagsResult; diff --git a/lib/services/consumptionManagement/lib/models/index.d.ts b/lib/services/consumptionManagement/lib/models/index.d.ts index 4030a06ba8..799a163e63 100644 --- a/lib/services/consumptionManagement/lib/models/index.d.ts +++ b/lib/services/consumptionManagement/lib/models/index.d.ts @@ -18,117 +18,600 @@ export { CloudError } from 'ms-rest-azure'; /** * @class - * Initializes a new instance of the ErrorDetails class. + * Initializes a new instance of the MeterDetails class. * @constructor - * The details of the error. + * The properties of the meter detail. * - * @member {string} [code] Error code. - * @member {string} [message] Error message indicating why the operation - * failed. + * @member {string} [meterName] The name of the meter, within the given meter + * category + * @member {string} [meterCategory] The category of the meter, for example, + * 'Cloud services', 'Networking', etc.. + * @member {string} [meterSubCategory] The subcategory of the meter, for + * example, 'A6 Cloud services', 'ExpressRoute (IXP)', etc.. + * @member {string} [unit] The unit in which the meter consumption is charged, + * for example, 'Hours', 'GB', etc. + * @member {string} [meterLocation] The location in which the Azure service is + * available. + * @member {number} [totalIncludedQuantity] The total included quantity + * associated with the offer. + * @member {number} [pretaxStandardRate] The pretax listing price. + * @member {string} [serviceName] The name of the service. + * @member {string} [serviceTier] The service tier. */ -export interface ErrorDetails { - readonly code?: string; - readonly message?: string; +export interface MeterDetails { + readonly meterName?: string; + readonly meterCategory?: string; + readonly meterSubCategory?: string; + readonly unit?: string; + readonly meterLocation?: string; + readonly totalIncludedQuantity?: number; + readonly pretaxStandardRate?: number; + readonly serviceName?: string; + readonly serviceTier?: string; } /** * @class - * Initializes a new instance of the ErrorResponse class. + * Initializes a new instance of the Resource class. * @constructor - * Error response indicates that the service is not able to process the - * incoming request. The reason is provided in the error message. + * The Resource model definition. + * + * @member {string} [id] Resource Id. + * @member {string} [name] Resource name. + * @member {string} [type] Resource type. + * @member {object} [tags] Resource tags. + */ +export interface Resource extends BaseResource { + readonly id?: string; + readonly name?: string; + readonly type?: string; + readonly tags?: { [propertyName: string]: string }; +} + +/** + * @class + * Initializes a new instance of the UsageDetail class. + * @constructor + * An usage detail resource. + * + * @member {string} [billingPeriodId] The id of the billing period resource + * that the usage belongs to. + * @member {string} [invoiceId] The id of the invoice resource that the usage + * belongs to. + * @member {date} [usageStart] The start of the date time range covered by the + * usage detail. + * @member {date} [usageEnd] The end of the date time range covered by the + * usage detail. + * @member {string} [instanceName] The name of the resource instance that the + * usage is about. + * @member {string} [instanceId] The uri of the resource instance that the + * usage is about. + * @member {string} [instanceLocation] The location of the resource instance + * that the usage is about. + * @member {string} [currency] The ISO currency in which the meter is charged, + * for example, USD. + * @member {number} [usageQuantity] The quantity of usage. + * @member {number} [billableQuantity] The billable usage quantity. + * @member {number} [pretaxCost] The amount of cost before tax. + * @member {boolean} [isEstimated] The estimated usage is subject to change. + * @member {uuid} [meterId] The meter id (GUID). + * @member {object} [meterDetails] The details about the meter. By default this + * is not populated, unless it's specified in $expand. + * @member {string} [meterDetails.meterName] The name of the meter, within the + * given meter category + * @member {string} [meterDetails.meterCategory] The category of the meter, for + * example, 'Cloud services', 'Networking', etc.. + * @member {string} [meterDetails.meterSubCategory] The subcategory of the + * meter, for example, 'A6 Cloud services', 'ExpressRoute (IXP)', etc.. + * @member {string} [meterDetails.unit] The unit in which the meter consumption + * is charged, for example, 'Hours', 'GB', etc. + * @member {string} [meterDetails.meterLocation] The location in which the + * Azure service is available. + * @member {number} [meterDetails.totalIncludedQuantity] The total included + * quantity associated with the offer. + * @member {number} [meterDetails.pretaxStandardRate] The pretax listing price. + * @member {string} [meterDetails.serviceName] The name of the service. + * @member {string} [meterDetails.serviceTier] The service tier. + * @member {uuid} [subscriptionGuid] Subscription guid. + * @member {string} [subscriptionName] Subscription name. + * @member {string} [accountName] Account name. + * @member {string} [departmentName] Department name. + * @member {string} [product] Product name. + * @member {string} [consumedService] Consumed service name. + * @member {string} [costCenter] The cost center of this department if it is a + * department and a costcenter exists + * @member {string} [partNumber] Part Number + * @member {string} [resourceGuid] Resource Guid + * @member {string} [offerId] Offer Id + * @member {boolean} [chargesBilledSeparately] Charges billed separately + * @member {string} [location] Resource Location + * @member {string} [additionalProperties] Additional details of this usage + * item. By default this is not populated, unless it's specified in $expand. + */ +export interface UsageDetail extends Resource { + readonly billingPeriodId?: string; + readonly invoiceId?: string; + readonly usageStart?: Date; + readonly usageEnd?: Date; + readonly instanceName?: string; + readonly instanceId?: string; + readonly instanceLocation?: string; + readonly currency?: string; + readonly usageQuantity?: number; + readonly billableQuantity?: number; + readonly pretaxCost?: number; + readonly isEstimated?: boolean; + readonly meterId?: string; + readonly meterDetails?: MeterDetails; + readonly subscriptionGuid?: string; + readonly subscriptionName?: string; + readonly accountName?: string; + readonly departmentName?: string; + readonly product?: string; + readonly consumedService?: string; + readonly costCenter?: string; + readonly partNumber?: string; + readonly resourceGuid?: string; + readonly offerId?: string; + readonly chargesBilledSeparately?: boolean; + readonly location?: string; + readonly additionalProperties?: string; +} + +/** + * @class + * Initializes a new instance of the Marketplace class. + * @constructor + * An marketplace resource. + * + * @member {string} [billingPeriodId] The id of the billing period resource + * that the usage belongs to. + * @member {date} [usageStart] The start of the date time range covered by the + * usage detail. + * @member {date} [usageEnd] The end of the date time range covered by the + * usage detail. + * @member {number} [resourceRate] The marketplace resource rate. + * @member {string} [offerName] The type of offer. + * @member {string} [resourceGroup] The name of resource group. + * @member {string} [orderNumber] The order number. + * @member {string} [instanceName] The name of the resource instance that the + * usage is about. + * @member {string} [instanceId] The uri of the resource instance that the + * usage is about. + * @member {string} [currency] The ISO currency in which the meter is charged, + * for example, USD. + * @member {number} [consumedQuantity] The quantity of usage. + * @member {string} [unitOfMeasure] The unit of measure. + * @member {number} [pretaxCost] The amount of cost before tax. + * @member {boolean} [isEstimated] The estimated usage is subject to change. + * @member {uuid} [meterId] The meter id (GUID). + * @member {uuid} [subscriptionGuid] Subscription guid. + * @member {string} [subscriptionName] Subscription name. + * @member {string} [accountName] Account name. + * @member {string} [departmentName] Department name. + * @member {string} [consumedService] Consumed service name. + * @member {string} [costCenter] The cost center of this department if it is a + * department and a costcenter exists + * @member {string} [additionalProperties] Additional details of this usage + * item. By default this is not populated, unless it's specified in $expand. + * @member {string} [publisherName] The name of publisher. + * @member {string} [planName] The name of plan. + */ +export interface Marketplace extends Resource { + readonly billingPeriodId?: string; + readonly usageStart?: Date; + readonly usageEnd?: Date; + readonly resourceRate?: number; + readonly offerName?: string; + readonly resourceGroup?: string; + readonly orderNumber?: string; + readonly instanceName?: string; + readonly instanceId?: string; + readonly currency?: string; + readonly consumedQuantity?: number; + readonly unitOfMeasure?: string; + readonly pretaxCost?: number; + readonly isEstimated?: boolean; + readonly meterId?: string; + readonly subscriptionGuid?: string; + readonly subscriptionName?: string; + readonly accountName?: string; + readonly departmentName?: string; + readonly consumedService?: string; + readonly costCenter?: string; + readonly additionalProperties?: string; + readonly publisherName?: string; + readonly planName?: string; +} + +/** + * @class + * Initializes a new instance of the BalancePropertiesNewPurchasesDetailsItem class. + * @constructor + * @member {string} [name] the name of new purchase. + * @member {number} [value] the value of new purchase. + */ +export interface BalancePropertiesNewPurchasesDetailsItem { + readonly name?: string; + readonly value?: number; +} + +/** + * @class + * Initializes a new instance of the BalancePropertiesAdjustmentDetailsItem class. + * @constructor + * @member {string} [name] the name of new adjustment. + * @member {number} [value] the value of new adjustment. + */ +export interface BalancePropertiesAdjustmentDetailsItem { + readonly name?: string; + readonly value?: number; +} + +/** + * @class + * Initializes a new instance of the Balance class. + * @constructor + * A balance resource. + * + * @member {string} [currency] The ISO currency in which the meter is charged, + * for example, USD. + * @member {number} [beginningBalance] The beginning balance for the billing + * period. + * @member {number} [endingBalance] The ending balance for the billing period + * (for open periods this will be updated daily). + * @member {number} [newPurchases] Total new purchase amount. + * @member {number} [adjustments] Total adjustment amount. + * @member {number} [utilized] Total Commitment usage. + * @member {number} [serviceOverage] Overage for Azure services. + * @member {number} [chargesBilledSeparately] Charges Billed separately. + * @member {number} [totalOverage] serviceOverage + chargesBilledSeparately. + * @member {number} [totalUsage] Azure service commitment + total Overage. + * @member {number} [azureMarketplaceServiceCharges] Total charges for Azure + * Marketplace. + * @member {string} [billingFrequency] The billing frequency. Possible values + * include: 'Month', 'Quarter', 'Year' + * @member {boolean} [priceHidden] Price is hidden or not. + * @member {array} [newPurchasesDetails] List of new purchases. + * @member {array} [adjustmentDetails] List of Adjustments (Promo credit, SIE + * credit etc.). + */ +export interface Balance extends Resource { + readonly currency?: string; + readonly beginningBalance?: number; + readonly endingBalance?: number; + readonly newPurchases?: number; + readonly adjustments?: number; + readonly utilized?: number; + readonly serviceOverage?: number; + readonly chargesBilledSeparately?: number; + readonly totalOverage?: number; + readonly totalUsage?: number; + readonly azureMarketplaceServiceCharges?: number; + billingFrequency?: string; + readonly priceHidden?: boolean; + readonly newPurchasesDetails?: BalancePropertiesNewPurchasesDetailsItem[]; + readonly adjustmentDetails?: BalancePropertiesAdjustmentDetailsItem[]; +} + +/** + * @class + * Initializes a new instance of the ReservationSummary class. + * @constructor + * reservation summary resource. + * + * @member {string} [reservationOrderId] The reservation order ID is the + * identifier for a reservation purchase. Each reservation order ID represents + * a single purchase transaction. A reservation order contains reservations. + * The reservation order specifies the VM size and region for the reservations. + * @member {string} [reservationId] The reservation ID is the identifier of a + * reservation within a reservation order. Each reservation is the grouping for + * applying the benefit scope and also specifies the number of instances to + * which the reservation benefit can be applied to. + * @member {string} [skuName] This is the ARM Sku name. It can be used to join + * with the servicetype field in additoinalinfo in usage records. + * @member {number} [reservedHours] This is the total hours reserved. E.g. if + * reservation for 1 instance was made on 1 PM, this will be 11 hours for that + * day and 24 hours from subsequent days + * @member {date} [usageDate] Data corresponding to the utilization record. If + * the grain of data is monthly, it will be first day of month. + * @member {number} [usedHours] Total used hours by the reservation + * @member {number} [minUtilizationPercentage] This is the minimum hourly + * utilization in the usage time (day or month). E.g. if usage record + * corresponds to 12/10/2017 and on that for hour 4 and 5, utilization was 10%, + * this field will return 10% for that day + * @member {number} [avgUtilizationPercentage] This is average utilization for + * the entire time range. (day or month depending on the grain) + * @member {number} [maxUtilizationPercentage] This is the maximum hourly + * utilization in the usage time (day or month). E.g. if usage record + * corresponds to 12/10/2017 and on that for hour 4 and 5, utilization was + * 100%, this field will return 100% for that day. + */ +export interface ReservationSummary extends Resource { + readonly reservationOrderId?: string; + readonly reservationId?: string; + readonly skuName?: string; + readonly reservedHours?: number; + readonly usageDate?: Date; + readonly usedHours?: number; + readonly minUtilizationPercentage?: number; + readonly avgUtilizationPercentage?: number; + readonly maxUtilizationPercentage?: number; +} + +/** + * @class + * Initializes a new instance of the ReservationDetail class. + * @constructor + * reservation detail resource. + * + * @member {string} [reservationOrderId] The reservation order ID is the + * identifier for a reservation purchase. Each reservation order ID represents + * a single purchase transaction. A reservation order contains reservations. + * The reservation order specifies the VM size and region for the reservations. + * @member {string} [reservationId] The reservation ID is the identifier of a + * reservation within a reservation order. Each reservation is the grouping for + * applying the benefit scope and also specifies the number of instances to + * which the reservation benefit can be applied to. + * @member {string} [skuName] This is the ARM Sku name. It can be used to join + * with the servicetype field in additoinalinfo in usage records. + * @member {number} [reservedHours] This is the total hours reserved for the + * day. E.g. if reservation for 1 instance was made on 1 PM, this will be 11 + * hours for that day and 24 hours from subsequent days. + * @member {date} [usageDate] The date on which consumption occurred. + * @member {number} [usedHours] This is the total hours used by the instance. + * @member {string} [instanceId] This identifier is the name of the resource or + * the fully qualified Resource ID. + * @member {number} [totalReservedQuantity] This is the total count of + * instances that are reserved for the reservationid. + */ +export interface ReservationDetail extends Resource { + readonly reservationOrderId?: string; + readonly reservationId?: string; + readonly skuName?: string; + readonly reservedHours?: number; + readonly usageDate?: Date; + readonly usedHours?: number; + readonly instanceId?: string; + readonly totalReservedQuantity?: number; +} + +/** + * @class + * Initializes a new instance of the ReservationRecommendation class. + * @constructor + * Reservation recommendation resource. + * + * @member {string} [id] Resource Id. + * @member {string} [name] Resource name. + * @member {string} [type] Resource type. + * @member {object} [tags] Resource tags. + * @member {string} [location] Resource location + * @member {string} [sku] Resource sku + * @member {string} [lookBackPeriod] The number of days of usage to look back + * for recommendation. + * @member {uuid} [meterId] The meter id (GUID) + * @member {string} [term] RI recommendations in one or three year terms. + * @member {number} [costWithNoReservedInstances] The total amount of cost + * without reserved instances. + * @member {number} [recommendedQuantity] Recomended quality for reserved + * instances. + * @member {number} [totalCostWithReservedInstances] The total amount of cost + * with reserved instances. + * @member {number} [netSavings] Total estimated savings with reserved + * instances. + * @member {date} [firstUsageDate] The usage date for looking back. + * @member {string} [scope] Shared or single recommendation. + */ +export interface ReservationRecommendation { + readonly id?: string; + readonly name?: string; + readonly type?: string; + readonly tags?: { [propertyName: string]: string }; + readonly location?: string; + readonly sku?: string; + readonly lookBackPeriod?: string; + readonly meterId?: string; + readonly term?: string; + readonly costWithNoReservedInstances?: number; + readonly recommendedQuantity?: number; + readonly totalCostWithReservedInstances?: number; + readonly netSavings?: number; + readonly firstUsageDate?: Date; + readonly scope?: string; +} + +/** + * @class + * Initializes a new instance of the Tag class. + * @constructor + * The tag resource. + * + * @member {string} [key] Tag key. + */ +export interface Tag { + key?: string; +} + +/** + * @class + * Initializes a new instance of the ProxyResource class. + * @constructor + * The Resource model definition. + * + * @member {string} [id] Resource Id. + * @member {string} [name] Resource name. + * @member {string} [type] Resource type. + * @member {string} [eTag] eTag of the resource. To handle concurrent update + * scenarion, this field will be used to determine whether the user is updating + * the latest version or not. + */ +export interface ProxyResource extends BaseResource { + readonly id?: string; + readonly name?: string; + readonly type?: string; + eTag?: string; +} + +/** + * @class + * Initializes a new instance of the TagsResult class. + * @constructor + * A resource listing all tags. + * + * @member {array} [tags] A list of Tag. + */ +export interface TagsResult extends ProxyResource { + tags?: Tag[]; +} + +/** + * @class + * Initializes a new instance of the BudgetTimePeriod class. + * @constructor + * The start and end date for a budget. + * + * @member {date} startDate The start date for the budget. + * @member {date} [endDate] The end date for the budget. If not provided, we + * default this to 10 years from the start date. + */ +export interface BudgetTimePeriod { + startDate: Date; + endDate?: Date; +} + +/** + * @class + * Initializes a new instance of the Filters class. + * @constructor + * May be used to filter budgets by resource group, resource, or meter. + * + * @member {array} [resourceGroups] The list of filters on resource groups, + * allowed at subscription level only. + * @member {array} [resources] The list of filters on resources. + * @member {array} [meters] The list of filters on meters (GUID), mandatory for + * budgets of usage category. + * @member {object} [tags] The dictionary of filters on tags. + */ +export interface Filters { + resourceGroups?: string[]; + resources?: string[]; + meters?: string[]; + tags?: { [propertyName: string]: string[] }; +} + +/** + * @class + * Initializes a new instance of the CurrentSpend class. + * @constructor + * The current amount of cost which is being tracked for a budget. * - * @member {object} [error] The details of the error. - * @member {string} [error.code] Error code. - * @member {string} [error.message] Error message indicating why the operation - * failed. + * @member {number} [amount] The total amount of cost which is being tracked by + * the budget. + * @member {string} [unit] The unit of measure for the budget amount. */ -export interface ErrorResponse { - error?: ErrorDetails; +export interface CurrentSpend { + readonly amount?: number; + readonly unit?: string; } /** * @class - * Initializes a new instance of the OperationDisplay class. + * Initializes a new instance of the Notification class. * @constructor - * The object that represents the operation. + * The notification associated with a budget. * - * @member {string} [provider] Service provider: Microsoft.Consumption. - * @member {string} [resource] Resource on which the operation is performed: - * UsageDetail, etc. - * @member {string} [operation] Operation type: Read, write, delete, etc. + * @member {boolean} enabled The notification is enabled or not. + * @member {string} operator The comparison operator. Possible values include: + * 'EqualTo', 'GreaterThan', 'GreaterThanOrEqualTo' + * @member {number} threshold Threshold value associated with a notification. + * Notification is sent when the cost exceeded the threshold. It is always + * percent and has to be between 0 and 1000. + * @member {array} contactEmails Email addresses to send the budget + * notification to when the threshold is exceeded. + * @member {array} [contactRoles] Contact roles to send the budget notification + * to when the threshold is exceeded. + * @member {array} [contactGroups] Action groups to send the budget + * notification to when the threshold is exceeded. */ -export interface OperationDisplay { - readonly provider?: string; - readonly resource?: string; - readonly operation?: string; +export interface Notification { + enabled: boolean; + operator: string; + threshold: number; + contactEmails: string[]; + contactRoles?: string[]; + contactGroups?: string[]; } /** * @class - * Initializes a new instance of the Operation class. + * Initializes a new instance of the Budget class. * @constructor - * A Consumption REST API operation. + * A budget resource. * - * @member {string} [name] Operation name: {provider}/{resource}/{operation}. - * @member {object} [display] The object that represents the operation. - * @member {string} [display.provider] Service provider: Microsoft.Consumption. - * @member {string} [display.resource] Resource on which the operation is - * performed: UsageDetail, etc. - * @member {string} [display.operation] Operation type: Read, write, delete, - * etc. + * @member {string} category The category of the budget, whether the budget + * tracks cost or usage. Possible values include: 'Cost', 'Usage' + * @member {number} amount The total amount of cost to track with the budget + * @member {string} timeGrain The time covered by a budget. Tracking of the + * amount will be reset based on the time grain. Possible values include: + * 'Monthly', 'Quarterly', 'Annually' + * @member {object} timePeriod Has start and end date of the budget. The start + * date must be first of the month and should be less than the end date. Budget + * start date must be on or after June 1, 2017. Future start date should not be + * more than three months. Past start date should be selected within the + * timegrain preiod. There are no restrictions on the end date. + * @member {date} [timePeriod.startDate] The start date for the budget. + * @member {date} [timePeriod.endDate] The end date for the budget. If not + * provided, we default this to 10 years from the start date. + * @member {object} [filters] May be used to filter budgets by resource group, + * resource, or meter. + * @member {array} [filters.resourceGroups] The list of filters on resource + * groups, allowed at subscription level only. + * @member {array} [filters.resources] The list of filters on resources. + * @member {array} [filters.meters] The list of filters on meters (GUID), + * mandatory for budgets of usage category. + * @member {object} [filters.tags] The dictionary of filters on tags. + * @member {object} [currentSpend] The current amount of cost which is being + * tracked for a budget. + * @member {number} [currentSpend.amount] The total amount of cost which is + * being tracked by the budget. + * @member {string} [currentSpend.unit] The unit of measure for the budget + * amount. + * @member {object} [notifications] Dictionary of notifications associated with + * the budget. Budget can have up to five notifications. */ -export interface Operation { - readonly name?: string; - display?: OperationDisplay; +export interface Budget extends ProxyResource { + category: string; + amount: number; + timeGrain: string; + timePeriod: BudgetTimePeriod; + filters?: Filters; + readonly currentSpend?: CurrentSpend; + notifications?: { [propertyName: string]: Notification }; } /** * @class - * Initializes a new instance of the Resource class. + * Initializes a new instance of the CostTagProperties class. * @constructor - * The Resource model definition. + * The properties of the cost tag. * - * @member {string} [id] Resource Id. - * @member {string} [name] Resource name. - * @member {string} [type] Resource type. - * @member {object} [tags] Resource tags. + * @member {string} [key] Cost tag key. */ -export interface Resource extends BaseResource { - readonly id?: string; - readonly name?: string; - readonly type?: string; - readonly tags?: { [propertyName: string]: string }; +export interface CostTagProperties { + key?: string; } /** * @class - * Initializes a new instance of the MeterDetails class. + * Initializes a new instance of the CostTag class. * @constructor - * The properties of the meter detail. + * A cost tag resource. * - * @member {string} [meterName] The name of the meter, within the given meter - * category - * @member {string} [meterCategory] The category of the meter, for example, - * 'Cloud services', 'Networking', etc.. - * @member {string} [meterSubCategory] The subcategory of the meter, for - * example, 'A6 Cloud services', 'ExpressRoute (IXP)', etc.. - * @member {string} [unit] The unit in which the meter consumption is charged, - * for example, 'Hours', 'GB', etc. - * @member {string} [meterLocation] The location in which the Azure service is - * available. - * @member {number} [totalIncludedQuantity] The total included quantity - * associated with the offer. - * @member {number} [pretaxStandardRate] The pretax listing price. + * @member {array} [costTags] Cost tags. */ -export interface MeterDetails { - readonly meterName?: string; - readonly meterCategory?: string; - readonly meterSubCategory?: string; - readonly unit?: string; - readonly meterLocation?: string; - readonly totalIncludedQuantity?: number; - readonly pretaxStandardRate?: number; +export interface CostTag extends ProxyResource { + costTags?: CostTagProperties[]; } /** @@ -155,6 +638,8 @@ export interface MeterDetails { * @member {number} [meterDetails.totalIncludedQuantity] The total included * quantity associated with the offer. * @member {number} [meterDetails.pretaxStandardRate] The pretax listing price. + * @member {string} [meterDetails.serviceName] The name of the service. + * @member {string} [meterDetails.serviceTier] The service tier. * @member {string} [unitOfMeasure] Unit of measure * @member {number} [includedQuantity] Included quality for an offer * @member {string} [partNumber] Part Number @@ -231,88 +716,83 @@ export interface Forecast extends Resource { /** * @class - * Initializes a new instance of the UsageDetail class. + * Initializes a new instance of the ErrorDetails class. * @constructor - * An usage detail resource. + * The details of the error. * - * @member {string} [billingPeriodId] The id of the billing period resource - * that the usage belongs to. - * @member {string} [invoiceId] The id of the invoice resource that the usage - * belongs to. - * @member {date} [usageStart] The start of the date time range covered by the - * usage detail. - * @member {date} [usageEnd] The end of the date time range covered by the - * usage detail. - * @member {string} [instanceName] The name of the resource instance that the - * usage is about. - * @member {string} [instanceId] The uri of the resource instance that the - * usage is about. - * @member {string} [instanceLocation] The location of the resource instance - * that the usage is about. - * @member {string} [currency] The ISO currency in which the meter is charged, - * for example, USD. - * @member {number} [usageQuantity] The quantity of usage. - * @member {number} [billableQuantity] The billable usage quantity. - * @member {number} [pretaxCost] The amount of cost before tax. - * @member {boolean} [isEstimated] The estimated usage is subject to change. - * @member {uuid} [meterId] The meter id (GUID). - * @member {object} [meterDetails] The details about the meter. By default this - * is not populated, unless it's specified in $expand. - * @member {string} [meterDetails.meterName] The name of the meter, within the - * given meter category - * @member {string} [meterDetails.meterCategory] The category of the meter, for - * example, 'Cloud services', 'Networking', etc.. - * @member {string} [meterDetails.meterSubCategory] The subcategory of the - * meter, for example, 'A6 Cloud services', 'ExpressRoute (IXP)', etc.. - * @member {string} [meterDetails.unit] The unit in which the meter consumption - * is charged, for example, 'Hours', 'GB', etc. - * @member {string} [meterDetails.meterLocation] The location in which the - * Azure service is available. - * @member {number} [meterDetails.totalIncludedQuantity] The total included - * quantity associated with the offer. - * @member {number} [meterDetails.pretaxStandardRate] The pretax listing price. - * @member {uuid} [subscriptionGuid] Subscription guid. - * @member {string} [subscriptionName] Subscription name. - * @member {string} [accountName] Account name. - * @member {string} [departmentName] Department name. - * @member {string} [product] Product name. - * @member {string} [consumedService] Consumed service name. - * @member {string} [costCenter] The cost center of this department if it is a - * department and a costcenter exists - * @member {string} [partNumber] Part Number - * @member {string} [resourceGuid] Resource Guid - * @member {string} [offerId] Offer Id - * @member {boolean} [chargesBilledSeparately] Charges billed separately - * @member {string} [additionalProperties] Additional details of this usage - * item. By default this is not populated, unless it's specified in $expand. + * @member {string} [code] Error code. + * @member {string} [message] Error message indicating why the operation + * failed. */ -export interface UsageDetail extends Resource { - readonly billingPeriodId?: string; - readonly invoiceId?: string; - readonly usageStart?: Date; - readonly usageEnd?: Date; - readonly instanceName?: string; - readonly instanceId?: string; - readonly instanceLocation?: string; - readonly currency?: string; - readonly usageQuantity?: number; - readonly billableQuantity?: number; - readonly pretaxCost?: number; - readonly isEstimated?: boolean; - readonly meterId?: string; - readonly meterDetails?: MeterDetails; - readonly subscriptionGuid?: string; - readonly subscriptionName?: string; - readonly accountName?: string; - readonly departmentName?: string; - readonly product?: string; - readonly consumedService?: string; - readonly costCenter?: string; - readonly partNumber?: string; - readonly resourceGuid?: string; - readonly offerId?: string; - readonly chargesBilledSeparately?: boolean; - readonly additionalProperties?: string; +export interface ErrorDetails { + readonly code?: string; + readonly message?: string; +} + +/** + * @class + * Initializes a new instance of the ErrorResponse class. + * @constructor + * Error response indicates that the service is not able to process the + * incoming request. The reason is provided in the error message. + * + * @member {object} [error] The details of the error. + * @member {string} [error.code] Error code. + * @member {string} [error.message] Error message indicating why the operation + * failed. + */ +export interface ErrorResponse { + error?: ErrorDetails; +} + +/** + * @class + * Initializes a new instance of the OperationDisplay class. + * @constructor + * The object that represents the operation. + * + * @member {string} [provider] Service provider: Microsoft.Consumption. + * @member {string} [resource] Resource on which the operation is performed: + * UsageDetail, etc. + * @member {string} [operation] Operation type: Read, write, delete, etc. + */ +export interface OperationDisplay { + readonly provider?: string; + readonly resource?: string; + readonly operation?: string; +} + +/** + * @class + * Initializes a new instance of the Operation class. + * @constructor + * A Consumption REST API operation. + * + * @member {string} [name] Operation name: {provider}/{resource}/{operation}. + * @member {object} [display] The object that represents the operation. + * @member {string} [display.provider] Service provider: Microsoft.Consumption. + * @member {string} [display.resource] Resource on which the operation is + * performed: UsageDetail, etc. + * @member {string} [display.operation] Operation type: Read, write, delete, + * etc. + */ +export interface Operation { + readonly name?: string; + display?: OperationDisplay; +} + +/** + * @class + * Initializes a new instance of the ResourceAttributes class. + * @constructor + * The Resource model definition. + * + * @member {string} [location] Resource location + * @member {string} [sku] Resource sku + */ +export interface ResourceAttributes { + readonly location?: string; + readonly sku?: string; } /** @@ -342,6 +822,68 @@ export interface UsageDetailsListResult extends Array { readonly nextLink?: string; } +/** + * @class + * Initializes a new instance of the MarketplacesListResult class. + * @constructor + * Result of listing marketplaces. It contains a list of available marketplaces + * in reverse chronological order by billing period. + * + * @member {string} [nextLink] The link (url) to the next page of results. + */ +export interface MarketplacesListResult extends Array { + readonly nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the ReservationSummariesListResult class. + * @constructor + * Result of listing reservation summaries. + * + * @member {string} [nextLink] The link (url) to the next page of results. + */ +export interface ReservationSummariesListResult extends Array { + readonly nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the ReservationDetailsListResult class. + * @constructor + * Result of listing reservation details. + * + * @member {string} [nextLink] The link (url) to the next page of results. + */ +export interface ReservationDetailsListResult extends Array { + readonly nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the ReservationRecommendationsListResult class. + * @constructor + * Result of listing reservation recommendations. + * + * @member {string} [nextLink] The link (url) to the next page of results. + */ +export interface ReservationRecommendationsListResult extends Array { + readonly nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the BudgetsListResult class. + * @constructor + * Result of listing budgets. It contains a list of available budgets in the + * scope provided. + * + * @member {string} [nextLink] The link (url) to the next page of results. + */ +export interface BudgetsListResult extends Array { + readonly nextLink?: string; +} + /** * @class * Initializes a new instance of the ForecastsListResult class. diff --git a/lib/services/consumptionManagement/lib/models/index.js b/lib/services/consumptionManagement/lib/models/index.js index 72a500dca9..b9ab71cd44 100644 --- a/lib/services/consumptionManagement/lib/models/index.js +++ b/lib/services/consumptionManagement/lib/models/index.js @@ -18,18 +18,41 @@ var msRestAzure = require('ms-rest-azure'); exports.BaseResource = msRestAzure.BaseResource; exports.CloudError = msRestAzure.CloudError; -exports.ErrorDetails = require('./errorDetails'); -exports.ErrorResponse = require('./errorResponse'); -exports.OperationDisplay = require('./operationDisplay'); -exports.Operation = require('./operation'); -exports.Resource = require('./resource'); exports.MeterDetails = require('./meterDetails'); +exports.Resource = require('./resource'); +exports.UsageDetail = require('./usageDetail'); +exports.Marketplace = require('./marketplace'); +exports.BalancePropertiesNewPurchasesDetailsItem = require('./balancePropertiesNewPurchasesDetailsItem'); +exports.BalancePropertiesAdjustmentDetailsItem = require('./balancePropertiesAdjustmentDetailsItem'); +exports.Balance = require('./balance'); +exports.ReservationSummary = require('./reservationSummary'); +exports.ReservationDetail = require('./reservationDetail'); +exports.ReservationRecommendation = require('./reservationRecommendation'); +exports.Tag = require('./tag'); +exports.ProxyResource = require('./proxyResource'); +exports.TagsResult = require('./tagsResult'); +exports.BudgetTimePeriod = require('./budgetTimePeriod'); +exports.Filters = require('./filters'); +exports.CurrentSpend = require('./currentSpend'); +exports.Notification = require('./notification'); +exports.Budget = require('./budget'); +exports.CostTagProperties = require('./costTagProperties'); +exports.CostTag = require('./costTag'); exports.PriceSheetProperties = require('./priceSheetProperties'); exports.PriceSheetResult = require('./priceSheetResult'); exports.ForecastPropertiesConfidenceLevelsItem = require('./forecastPropertiesConfidenceLevelsItem'); exports.Forecast = require('./forecast'); -exports.UsageDetail = require('./usageDetail'); +exports.ErrorDetails = require('./errorDetails'); +exports.ErrorResponse = require('./errorResponse'); +exports.OperationDisplay = require('./operationDisplay'); +exports.Operation = require('./operation'); +exports.ResourceAttributes = require('./resourceAttributes'); exports.QueryOptions = require('./queryOptions'); exports.UsageDetailsListResult = require('./usageDetailsListResult'); +exports.MarketplacesListResult = require('./marketplacesListResult'); +exports.ReservationSummariesListResult = require('./reservationSummariesListResult'); +exports.ReservationDetailsListResult = require('./reservationDetailsListResult'); +exports.ReservationRecommendationsListResult = require('./reservationRecommendationsListResult'); +exports.BudgetsListResult = require('./budgetsListResult'); exports.ForecastsListResult = require('./forecastsListResult'); exports.OperationListResult = require('./operationListResult'); diff --git a/lib/services/consumptionManagement/lib/models/meterDetails.js b/lib/services/consumptionManagement/lib/models/meterDetails.js index 3420ce4172..9f38c8d5f7 100644 --- a/lib/services/consumptionManagement/lib/models/meterDetails.js +++ b/lib/services/consumptionManagement/lib/models/meterDetails.js @@ -30,6 +30,8 @@ class MeterDetails { * @member {number} [totalIncludedQuantity] The total included quantity * associated with the offer. * @member {number} [pretaxStandardRate] The pretax listing price. + * @member {string} [serviceName] The name of the service. + * @member {string} [serviceTier] The service tier. */ constructor() { } @@ -103,6 +105,22 @@ class MeterDetails { type: { name: 'Number' } + }, + serviceName: { + required: false, + readOnly: true, + serializedName: 'serviceName', + type: { + name: 'String' + } + }, + serviceTier: { + required: false, + readOnly: true, + serializedName: 'serviceTier', + type: { + name: 'String' + } } } } diff --git a/lib/services/consumptionManagement/lib/models/priceSheetProperties.js b/lib/services/consumptionManagement/lib/models/priceSheetProperties.js index 42cec9de79..7fc321d7ef 100644 --- a/lib/services/consumptionManagement/lib/models/priceSheetProperties.js +++ b/lib/services/consumptionManagement/lib/models/priceSheetProperties.js @@ -38,6 +38,8 @@ class PriceSheetProperties { * quantity associated with the offer. * @member {number} [meterDetails.pretaxStandardRate] The pretax listing * price. + * @member {string} [meterDetails.serviceName] The name of the service. + * @member {string} [meterDetails.serviceTier] The service tier. * @member {string} [unitOfMeasure] Unit of measure * @member {number} [includedQuantity] Included quality for an offer * @member {string} [partNumber] Part Number diff --git a/lib/services/consumptionManagement/lib/models/reservationDetail.js b/lib/services/consumptionManagement/lib/models/reservationDetail.js new file mode 100644 index 0000000000..e6b382824e --- /dev/null +++ b/lib/services/consumptionManagement/lib/models/reservationDetail.js @@ -0,0 +1,171 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * reservation detail resource. + * + * @extends models['Resource'] + */ +class ReservationDetail extends models['Resource'] { + /** + * Create a ReservationDetail. + * @member {string} [reservationOrderId] The reservation order ID is the + * identifier for a reservation purchase. Each reservation order ID + * represents a single purchase transaction. A reservation order contains + * reservations. The reservation order specifies the VM size and region for + * the reservations. + * @member {string} [reservationId] The reservation ID is the identifier of a + * reservation within a reservation order. Each reservation is the grouping + * for applying the benefit scope and also specifies the number of instances + * to which the reservation benefit can be applied to. + * @member {string} [skuName] This is the ARM Sku name. It can be used to + * join with the servicetype field in additoinalinfo in usage records. + * @member {number} [reservedHours] This is the total hours reserved for the + * day. E.g. if reservation for 1 instance was made on 1 PM, this will be 11 + * hours for that day and 24 hours from subsequent days. + * @member {date} [usageDate] The date on which consumption occurred. + * @member {number} [usedHours] This is the total hours used by the instance. + * @member {string} [instanceId] This identifier is the name of the resource + * or the fully qualified Resource ID. + * @member {number} [totalReservedQuantity] This is the total count of + * instances that are reserved for the reservationid. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ReservationDetail + * + * @returns {object} metadata of ReservationDetail + * + */ + mapper() { + return { + required: false, + serializedName: 'ReservationDetail', + type: { + name: 'Composite', + className: 'ReservationDetail', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + tags: { + required: false, + readOnly: true, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + reservationOrderId: { + required: false, + readOnly: true, + serializedName: 'properties.reservationOrderId', + type: { + name: 'String' + } + }, + reservationId: { + required: false, + readOnly: true, + serializedName: 'properties.reservationId', + type: { + name: 'String' + } + }, + skuName: { + required: false, + readOnly: true, + serializedName: 'properties.skuName', + type: { + name: 'String' + } + }, + reservedHours: { + required: false, + readOnly: true, + serializedName: 'properties.reservedHours', + type: { + name: 'Number' + } + }, + usageDate: { + required: false, + readOnly: true, + serializedName: 'properties.usageDate', + type: { + name: 'DateTime' + } + }, + usedHours: { + required: false, + readOnly: true, + serializedName: 'properties.usedHours', + type: { + name: 'Number' + } + }, + instanceId: { + required: false, + readOnly: true, + serializedName: 'properties.instanceId', + type: { + name: 'String' + } + }, + totalReservedQuantity: { + required: false, + readOnly: true, + serializedName: 'properties.totalReservedQuantity', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = ReservationDetail; diff --git a/lib/services/consumptionManagement/lib/models/reservationDetailsListResult.js b/lib/services/consumptionManagement/lib/models/reservationDetailsListResult.js index 2e81e65d1a..3739225d33 100644 --- a/lib/services/consumptionManagement/lib/models/reservationDetailsListResult.js +++ b/lib/services/consumptionManagement/lib/models/reservationDetailsListResult.js @@ -44,10 +44,10 @@ class ReservationDetailsListResult extends Array { name: 'Sequence', element: { required: false, - serializedName: 'ReservationDetailsElementType', + serializedName: 'ReservationDetailElementType', type: { name: 'Composite', - className: 'ReservationDetails' + className: 'ReservationDetail' } } } diff --git a/lib/services/consumptionManagement/lib/models/reservationRecommendation.js b/lib/services/consumptionManagement/lib/models/reservationRecommendation.js new file mode 100644 index 0000000000..0e4dcc4ca0 --- /dev/null +++ b/lib/services/consumptionManagement/lib/models/reservationRecommendation.js @@ -0,0 +1,191 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Reservation recommendation resource. + * + */ +class ReservationRecommendation { + /** + * Create a ReservationRecommendation. + * @member {string} [id] Resource Id. + * @member {string} [name] Resource name. + * @member {string} [type] Resource type. + * @member {object} [tags] Resource tags. + * @member {string} [location] Resource location + * @member {string} [sku] Resource sku + * @member {string} [lookBackPeriod] The number of days of usage to look back + * for recommendation. + * @member {uuid} [meterId] The meter id (GUID) + * @member {string} [term] RI recommendations in one or three year terms. + * @member {number} [costWithNoReservedInstances] The total amount of cost + * without reserved instances. + * @member {number} [recommendedQuantity] Recomended quality for reserved + * instances. + * @member {number} [totalCostWithReservedInstances] The total amount of cost + * with reserved instances. + * @member {number} [netSavings] Total estimated savings with reserved + * instances. + * @member {date} [firstUsageDate] The usage date for looking back. + * @member {string} [scope] Shared or single recommendation. + */ + constructor() { + } + + /** + * Defines the metadata of ReservationRecommendation + * + * @returns {object} metadata of ReservationRecommendation + * + */ + mapper() { + return { + required: false, + serializedName: 'ReservationRecommendation', + type: { + name: 'Composite', + className: 'ReservationRecommendation', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + tags: { + required: false, + readOnly: true, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + location: { + required: false, + readOnly: true, + serializedName: 'location', + type: { + name: 'String' + } + }, + sku: { + required: false, + readOnly: true, + serializedName: 'sku', + type: { + name: 'String' + } + }, + lookBackPeriod: { + required: false, + readOnly: true, + serializedName: 'properties.lookBackPeriod', + type: { + name: 'String' + } + }, + meterId: { + required: false, + readOnly: true, + serializedName: 'properties.meterId', + type: { + name: 'String' + } + }, + term: { + required: false, + readOnly: true, + serializedName: 'properties.term', + type: { + name: 'String' + } + }, + costWithNoReservedInstances: { + required: false, + readOnly: true, + serializedName: 'properties.costWithNoReservedInstances', + type: { + name: 'Number' + } + }, + recommendedQuantity: { + required: false, + readOnly: true, + serializedName: 'properties.recommendedQuantity', + type: { + name: 'Number' + } + }, + totalCostWithReservedInstances: { + required: false, + readOnly: true, + serializedName: 'properties.totalCostWithReservedInstances', + type: { + name: 'Number' + } + }, + netSavings: { + required: false, + readOnly: true, + serializedName: 'properties.netSavings', + type: { + name: 'Number' + } + }, + firstUsageDate: { + required: false, + readOnly: true, + serializedName: 'properties.firstUsageDate', + type: { + name: 'DateTime' + } + }, + scope: { + required: false, + readOnly: true, + serializedName: 'properties.scope', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ReservationRecommendation; diff --git a/lib/services/consumptionManagement/lib/models/reservationRecommendationsListResult.js b/lib/services/consumptionManagement/lib/models/reservationRecommendationsListResult.js index b7529c060d..c689e9857b 100644 --- a/lib/services/consumptionManagement/lib/models/reservationRecommendationsListResult.js +++ b/lib/services/consumptionManagement/lib/models/reservationRecommendationsListResult.js @@ -44,10 +44,10 @@ class ReservationRecommendationsListResult extends Array { name: 'Sequence', element: { required: false, - serializedName: 'ReservationRecommendationsElementType', + serializedName: 'ReservationRecommendationElementType', type: { name: 'Composite', - className: 'ReservationRecommendations' + className: 'ReservationRecommendation' } } } diff --git a/lib/services/consumptionManagement/lib/models/reservationSummariesListResult.js b/lib/services/consumptionManagement/lib/models/reservationSummariesListResult.js index 864c674160..b5abffdb42 100644 --- a/lib/services/consumptionManagement/lib/models/reservationSummariesListResult.js +++ b/lib/services/consumptionManagement/lib/models/reservationSummariesListResult.js @@ -44,10 +44,10 @@ class ReservationSummariesListResult extends Array { name: 'Sequence', element: { required: false, - serializedName: 'ReservationSummariesElementType', + serializedName: 'ReservationSummaryElementType', type: { name: 'Composite', - className: 'ReservationSummaries' + className: 'ReservationSummary' } } } diff --git a/lib/services/consumptionManagement/lib/models/reservationSummary.js b/lib/services/consumptionManagement/lib/models/reservationSummary.js new file mode 100644 index 0000000000..b7b1928543 --- /dev/null +++ b/lib/services/consumptionManagement/lib/models/reservationSummary.js @@ -0,0 +1,186 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * reservation summary resource. + * + * @extends models['Resource'] + */ +class ReservationSummary extends models['Resource'] { + /** + * Create a ReservationSummary. + * @member {string} [reservationOrderId] The reservation order ID is the + * identifier for a reservation purchase. Each reservation order ID + * represents a single purchase transaction. A reservation order contains + * reservations. The reservation order specifies the VM size and region for + * the reservations. + * @member {string} [reservationId] The reservation ID is the identifier of a + * reservation within a reservation order. Each reservation is the grouping + * for applying the benefit scope and also specifies the number of instances + * to which the reservation benefit can be applied to. + * @member {string} [skuName] This is the ARM Sku name. It can be used to + * join with the servicetype field in additoinalinfo in usage records. + * @member {number} [reservedHours] This is the total hours reserved. E.g. if + * reservation for 1 instance was made on 1 PM, this will be 11 hours for + * that day and 24 hours from subsequent days + * @member {date} [usageDate] Data corresponding to the utilization record. + * If the grain of data is monthly, it will be first day of month. + * @member {number} [usedHours] Total used hours by the reservation + * @member {number} [minUtilizationPercentage] This is the minimum hourly + * utilization in the usage time (day or month). E.g. if usage record + * corresponds to 12/10/2017 and on that for hour 4 and 5, utilization was + * 10%, this field will return 10% for that day + * @member {number} [avgUtilizationPercentage] This is average utilization + * for the entire time range. (day or month depending on the grain) + * @member {number} [maxUtilizationPercentage] This is the maximum hourly + * utilization in the usage time (day or month). E.g. if usage record + * corresponds to 12/10/2017 and on that for hour 4 and 5, utilization was + * 100%, this field will return 100% for that day. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ReservationSummary + * + * @returns {object} metadata of ReservationSummary + * + */ + mapper() { + return { + required: false, + serializedName: 'ReservationSummary', + type: { + name: 'Composite', + className: 'ReservationSummary', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + tags: { + required: false, + readOnly: true, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + reservationOrderId: { + required: false, + readOnly: true, + serializedName: 'properties.reservationOrderId', + type: { + name: 'String' + } + }, + reservationId: { + required: false, + readOnly: true, + serializedName: 'properties.reservationId', + type: { + name: 'String' + } + }, + skuName: { + required: false, + readOnly: true, + serializedName: 'properties.skuName', + type: { + name: 'String' + } + }, + reservedHours: { + required: false, + readOnly: true, + serializedName: 'properties.reservedHours', + type: { + name: 'Number' + } + }, + usageDate: { + required: false, + readOnly: true, + serializedName: 'properties.usageDate', + type: { + name: 'DateTime' + } + }, + usedHours: { + required: false, + readOnly: true, + serializedName: 'properties.usedHours', + type: { + name: 'Number' + } + }, + minUtilizationPercentage: { + required: false, + readOnly: true, + serializedName: 'properties.minUtilizationPercentage', + type: { + name: 'Number' + } + }, + avgUtilizationPercentage: { + required: false, + readOnly: true, + serializedName: 'properties.avgUtilizationPercentage', + type: { + name: 'Number' + } + }, + maxUtilizationPercentage: { + required: false, + readOnly: true, + serializedName: 'properties.maxUtilizationPercentage', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = ReservationSummary; diff --git a/lib/services/consumptionManagement/lib/models/tagsResult.js b/lib/services/consumptionManagement/lib/models/tagsResult.js new file mode 100644 index 0000000000..54cd3eaca9 --- /dev/null +++ b/lib/services/consumptionManagement/lib/models/tagsResult.js @@ -0,0 +1,95 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * A resource listing all tags. + * + * @extends models['ProxyResource'] + */ +class TagsResult extends models['ProxyResource'] { + /** + * Create a TagsResult. + * @member {array} [tags] A list of Tag. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of TagsResult + * + * @returns {object} metadata of TagsResult + * + */ + mapper() { + return { + required: false, + serializedName: 'TagsResult', + type: { + name: 'Composite', + className: 'TagsResult', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + eTag: { + required: false, + serializedName: 'eTag', + type: { + name: 'String' + } + }, + tags: { + required: false, + serializedName: 'properties.tags', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'TagElementType', + type: { + name: 'Composite', + className: 'Tag' + } + } + } + } + } + } + }; + } +} + +module.exports = TagsResult; diff --git a/lib/services/consumptionManagement/lib/models/usageDetail.js b/lib/services/consumptionManagement/lib/models/usageDetail.js index 5fbbcdaa37..fca8718d41 100644 --- a/lib/services/consumptionManagement/lib/models/usageDetail.js +++ b/lib/services/consumptionManagement/lib/models/usageDetail.js @@ -57,6 +57,8 @@ class UsageDetail extends models['Resource'] { * quantity associated with the offer. * @member {number} [meterDetails.pretaxStandardRate] The pretax listing * price. + * @member {string} [meterDetails.serviceName] The name of the service. + * @member {string} [meterDetails.serviceTier] The service tier. * @member {uuid} [subscriptionGuid] Subscription guid. * @member {string} [subscriptionName] Subscription name. * @member {string} [accountName] Account name. @@ -69,6 +71,7 @@ class UsageDetail extends models['Resource'] { * @member {string} [resourceGuid] Resource Guid * @member {string} [offerId] Offer Id * @member {boolean} [chargesBilledSeparately] Charges billed separately + * @member {string} [location] Resource Location * @member {string} [additionalProperties] Additional details of this usage * item. By default this is not populated, unless it's specified in $expand. */ @@ -330,6 +333,14 @@ class UsageDetail extends models['Resource'] { name: 'Boolean' } }, + location: { + required: false, + readOnly: true, + serializedName: 'properties.location', + type: { + name: 'String' + } + }, additionalProperties: { required: false, readOnly: true, diff --git a/lib/services/consumptionManagement/lib/operations/balances.js b/lib/services/consumptionManagement/lib/operations/balances.js new file mode 100644 index 0000000000..17e2d6c80d --- /dev/null +++ b/lib/services/consumptionManagement/lib/operations/balances.js @@ -0,0 +1,483 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets the balances for a scope by billingAccountId. Balances are available + * via this API only for May 1, 2014 or later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Balance} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _getByBillingAccount(billingAccountId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/balances'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Balance']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets the balances for a scope by billing period and billingAccountId. + * Balances are available via this API only for May 1, 2014 or later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Balance} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _getForBillingPeriodByBillingAccount(billingAccountId, billingPeriodName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (billingPeriodName === null || billingPeriodName === undefined || typeof billingPeriodName.valueOf() !== 'string') { + throw new Error('billingPeriodName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/balances'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{billingPeriodName}', encodeURIComponent(billingPeriodName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Balance']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a Balances. */ +class Balances { + /** + * Create a Balances. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._getByBillingAccount = _getByBillingAccount; + this._getForBillingPeriodByBillingAccount = _getForBillingPeriodByBillingAccount; + } + + /** + * Gets the balances for a scope by billingAccountId. Balances are available + * via this API only for May 1, 2014 or later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getByBillingAccountWithHttpOperationResponse(billingAccountId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._getByBillingAccount(billingAccountId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the balances for a scope by billingAccountId. Balances are available + * via this API only for May 1, 2014 or later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Balance} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Balance} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + getByBillingAccount(billingAccountId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._getByBillingAccount(billingAccountId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._getByBillingAccount(billingAccountId, options, optionalCallback); + } + } + + /** + * Gets the balances for a scope by billing period and billingAccountId. + * Balances are available via this API only for May 1, 2014 or later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getForBillingPeriodByBillingAccountWithHttpOperationResponse(billingAccountId, billingPeriodName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._getForBillingPeriodByBillingAccount(billingAccountId, billingPeriodName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the balances for a scope by billing period and billingAccountId. + * Balances are available via this API only for May 1, 2014 or later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Balance} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Balance} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + getForBillingPeriodByBillingAccount(billingAccountId, billingPeriodName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._getForBillingPeriodByBillingAccount(billingAccountId, billingPeriodName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._getForBillingPeriodByBillingAccount(billingAccountId, billingPeriodName, options, optionalCallback); + } + } + +} + +module.exports = Balances; diff --git a/lib/services/consumptionManagement/lib/operations/costTags.js b/lib/services/consumptionManagement/lib/operations/costTags.js new file mode 100644 index 0000000000..15f495039d --- /dev/null +++ b/lib/services/consumptionManagement/lib/operations/costTags.js @@ -0,0 +1,537 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Get cost tags for a billing account. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link CostTag} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(billingAccountId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/costTags'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['CostTag']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * The operation to create or update cost tags assiciated with a billing + * account. Update operation requires latest eTag to be set in the request + * mandatorily. You may obtain the latest eTag by performing a get operation. + * Create operation does not require eTag. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} parameters Parameters supplied to the Create cost tags + * operation. + * + * @param {array} [parameters.costTags] Cost tags. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link CostTag} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(billingAccountId, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/costTags'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['CostTag']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['CostTag']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['CostTag']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a CostTags. */ +class CostTags { + /** + * Create a CostTags. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + } + + /** + * Get cost tags for a billing account. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(billingAccountId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get cost tags for a billing account. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {CostTag} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link CostTag} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(billingAccountId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(billingAccountId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountId, options, optionalCallback); + } + } + + /** + * The operation to create or update cost tags assiciated with a billing + * account. Update operation requires latest eTag to be set in the request + * mandatorily. You may obtain the latest eTag by performing a get operation. + * Create operation does not require eTag. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} parameters Parameters supplied to the Create cost tags + * operation. + * + * @param {array} [parameters.costTags] Cost tags. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createOrUpdateWithHttpOperationResponse(billingAccountId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(billingAccountId, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * The operation to create or update cost tags assiciated with a billing + * account. Update operation requires latest eTag to be set in the request + * mandatorily. You may obtain the latest eTag by performing a get operation. + * Create operation does not require eTag. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} parameters Parameters supplied to the Create cost tags + * operation. + * + * @param {array} [parameters.costTags] Cost tags. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {CostTag} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link CostTag} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(billingAccountId, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(billingAccountId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(billingAccountId, parameters, options, optionalCallback); + } + } + +} + +module.exports = CostTags; diff --git a/lib/services/consumptionManagement/lib/operations/index.d.ts b/lib/services/consumptionManagement/lib/operations/index.d.ts index c56b27cd21..7f218b2ea9 100644 --- a/lib/services/consumptionManagement/lib/operations/index.d.ts +++ b/lib/services/consumptionManagement/lib/operations/index.d.ts @@ -12,173 +12,6 @@ import { ServiceClientOptions, RequestOptions, ServiceCallback, HttpOperationRes import * as models from '../models'; -/** - * @class - * PriceSheet - * __NOTE__: An instance of this class is automatically created for an - * instance of the ConsumptionManagementClient. - */ -export interface PriceSheet { - - - /** - * Gets the price sheet for a scope by subscriptionId. Price sheet is available - * via this API only for May 1, 2014 or later. - * - * @param {object} [options] Optional Parameters. - * - * @param {string} [options.expand] May be used to expand the - * properties/meterDetails within a price sheet. By default, these fields are - * not included when returning price sheet. - * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. - * - * @param {number} [options.top] May be used to limit the number of results to - * the top N results. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - getWithHttpOperationResponse(options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Gets the price sheet for a scope by subscriptionId. Price sheet is available - * via this API only for May 1, 2014 or later. - * - * @param {object} [options] Optional Parameters. - * - * @param {string} [options.expand] May be used to expand the - * properties/meterDetails within a price sheet. By default, these fields are - * not included when returning price sheet. - * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. - * - * @param {number} [options.top] May be used to limit the number of results to - * the top N results. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {PriceSheetResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {PriceSheetResult} [result] - The deserialized result object if an error did not occur. - * See {@link PriceSheetResult} for more information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - get(options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; - get(callback: ServiceCallback): void; - get(options: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * Get the price sheet for a scope by subscriptionId and billing period. Price - * sheet is available via this API only for May 1, 2014 or later. - * - * @param {string} billingPeriodName Billing Period Name. - * - * @param {object} [options] Optional Parameters. - * - * @param {string} [options.expand] May be used to expand the - * properties/meterDetails within a price sheet. By default, these fields are - * not included when returning price sheet. - * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. - * - * @param {number} [options.top] May be used to limit the number of results to - * the top N results. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - */ - getByBillingPeriodWithHttpOperationResponse(billingPeriodName: string, options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Get the price sheet for a scope by subscriptionId and billing period. Price - * sheet is available via this API only for May 1, 2014 or later. - * - * @param {string} billingPeriodName Billing Period Name. - * - * @param {object} [options] Optional Parameters. - * - * @param {string} [options.expand] May be used to expand the - * properties/meterDetails within a price sheet. By default, these fields are - * not included when returning price sheet. - * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. - * - * @param {number} [options.top] May be used to limit the number of results to - * the top N results. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {PriceSheetResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {PriceSheetResult} [result] - The deserialized result object if an error did not occur. - * See {@link PriceSheetResult} for more information. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - getByBillingPeriod(billingPeriodName: string, options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; - getByBillingPeriod(billingPeriodName: string, callback: ServiceCallback): void; - getByBillingPeriod(billingPeriodName: string, options: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; -} - /** * @class * UsageDetails @@ -1576,6 +1409,3122 @@ export interface UsageDetails { listForBillingPeriodByEnrollmentAccountNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } +/** + * @class + * Marketplaces + * __NOTE__: An instance of this class is automatically created for an + * instance of the ConsumptionManagementClient. + */ +export interface Marketplaces { + + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the marketplaces for a scope by billing period and subscripotionId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByBillingPeriodWithHttpOperationResponse(billingPeriodName: string, options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the marketplaces for a scope by billing period and subscripotionId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriod(billingPeriodName: string, options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + listByBillingPeriod(billingPeriodName: string, callback: ServiceCallback): void; + listByBillingPeriod(billingPeriodName: string, options: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByBillingAccountWithHttpOperationResponse(billingAccountId: string, options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingAccount(billingAccountId: string, options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + listByBillingAccount(billingAccountId: string, callback: ServiceCallback): void; + listByBillingAccount(billingAccountId: string, options: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listForBillingPeriodByBillingAccountWithHttpOperationResponse(billingAccountId: string, billingPeriodName: string, options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listForBillingPeriodByBillingAccount(billingAccountId: string, billingPeriodName: string, options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + listForBillingPeriodByBillingAccount(billingAccountId: string, billingPeriodName: string, callback: ServiceCallback): void; + listForBillingPeriodByBillingAccount(billingAccountId: string, billingPeriodName: string, options: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the marketplaces for a scope by departmentId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} departmentId Department ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByDepartmentWithHttpOperationResponse(departmentId: string, options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the marketplaces for a scope by departmentId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} departmentId Department ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByDepartment(departmentId: string, options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + listByDepartment(departmentId: string, callback: ServiceCallback): void; + listByDepartment(departmentId: string, options: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the marketplaces for a scope by billing period and departmentId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} departmentId Department ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listForBillingPeriodByDepartmentWithHttpOperationResponse(departmentId: string, billingPeriodName: string, options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the marketplaces for a scope by billing period and departmentId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} departmentId Department ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listForBillingPeriodByDepartment(departmentId: string, billingPeriodName: string, options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + listForBillingPeriodByDepartment(departmentId: string, billingPeriodName: string, callback: ServiceCallback): void; + listForBillingPeriodByDepartment(departmentId: string, billingPeriodName: string, options: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current + * billing period. Marketplaces are available via this API only for May 1, 2014 + * or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByEnrollmentAccountWithHttpOperationResponse(enrollmentAccountId: string, options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current + * billing period. Marketplaces are available via this API only for May 1, 2014 + * or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByEnrollmentAccount(enrollmentAccountId: string, options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + listByEnrollmentAccount(enrollmentAccountId: string, callback: ServiceCallback): void; + listByEnrollmentAccount(enrollmentAccountId: string, options: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the marketplaces for a scope by billing period and + * enrollmentAccountId. Marketplaces are available via this API only for May 1, + * 2014 or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listForBillingPeriodByEnrollmentAccountWithHttpOperationResponse(enrollmentAccountId: string, billingPeriodName: string, options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the marketplaces for a scope by billing period and + * enrollmentAccountId. Marketplaces are available via this API only for May 1, + * 2014 or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listForBillingPeriodByEnrollmentAccount(enrollmentAccountId: string, billingPeriodName: string, options?: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + listForBillingPeriodByEnrollmentAccount(enrollmentAccountId: string, billingPeriodName: string, callback: ServiceCallback): void; + listForBillingPeriodByEnrollmentAccount(enrollmentAccountId: string, billingPeriodName: string, options: { filter? : string, top? : number, skiptoken? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextPageLink: string, callback: ServiceCallback): void; + listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the marketplaces for a scope by billing period and subscripotionId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByBillingPeriodNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the marketplaces for a scope by billing period and subscripotionId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriodNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByBillingPeriodNext(nextPageLink: string, callback: ServiceCallback): void; + listByBillingPeriodNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByBillingAccountNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingAccountNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByBillingAccountNext(nextPageLink: string, callback: ServiceCallback): void; + listByBillingAccountNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listForBillingPeriodByBillingAccountNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listForBillingPeriodByBillingAccountNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listForBillingPeriodByBillingAccountNext(nextPageLink: string, callback: ServiceCallback): void; + listForBillingPeriodByBillingAccountNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the marketplaces for a scope by departmentId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByDepartmentNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the marketplaces for a scope by departmentId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByDepartmentNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByDepartmentNext(nextPageLink: string, callback: ServiceCallback): void; + listByDepartmentNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the marketplaces for a scope by billing period and departmentId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listForBillingPeriodByDepartmentNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the marketplaces for a scope by billing period and departmentId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listForBillingPeriodByDepartmentNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listForBillingPeriodByDepartmentNext(nextPageLink: string, callback: ServiceCallback): void; + listForBillingPeriodByDepartmentNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current + * billing period. Marketplaces are available via this API only for May 1, 2014 + * or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByEnrollmentAccountNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current + * billing period. Marketplaces are available via this API only for May 1, 2014 + * or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByEnrollmentAccountNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByEnrollmentAccountNext(nextPageLink: string, callback: ServiceCallback): void; + listByEnrollmentAccountNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the marketplaces for a scope by billing period and + * enrollmentAccountId. Marketplaces are available via this API only for May 1, + * 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listForBillingPeriodByEnrollmentAccountNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the marketplaces for a scope by billing period and + * enrollmentAccountId. Marketplaces are available via this API only for May 1, + * 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MarketplacesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listForBillingPeriodByEnrollmentAccountNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listForBillingPeriodByEnrollmentAccountNext(nextPageLink: string, callback: ServiceCallback): void; + listForBillingPeriodByEnrollmentAccountNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * Balances + * __NOTE__: An instance of this class is automatically created for an + * instance of the ConsumptionManagementClient. + */ +export interface Balances { + + + /** + * Gets the balances for a scope by billingAccountId. Balances are available + * via this API only for May 1, 2014 or later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getByBillingAccountWithHttpOperationResponse(billingAccountId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the balances for a scope by billingAccountId. Balances are available + * via this API only for May 1, 2014 or later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Balance} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Balance} [result] - The deserialized result object if an error did not occur. + * See {@link Balance} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + getByBillingAccount(billingAccountId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getByBillingAccount(billingAccountId: string, callback: ServiceCallback): void; + getByBillingAccount(billingAccountId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets the balances for a scope by billing period and billingAccountId. + * Balances are available via this API only for May 1, 2014 or later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getForBillingPeriodByBillingAccountWithHttpOperationResponse(billingAccountId: string, billingPeriodName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the balances for a scope by billing period and billingAccountId. + * Balances are available via this API only for May 1, 2014 or later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Balance} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Balance} [result] - The deserialized result object if an error did not occur. + * See {@link Balance} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + getForBillingPeriodByBillingAccount(billingAccountId: string, billingPeriodName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getForBillingPeriodByBillingAccount(billingAccountId: string, billingPeriodName: string, callback: ServiceCallback): void; + getForBillingPeriodByBillingAccount(billingAccountId: string, billingPeriodName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ReservationsSummaries + * __NOTE__: An instance of this class is automatically created for an + * instance of the ConsumptionManagementClient. + */ +export interface ReservationsSummaries { + + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} grain Can be daily or monthly. Possible values include: + * 'DailyGrain', 'MonthlyGrain' + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] Required only for daily grain. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByReservationOrderWithHttpOperationResponse(reservationOrderId: string, grain: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} grain Can be daily or monthly. Possible values include: + * 'DailyGrain', 'MonthlyGrain' + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] Required only for daily grain. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ReservationSummariesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ReservationSummariesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationSummariesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrder(reservationOrderId: string, grain: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + listByReservationOrder(reservationOrderId: string, grain: string, callback: ServiceCallback): void; + listByReservationOrder(reservationOrderId: string, grain: string, options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} reservationId Id of the reservation + * + * @param {string} grain Can be daily or monthly. Possible values include: + * 'DailyGrain', 'MonthlyGrain' + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] Required only for daily grain. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByReservationOrderAndReservationWithHttpOperationResponse(reservationOrderId: string, reservationId: string, grain: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} reservationId Id of the reservation + * + * @param {string} grain Can be daily or monthly. Possible values include: + * 'DailyGrain', 'MonthlyGrain' + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] Required only for daily grain. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ReservationSummariesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ReservationSummariesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationSummariesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrderAndReservation(reservationOrderId: string, reservationId: string, grain: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + listByReservationOrderAndReservation(reservationOrderId: string, reservationId: string, grain: string, callback: ServiceCallback): void; + listByReservationOrderAndReservation(reservationOrderId: string, reservationId: string, grain: string, options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByReservationOrderNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ReservationSummariesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ReservationSummariesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationSummariesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrderNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByReservationOrderNext(nextPageLink: string, callback: ServiceCallback): void; + listByReservationOrderNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByReservationOrderAndReservationNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the reservations summaries for daily or monthly grain. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ReservationSummariesListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ReservationSummariesListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationSummariesListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrderAndReservationNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByReservationOrderAndReservationNext(nextPageLink: string, callback: ServiceCallback): void; + listByReservationOrderAndReservationNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ReservationsDetails + * __NOTE__: An instance of this class is automatically created for an + * instance of the ConsumptionManagementClient. + */ +export interface ReservationsDetails { + + + /** + * Lists the reservations details for provided date range. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} filter Filter reservation details by date range. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByReservationOrderWithHttpOperationResponse(reservationOrderId: string, filter: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the reservations details for provided date range. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} filter Filter reservation details by date range. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ReservationDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ReservationDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrder(reservationOrderId: string, filter: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByReservationOrder(reservationOrderId: string, filter: string, callback: ServiceCallback): void; + listByReservationOrder(reservationOrderId: string, filter: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the reservations details for provided date range. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} reservationId Id of the reservation + * + * @param {string} filter Filter reservation details by date range. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByReservationOrderAndReservationWithHttpOperationResponse(reservationOrderId: string, reservationId: string, filter: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the reservations details for provided date range. + * + * @param {string} reservationOrderId Order Id of the reservation + * + * @param {string} reservationId Id of the reservation + * + * @param {string} filter Filter reservation details by date range. The + * properties/UsageDate for start date and end date. The filter supports 'le' + * and 'ge' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ReservationDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ReservationDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrderAndReservation(reservationOrderId: string, reservationId: string, filter: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByReservationOrderAndReservation(reservationOrderId: string, reservationId: string, filter: string, callback: ServiceCallback): void; + listByReservationOrderAndReservation(reservationOrderId: string, reservationId: string, filter: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the reservations details for provided date range. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByReservationOrderNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the reservations details for provided date range. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ReservationDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ReservationDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrderNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByReservationOrderNext(nextPageLink: string, callback: ServiceCallback): void; + listByReservationOrderNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the reservations details for provided date range. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByReservationOrderAndReservationNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the reservations details for provided date range. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ReservationDetailsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ReservationDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationDetailsListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByReservationOrderAndReservationNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByReservationOrderAndReservationNext(nextPageLink: string, callback: ServiceCallback): void; + listByReservationOrderAndReservationNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ReservationRecommendations + * __NOTE__: An instance of this class is automatically created for an + * instance of the ConsumptionManagementClient. + */ +export interface ReservationRecommendations { + + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter + * reservationRecommendations by properties/scope and + * properties/lookBackPeriod. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter + * reservationRecommendations by properties/scope and + * properties/lookBackPeriod. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ReservationRecommendationsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ReservationRecommendationsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationRecommendationsListResult} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ReservationRecommendationsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ReservationRecommendationsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationRecommendationsListResult} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextPageLink: string, callback: ServiceCallback): void; + listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * Budgets + * __NOTE__: An instance of this class is automatically created for an + * instance of the ConsumptionManagementClient. + */ +export interface Budgets { + + + /** + * Lists all budgets for a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all budgets for a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {BudgetsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {BudgetsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BudgetsListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all budgets for a resource group under a subscription. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByResourceGroupNameWithHttpOperationResponse(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all budgets for a resource group under a subscription. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {BudgetsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {BudgetsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BudgetsListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByResourceGroupName(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByResourceGroupName(resourceGroupName: string, callback: ServiceCallback): void; + listByResourceGroupName(resourceGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets the budget for a subscription by budget name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the budget for a subscription by budget name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Budget} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Budget} [result] - The deserialized result object if an error did not occur. + * See {@link Budget} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(budgetName: string, callback: ServiceCallback): void; + get(budgetName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to create or update a budget. Update operation requires latest + * eTag to be set in the request mandatorily. You may obtain the latest eTag by + * performing a get operation. Create operation does not require eTag. + * + * @param {string} budgetName Budget Name. + * + * @param {object} parameters Parameters supplied to the Create Budget + * operation. + * + * @param {string} parameters.category The category of the budget, whether the + * budget tracks cost or usage. Possible values include: 'Cost', 'Usage' + * + * @param {number} parameters.amount The total amount of cost to track with the + * budget + * + * @param {string} parameters.timeGrain The time covered by a budget. Tracking + * of the amount will be reset based on the time grain. Possible values + * include: 'Monthly', 'Quarterly', 'Annually' + * + * @param {object} parameters.timePeriod Has start and end date of the budget. + * The start date must be first of the month and should be less than the end + * date. Budget start date must be on or after June 1, 2017. Future start date + * should not be more than three months. Past start date should be selected + * within the timegrain preiod. There are no restrictions on the end date. + * + * @param {date} parameters.timePeriod.startDate The start date for the budget. + * + * @param {date} [parameters.timePeriod.endDate] The end date for the budget. + * If not provided, we default this to 10 years from the start date. + * + * @param {object} [parameters.filters] May be used to filter budgets by + * resource group, resource, or meter. + * + * @param {array} [parameters.filters.resourceGroups] The list of filters on + * resource groups, allowed at subscription level only. + * + * @param {array} [parameters.filters.resources] The list of filters on + * resources. + * + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. + * + * @param {object} [parameters.notifications] Dictionary of notifications + * associated with the budget. Budget can have up to five notifications. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createOrUpdateWithHttpOperationResponse(budgetName: string, parameters: models.Budget, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to create or update a budget. Update operation requires latest + * eTag to be set in the request mandatorily. You may obtain the latest eTag by + * performing a get operation. Create operation does not require eTag. + * + * @param {string} budgetName Budget Name. + * + * @param {object} parameters Parameters supplied to the Create Budget + * operation. + * + * @param {string} parameters.category The category of the budget, whether the + * budget tracks cost or usage. Possible values include: 'Cost', 'Usage' + * + * @param {number} parameters.amount The total amount of cost to track with the + * budget + * + * @param {string} parameters.timeGrain The time covered by a budget. Tracking + * of the amount will be reset based on the time grain. Possible values + * include: 'Monthly', 'Quarterly', 'Annually' + * + * @param {object} parameters.timePeriod Has start and end date of the budget. + * The start date must be first of the month and should be less than the end + * date. Budget start date must be on or after June 1, 2017. Future start date + * should not be more than three months. Past start date should be selected + * within the timegrain preiod. There are no restrictions on the end date. + * + * @param {date} parameters.timePeriod.startDate The start date for the budget. + * + * @param {date} [parameters.timePeriod.endDate] The end date for the budget. + * If not provided, we default this to 10 years from the start date. + * + * @param {object} [parameters.filters] May be used to filter budgets by + * resource group, resource, or meter. + * + * @param {array} [parameters.filters.resourceGroups] The list of filters on + * resource groups, allowed at subscription level only. + * + * @param {array} [parameters.filters.resources] The list of filters on + * resources. + * + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. + * + * @param {object} [parameters.notifications] Dictionary of notifications + * associated with the budget. Budget can have up to five notifications. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Budget} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Budget} [result] - The deserialized result object if an error did not occur. + * See {@link Budget} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(budgetName: string, parameters: models.Budget, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(budgetName: string, parameters: models.Budget, callback: ServiceCallback): void; + createOrUpdate(budgetName: string, parameters: models.Budget, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to delete a budget. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to delete a budget. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(budgetName: string, callback: ServiceCallback): void; + deleteMethod(budgetName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets the budget for a resource group under a subscription by budget name. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getByResourceGroupNameWithHttpOperationResponse(resourceGroupName: string, budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the budget for a resource group under a subscription by budget name. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Budget} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Budget} [result] - The deserialized result object if an error did not occur. + * See {@link Budget} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + getByResourceGroupName(resourceGroupName: string, budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getByResourceGroupName(resourceGroupName: string, budgetName: string, callback: ServiceCallback): void; + getByResourceGroupName(resourceGroupName: string, budgetName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to create or update a budget. Update operation requires latest + * eTag to be set in the request mandatorily. You may obtain the latest eTag by + * performing a get operation. Create operation does not require eTag. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} parameters Parameters supplied to the Create Budget + * operation. + * + * @param {string} parameters.category The category of the budget, whether the + * budget tracks cost or usage. Possible values include: 'Cost', 'Usage' + * + * @param {number} parameters.amount The total amount of cost to track with the + * budget + * + * @param {string} parameters.timeGrain The time covered by a budget. Tracking + * of the amount will be reset based on the time grain. Possible values + * include: 'Monthly', 'Quarterly', 'Annually' + * + * @param {object} parameters.timePeriod Has start and end date of the budget. + * The start date must be first of the month and should be less than the end + * date. Budget start date must be on or after June 1, 2017. Future start date + * should not be more than three months. Past start date should be selected + * within the timegrain preiod. There are no restrictions on the end date. + * + * @param {date} parameters.timePeriod.startDate The start date for the budget. + * + * @param {date} [parameters.timePeriod.endDate] The end date for the budget. + * If not provided, we default this to 10 years from the start date. + * + * @param {object} [parameters.filters] May be used to filter budgets by + * resource group, resource, or meter. + * + * @param {array} [parameters.filters.resourceGroups] The list of filters on + * resource groups, allowed at subscription level only. + * + * @param {array} [parameters.filters.resources] The list of filters on + * resources. + * + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. + * + * @param {object} [parameters.notifications] Dictionary of notifications + * associated with the budget. Budget can have up to five notifications. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createOrUpdateByResourceGroupNameWithHttpOperationResponse(resourceGroupName: string, budgetName: string, parameters: models.Budget, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to create or update a budget. Update operation requires latest + * eTag to be set in the request mandatorily. You may obtain the latest eTag by + * performing a get operation. Create operation does not require eTag. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} parameters Parameters supplied to the Create Budget + * operation. + * + * @param {string} parameters.category The category of the budget, whether the + * budget tracks cost or usage. Possible values include: 'Cost', 'Usage' + * + * @param {number} parameters.amount The total amount of cost to track with the + * budget + * + * @param {string} parameters.timeGrain The time covered by a budget. Tracking + * of the amount will be reset based on the time grain. Possible values + * include: 'Monthly', 'Quarterly', 'Annually' + * + * @param {object} parameters.timePeriod Has start and end date of the budget. + * The start date must be first of the month and should be less than the end + * date. Budget start date must be on or after June 1, 2017. Future start date + * should not be more than three months. Past start date should be selected + * within the timegrain preiod. There are no restrictions on the end date. + * + * @param {date} parameters.timePeriod.startDate The start date for the budget. + * + * @param {date} [parameters.timePeriod.endDate] The end date for the budget. + * If not provided, we default this to 10 years from the start date. + * + * @param {object} [parameters.filters] May be used to filter budgets by + * resource group, resource, or meter. + * + * @param {array} [parameters.filters.resourceGroups] The list of filters on + * resource groups, allowed at subscription level only. + * + * @param {array} [parameters.filters.resources] The list of filters on + * resources. + * + * @param {array} [parameters.filters.meters] The list of filters on meters + * (GUID), mandatory for budgets of usage category. + * + * @param {object} [parameters.filters.tags] The dictionary of filters on tags. + * + * @param {object} [parameters.notifications] Dictionary of notifications + * associated with the budget. Budget can have up to five notifications. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Budget} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Budget} [result] - The deserialized result object if an error did not occur. + * See {@link Budget} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdateByResourceGroupName(resourceGroupName: string, budgetName: string, parameters: models.Budget, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdateByResourceGroupName(resourceGroupName: string, budgetName: string, parameters: models.Budget, callback: ServiceCallback): void; + createOrUpdateByResourceGroupName(resourceGroupName: string, budgetName: string, parameters: models.Budget, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to delete a budget. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteByResourceGroupNameWithHttpOperationResponse(resourceGroupName: string, budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to delete a budget. + * + * @param {string} resourceGroupName Azure Resource Group Name. + * + * @param {string} budgetName Budget Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteByResourceGroupName(resourceGroupName: string, budgetName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteByResourceGroupName(resourceGroupName: string, budgetName: string, callback: ServiceCallback): void; + deleteByResourceGroupName(resourceGroupName: string, budgetName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all budgets for a subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all budgets for a subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {BudgetsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {BudgetsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BudgetsListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextPageLink: string, callback: ServiceCallback): void; + listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all budgets for a resource group under a subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByResourceGroupNameNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all budgets for a resource group under a subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {BudgetsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {BudgetsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BudgetsListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByResourceGroupNameNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByResourceGroupNameNext(nextPageLink: string, callback: ServiceCallback): void; + listByResourceGroupNameNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * PriceSheet + * __NOTE__: An instance of this class is automatically created for an + * instance of the ConsumptionManagementClient. + */ +export interface PriceSheet { + + + /** + * Gets the price sheet for a scope by subscriptionId. Price sheet is available + * via this API only for May 1, 2014 or later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/meterDetails within a price sheet. By default, these fields are + * not included when returning price sheet. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the price sheet for a scope by subscriptionId. Price sheet is available + * via this API only for May 1, 2014 or later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/meterDetails within a price sheet. By default, these fields are + * not included when returning price sheet. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {PriceSheetResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {PriceSheetResult} [result] - The deserialized result object if an error did not occur. + * See {@link PriceSheetResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; + get(callback: ServiceCallback): void; + get(options: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get the price sheet for a scope by subscriptionId and billing period. Price + * sheet is available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/meterDetails within a price sheet. By default, these fields are + * not included when returning price sheet. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getByBillingPeriodWithHttpOperationResponse(billingPeriodName: string, options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the price sheet for a scope by subscriptionId and billing period. Price + * sheet is available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * properties/meterDetails within a price sheet. By default, these fields are + * not included when returning price sheet. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {number} [options.top] May be used to limit the number of results to + * the top N results. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {PriceSheetResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {PriceSheetResult} [result] - The deserialized result object if an error did not occur. + * See {@link PriceSheetResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + getByBillingPeriod(billingPeriodName: string, options?: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; + getByBillingPeriod(billingPeriodName: string, callback: ServiceCallback): void; + getByBillingPeriod(billingPeriodName: string, options: { expand? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * CostTags + * __NOTE__: An instance of this class is automatically created for an + * instance of the ConsumptionManagementClient. + */ +export interface CostTags { + + + /** + * Get cost tags for a billing account. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(billingAccountId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get cost tags for a billing account. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {CostTag} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {CostTag} [result] - The deserialized result object if an error did not occur. + * See {@link CostTag} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(billingAccountId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountId: string, callback: ServiceCallback): void; + get(billingAccountId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to create or update cost tags assiciated with a billing + * account. Update operation requires latest eTag to be set in the request + * mandatorily. You may obtain the latest eTag by performing a get operation. + * Create operation does not require eTag. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} parameters Parameters supplied to the Create cost tags + * operation. + * + * @param {array} [parameters.costTags] Cost tags. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createOrUpdateWithHttpOperationResponse(billingAccountId: string, parameters: models.CostTag, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to create or update cost tags assiciated with a billing + * account. Update operation requires latest eTag to be set in the request + * mandatorily. You may obtain the latest eTag by performing a get operation. + * Create operation does not require eTag. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} parameters Parameters supplied to the Create cost tags + * operation. + * + * @param {array} [parameters.costTags] Cost tags. + * + * @param {string} [parameters.eTag] eTag of the resource. To handle concurrent + * update scenarion, this field will be used to determine whether the user is + * updating the latest version or not. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {CostTag} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {CostTag} [result] - The deserialized result object if an error did not occur. + * See {@link CostTag} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(billingAccountId: string, parameters: models.CostTag, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(billingAccountId: string, parameters: models.CostTag, callback: ServiceCallback): void; + createOrUpdate(billingAccountId: string, parameters: models.CostTag, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * Tags + * __NOTE__: An instance of this class is automatically created for an + * instance of the ConsumptionManagementClient. + */ +export interface Tags { + + + /** + * Get all available tag keys for a billing account. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(billingAccountId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get all available tag keys for a billing account. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {TagsResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {TagsResult} [result] - The deserialized result object if an error did not occur. + * See {@link TagsResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(billingAccountId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountId: string, callback: ServiceCallback): void; + get(billingAccountId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + /** * @class * Forecasts diff --git a/lib/services/consumptionManagement/lib/operations/index.js b/lib/services/consumptionManagement/lib/operations/index.js index 483623b162..092ae808a1 100644 --- a/lib/services/consumptionManagement/lib/operations/index.js +++ b/lib/services/consumptionManagement/lib/operations/index.js @@ -14,7 +14,15 @@ 'use strict'; -exports.PriceSheet = require('./priceSheet'); exports.UsageDetails = require('./usageDetails'); +exports.Marketplaces = require('./marketplaces'); +exports.Balances = require('./balances'); +exports.ReservationsSummaries = require('./reservationsSummaries'); +exports.ReservationsDetails = require('./reservationsDetails'); +exports.ReservationRecommendations = require('./reservationRecommendations'); +exports.Budgets = require('./budgets'); +exports.PriceSheet = require('./priceSheet'); +exports.CostTags = require('./costTags'); +exports.Tags = require('./tags'); exports.Forecasts = require('./forecasts'); exports.Operations = require('./operations'); diff --git a/lib/services/consumptionManagement/lib/operations/marketplaces.js b/lib/services/consumptionManagement/lib/operations/marketplaces.js index f0ef834b31..d5716af463 100644 --- a/lib/services/consumptionManagement/lib/operations/marketplaces.js +++ b/lib/services/consumptionManagement/lib/operations/marketplaces.js @@ -384,15 +384,28 @@ function _listByBillingPeriod(billingPeriodName, options, callback) { } /** - * Lists the marketplaces for a scope by subscriptionId and current billing + * Lists the marketplaces for a scope by billingAccountId and current billing * period. Marketplaces are available via this API only for May 1, 2014 or * later. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} billingAccountId BillingAccount ID * * @param {object} [options] Optional Parameters. * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -410,7 +423,7 @@ function _listByBillingPeriod(billingPeriodName, options, callback) { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _listNext(nextPageLink, options, callback) { +function _listByBillingAccount(billingAccountId, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -420,10 +433,35 @@ function _listNext(nextPageLink, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; // Validate try { - if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { - throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); @@ -433,8 +471,23 @@ function _listNext(nextPageLink, options, callback) { } // Construct URL - let requestUrl = '{nextLink}'; - requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/marketplaces'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } // Create HTTP transport objects let httpRequest = new WebResource(); @@ -515,14 +568,29 @@ function _listNext(nextPageLink, options, callback) { } /** - * Lists the marketplaces for a scope by billing period and subscripotionId. + * Lists the marketplaces for a scope by billing period and billingAccountId. * Marketplaces are available via this API only for May 1, 2014 or later. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. * * @param {object} [options] Optional Parameters. * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -540,7 +608,7 @@ function _listNext(nextPageLink, options, callback) { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _listByBillingPeriodNext(nextPageLink, options, callback) { +function _listForBillingPeriodByBillingAccount(billingAccountId, billingPeriodName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -550,10 +618,38 @@ function _listByBillingPeriodNext(nextPageLink, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; // Validate try { - if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { - throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (billingPeriodName === null || billingPeriodName === undefined || typeof billingPeriodName.valueOf() !== 'string') { + throw new Error('billingPeriodName cannot be null or undefined and it must be of type string.'); } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); @@ -563,8 +659,24 @@ function _listByBillingPeriodNext(nextPageLink, options, callback) { } // Construct URL - let requestUrl = '{nextLink}'; - requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/marketplaces'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{billingPeriodName}', encodeURIComponent(billingPeriodName)); + let queryParameters = []; + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } // Create HTTP transport objects let httpRequest = new WebResource(); @@ -644,40 +756,3019 @@ function _listByBillingPeriodNext(nextPageLink, options, callback) { }); } -/** Class representing a Marketplaces. */ -class Marketplaces { +/** + * Lists the marketplaces for a scope by departmentId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} departmentId Department ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByDepartment(departmentId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + // Validate + try { + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (departmentId === null || departmentId === undefined || typeof departmentId.valueOf() !== 'string') { + throw new Error('departmentId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Consumption/marketplaces'; + requestUrl = requestUrl.replace('{departmentId}', encodeURIComponent(departmentId)); + let queryParameters = []; + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the marketplaces for a scope by billing period and departmentId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} departmentId Department ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listForBillingPeriodByDepartment(departmentId, billingPeriodName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + // Validate + try { + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (departmentId === null || departmentId === undefined || typeof departmentId.valueOf() !== 'string') { + throw new Error('departmentId cannot be null or undefined and it must be of type string.'); + } + if (billingPeriodName === null || billingPeriodName === undefined || typeof billingPeriodName.valueOf() !== 'string') { + throw new Error('billingPeriodName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/marketplaces'; + requestUrl = requestUrl.replace('{departmentId}', encodeURIComponent(departmentId)); + requestUrl = requestUrl.replace('{billingPeriodName}', encodeURIComponent(billingPeriodName)); + let queryParameters = []; + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the marketplaces for a scope by enrollmentAccountId and current + * billing period. Marketplaces are available via this API only for May 1, 2014 + * or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByEnrollmentAccount(enrollmentAccountId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + // Validate + try { + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (enrollmentAccountId === null || enrollmentAccountId === undefined || typeof enrollmentAccountId.valueOf() !== 'string') { + throw new Error('enrollmentAccountId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}/providers/Microsoft.Consumption/marketplaces'; + requestUrl = requestUrl.replace('{enrollmentAccountId}', encodeURIComponent(enrollmentAccountId)); + let queryParameters = []; + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the marketplaces for a scope by billing period and + * enrollmentAccountId. Marketplaces are available via this API only for May 1, + * 2014 or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listForBillingPeriodByEnrollmentAccount(enrollmentAccountId, billingPeriodName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + let skiptoken = (options && options.skiptoken !== undefined) ? options.skiptoken : undefined; + // Validate + try { + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + if (skiptoken !== null && skiptoken !== undefined && typeof skiptoken.valueOf() !== 'string') { + throw new Error('skiptoken must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (enrollmentAccountId === null || enrollmentAccountId === undefined || typeof enrollmentAccountId.valueOf() !== 'string') { + throw new Error('enrollmentAccountId cannot be null or undefined and it must be of type string.'); + } + if (billingPeriodName === null || billingPeriodName === undefined || typeof billingPeriodName.valueOf() !== 'string') { + throw new Error('billingPeriodName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/marketplaces'; + requestUrl = requestUrl.replace('{enrollmentAccountId}', encodeURIComponent(enrollmentAccountId)); + requestUrl = requestUrl.replace('{billingPeriodName}', encodeURIComponent(billingPeriodName)); + let queryParameters = []; + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + if (skiptoken !== null && skiptoken !== undefined) { + queryParameters.push('$skiptoken=' + encodeURIComponent(skiptoken)); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the marketplaces for a scope by subscriptionId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the marketplaces for a scope by billing period and subscripotionId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByBillingPeriodNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the marketplaces for a scope by billingAccountId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByBillingAccountNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the marketplaces for a scope by billing period and billingAccountId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listForBillingPeriodByBillingAccountNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the marketplaces for a scope by departmentId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByDepartmentNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the marketplaces for a scope by billing period and departmentId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listForBillingPeriodByDepartmentNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the marketplaces for a scope by enrollmentAccountId and current + * billing period. Marketplaces are available via this API only for May 1, 2014 + * or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByEnrollmentAccountNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the marketplaces for a scope by billing period and + * enrollmentAccountId. Marketplaces are available via this API only for May 1, + * 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listForBillingPeriodByEnrollmentAccountNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MarketplacesListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a Marketplaces. */ +class Marketplaces { + /** + * Create a Marketplaces. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listByBillingPeriod = _listByBillingPeriod; + this._listByBillingAccount = _listByBillingAccount; + this._listForBillingPeriodByBillingAccount = _listForBillingPeriodByBillingAccount; + this._listByDepartment = _listByDepartment; + this._listForBillingPeriodByDepartment = _listForBillingPeriodByDepartment; + this._listByEnrollmentAccount = _listByEnrollmentAccount; + this._listForBillingPeriodByEnrollmentAccount = _listForBillingPeriodByEnrollmentAccount; + this._listNext = _listNext; + this._listByBillingPeriodNext = _listByBillingPeriodNext; + this._listByBillingAccountNext = _listByBillingAccountNext; + this._listForBillingPeriodByBillingAccountNext = _listForBillingPeriodByBillingAccountNext; + this._listByDepartmentNext = _listByDepartmentNext; + this._listForBillingPeriodByDepartmentNext = _listForBillingPeriodByDepartmentNext; + this._listByEnrollmentAccountNext = _listByEnrollmentAccountNext; + this._listForBillingPeriodByEnrollmentAccountNext = _listForBillingPeriodByEnrollmentAccountNext; + } + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(options, optionalCallback); + } + } + + /** + * Lists the marketplaces for a scope by billing period and subscripotionId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByBillingPeriodWithHttpOperationResponse(billingPeriodName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingPeriod(billingPeriodName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by billing period and subscripotionId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriod(billingPeriodName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingPeriod(billingPeriodName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingPeriod(billingPeriodName, options, optionalCallback); + } + } + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByBillingAccountWithHttpOperationResponse(billingAccountId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingAccount(billingAccountId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by billingAccountId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingAccount(billingAccountId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingAccount(billingAccountId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingAccount(billingAccountId, options, optionalCallback); + } + } + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listForBillingPeriodByBillingAccountWithHttpOperationResponse(billingAccountId, billingPeriodName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listForBillingPeriodByBillingAccount(billingAccountId, billingPeriodName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listForBillingPeriodByBillingAccount(billingAccountId, billingPeriodName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listForBillingPeriodByBillingAccount(billingAccountId, billingPeriodName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listForBillingPeriodByBillingAccount(billingAccountId, billingPeriodName, options, optionalCallback); + } + } + + /** + * Lists the marketplaces for a scope by departmentId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} departmentId Department ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByDepartmentWithHttpOperationResponse(departmentId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByDepartment(departmentId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by departmentId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} departmentId Department ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByDepartment(departmentId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByDepartment(departmentId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByDepartment(departmentId, options, optionalCallback); + } + } + + /** + * Lists the marketplaces for a scope by billing period and departmentId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} departmentId Department ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listForBillingPeriodByDepartmentWithHttpOperationResponse(departmentId, billingPeriodName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listForBillingPeriodByDepartment(departmentId, billingPeriodName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by billing period and departmentId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} departmentId Department ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listForBillingPeriodByDepartment(departmentId, billingPeriodName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listForBillingPeriodByDepartment(departmentId, billingPeriodName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listForBillingPeriodByDepartment(departmentId, billingPeriodName, options, optionalCallback); + } + } + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current + * billing period. Marketplaces are available via this API only for May 1, 2014 + * or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByEnrollmentAccountWithHttpOperationResponse(enrollmentAccountId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByEnrollmentAccount(enrollmentAccountId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by enrollmentAccountId and current + * billing period. Marketplaces are available via this API only for May 1, 2014 + * or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByEnrollmentAccount(enrollmentAccountId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByEnrollmentAccount(enrollmentAccountId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByEnrollmentAccount(enrollmentAccountId, options, optionalCallback); + } + } + + /** + * Lists the marketplaces for a scope by billing period and + * enrollmentAccountId. Marketplaces are available via this API only for May 1, + * 2014 or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listForBillingPeriodByEnrollmentAccountWithHttpOperationResponse(enrollmentAccountId, billingPeriodName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listForBillingPeriodByEnrollmentAccount(enrollmentAccountId, billingPeriodName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by billing period and + * enrollmentAccountId. Marketplaces are available via this API only for May 1, + * 2014 or later. + * + * @param {string} enrollmentAccountId EnrollmentAccount ID + * + * @param {string} billingPeriodName Billing Period Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter marketplaces by + * properties/usageEnd (Utc time), properties/usageStart (Utc time), + * properties/resourceGroup, properties/instanceName or properties/instanceId. + * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + * currently support 'ne', 'or', or 'not'. + * + * @param {number} [options.top] May be used to limit the number of results to + * the most recent N marketplaces. + * + * @param {string} [options.skiptoken] Skiptoken is only used if a previous + * operation returned a partial result. If a previous response contains a + * nextLink element, the value of the nextLink element will include a skiptoken + * parameter that specifies a starting point to use for subsequent calls. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listForBillingPeriodByEnrollmentAccount(enrollmentAccountId, billingPeriodName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listForBillingPeriodByEnrollmentAccount(enrollmentAccountId, billingPeriodName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listForBillingPeriodByEnrollmentAccount(enrollmentAccountId, billingPeriodName, options, optionalCallback); + } + } + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by subscriptionId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Lists the marketplaces for a scope by billing period and subscripotionId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByBillingPeriodNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by billing period and subscripotionId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingPeriodNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingPeriodNext(nextPageLink, options, optionalCallback); + } + } + /** - * Create a Marketplaces. - * @param {ConsumptionManagementClient} client Reference to the service client. + * Lists the marketplaces for a scope by billingAccountId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. */ - constructor(client) { - this.client = client; - this._list = _list; - this._listByBillingPeriod = _listByBillingPeriod; - this._listNext = _listNext; - this._listByBillingPeriodNext = _listByBillingPeriodNext; + listByBillingAccountNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByBillingAccountNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); } /** - * Lists the marketplaces for a scope by subscriptionId and current billing + * Lists the marketplaces for a scope by billingAccountId and current billing * period. Marketplaces are available via this API only for May 1, 2014 or * later. * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * * @param {object} [options] Optional Parameters. * - * @param {string} [options.filter] May be used to filter marketplaces by - * properties/usageEnd (Utc time), properties/usageStart (Utc time), - * properties/resourceGroup, properties/instanceName or properties/instanceId. - * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not - * currently support 'ne', 'or', or 'not'. + * @param {object} [options.customHeaders] Headers that will be added to the + * request * - * @param {number} [options.top] May be used to limit the number of results to - * the most recent N marketplaces. + * @param {function} [optionalCallback] - The optional callback. * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByBillingAccountNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByBillingAccountNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByBillingAccountNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Lists the marketplaces for a scope by billing period and billingAccountId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -688,11 +3779,11 @@ class Marketplaces { * * @reject {Error} - The error object. */ - listWithHttpOperationResponse(options) { + listForBillingPeriodByBillingAccountNextWithHttpOperationResponse(nextPageLink, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._list(options, (err, result, request, response) => { + self._listForBillingPeriodByBillingAccountNext(nextPageLink, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -703,25 +3794,102 @@ class Marketplaces { } /** - * Lists the marketplaces for a scope by subscriptionId and current billing + * Lists the marketplaces for a scope by billing period and billingAccountId. + * Marketplaces are available via this API only for May 1, 2014 or later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MarketplacesListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MarketplacesListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listForBillingPeriodByBillingAccountNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listForBillingPeriodByBillingAccountNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listForBillingPeriodByBillingAccountNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Lists the marketplaces for a scope by departmentId and current billing * period. Marketplaces are available via this API only for May 1, 2014 or * later. * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * * @param {object} [options] Optional Parameters. * - * @param {string} [options.filter] May be used to filter marketplaces by - * properties/usageEnd (Utc time), properties/usageStart (Utc time), - * properties/resourceGroup, properties/instanceName or properties/instanceId. - * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not - * currently support 'ne', 'or', or 'not'. + * @param {object} [options.customHeaders] Headers that will be added to the + * request * - * @param {number} [options.top] May be used to limit the number of results to - * the most recent N marketplaces. + * @returns {Promise} A promise is returned * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByDepartmentNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByDepartmentNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the marketplaces for a scope by departmentId and current billing + * period. Marketplaces are available via this API only for May 1, 2014 or + * later. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -749,7 +3917,7 @@ class Marketplaces { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - list(options, optionalCallback) { + listByDepartmentNext(nextPageLink, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -758,39 +3926,26 @@ class Marketplaces { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._list(options, (err, result, request, response) => { + self._listByDepartmentNext(nextPageLink, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._list(options, optionalCallback); + return self._listByDepartmentNext(nextPageLink, options, optionalCallback); } } /** - * Lists the marketplaces for a scope by billing period and subscripotionId. + * Lists the marketplaces for a scope by billing period and departmentId. * Marketplaces are available via this API only for May 1, 2014 or later. * - * @param {string} billingPeriodName Billing Period Name. + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. * * @param {object} [options] Optional Parameters. * - * @param {string} [options.filter] May be used to filter marketplaces by - * properties/usageEnd (Utc time), properties/usageStart (Utc time), - * properties/resourceGroup, properties/instanceName or properties/instanceId. - * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not - * currently support 'ne', 'or', or 'not'. - * - * @param {number} [options.top] May be used to limit the number of results to - * the most recent N marketplaces. - * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. - * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -800,11 +3955,11 @@ class Marketplaces { * * @reject {Error} - The error object. */ - listByBillingPeriodWithHttpOperationResponse(billingPeriodName, options) { + listForBillingPeriodByDepartmentNextWithHttpOperationResponse(nextPageLink, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._listByBillingPeriod(billingPeriodName, options, (err, result, request, response) => { + self._listForBillingPeriodByDepartmentNext(nextPageLink, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -815,27 +3970,14 @@ class Marketplaces { } /** - * Lists the marketplaces for a scope by billing period and subscripotionId. + * Lists the marketplaces for a scope by billing period and departmentId. * Marketplaces are available via this API only for May 1, 2014 or later. * - * @param {string} billingPeriodName Billing Period Name. + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. * * @param {object} [options] Optional Parameters. * - * @param {string} [options.filter] May be used to filter marketplaces by - * properties/usageEnd (Utc time), properties/usageStart (Utc time), - * properties/resourceGroup, properties/instanceName or properties/instanceId. - * The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not - * currently support 'ne', 'or', or 'not'. - * - * @param {number} [options.top] May be used to limit the number of results to - * the most recent N marketplaces. - * - * @param {string} [options.skiptoken] Skiptoken is only used if a previous - * operation returned a partial result. If a previous response contains a - * nextLink element, the value of the nextLink element will include a skiptoken - * parameter that specifies a starting point to use for subsequent calls. - * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -862,7 +4004,7 @@ class Marketplaces { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - listByBillingPeriod(billingPeriodName, options, optionalCallback) { + listForBillingPeriodByDepartmentNext(nextPageLink, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -871,21 +4013,21 @@ class Marketplaces { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._listByBillingPeriod(billingPeriodName, options, (err, result, request, response) => { + self._listForBillingPeriodByDepartmentNext(nextPageLink, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._listByBillingPeriod(billingPeriodName, options, optionalCallback); + return self._listForBillingPeriodByDepartmentNext(nextPageLink, options, optionalCallback); } } /** - * Lists the marketplaces for a scope by subscriptionId and current billing - * period. Marketplaces are available via this API only for May 1, 2014 or - * later. + * Lists the marketplaces for a scope by enrollmentAccountId and current + * billing period. Marketplaces are available via this API only for May 1, 2014 + * or later. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -901,11 +4043,11 @@ class Marketplaces { * * @reject {Error} - The error object. */ - listNextWithHttpOperationResponse(nextPageLink, options) { + listByEnrollmentAccountNextWithHttpOperationResponse(nextPageLink, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._listNext(nextPageLink, options, (err, result, request, response) => { + self._listByEnrollmentAccountNext(nextPageLink, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -916,9 +4058,9 @@ class Marketplaces { } /** - * Lists the marketplaces for a scope by subscriptionId and current billing - * period. Marketplaces are available via this API only for May 1, 2014 or - * later. + * Lists the marketplaces for a scope by enrollmentAccountId and current + * billing period. Marketplaces are available via this API only for May 1, 2014 + * or later. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -951,7 +4093,7 @@ class Marketplaces { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - listNext(nextPageLink, options, optionalCallback) { + listByEnrollmentAccountNext(nextPageLink, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -960,20 +4102,21 @@ class Marketplaces { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._listNext(nextPageLink, options, (err, result, request, response) => { + self._listByEnrollmentAccountNext(nextPageLink, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._listNext(nextPageLink, options, optionalCallback); + return self._listByEnrollmentAccountNext(nextPageLink, options, optionalCallback); } } /** - * Lists the marketplaces for a scope by billing period and subscripotionId. - * Marketplaces are available via this API only for May 1, 2014 or later. + * Lists the marketplaces for a scope by billing period and + * enrollmentAccountId. Marketplaces are available via this API only for May 1, + * 2014 or later. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -989,11 +4132,11 @@ class Marketplaces { * * @reject {Error} - The error object. */ - listByBillingPeriodNextWithHttpOperationResponse(nextPageLink, options) { + listForBillingPeriodByEnrollmentAccountNextWithHttpOperationResponse(nextPageLink, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + self._listForBillingPeriodByEnrollmentAccountNext(nextPageLink, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -1004,8 +4147,9 @@ class Marketplaces { } /** - * Lists the marketplaces for a scope by billing period and subscripotionId. - * Marketplaces are available via this API only for May 1, 2014 or later. + * Lists the marketplaces for a scope by billing period and + * enrollmentAccountId. Marketplaces are available via this API only for May 1, + * 2014 or later. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -1038,7 +4182,7 @@ class Marketplaces { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - listByBillingPeriodNext(nextPageLink, options, optionalCallback) { + listForBillingPeriodByEnrollmentAccountNext(nextPageLink, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -1047,14 +4191,14 @@ class Marketplaces { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._listByBillingPeriodNext(nextPageLink, options, (err, result, request, response) => { + self._listForBillingPeriodByEnrollmentAccountNext(nextPageLink, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._listByBillingPeriodNext(nextPageLink, options, optionalCallback); + return self._listForBillingPeriodByEnrollmentAccountNext(nextPageLink, options, optionalCallback); } } diff --git a/lib/services/consumptionManagement/lib/operations/reservationRecommendations.js b/lib/services/consumptionManagement/lib/operations/reservationRecommendations.js new file mode 100644 index 0000000000..89a5db3632 --- /dev/null +++ b/lib/services/consumptionManagement/lib/operations/reservationRecommendations.js @@ -0,0 +1,478 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * List of recomendations for purchasing reserved instances. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter + * reservationRecommendations by properties/scope and + * properties/lookBackPeriod. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationRecommendationsListResult} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + // Validate + try { + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Consumption/reservationRecommendations'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ReservationRecommendationsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * List of recomendations for purchasing reserved instances. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationRecommendationsListResult} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ReservationRecommendationsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a ReservationRecommendations. */ +class ReservationRecommendations { + /** + * Create a ReservationRecommendations. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listNext = _listNext; + } + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter + * reservationRecommendations by properties/scope and + * properties/lookBackPeriod. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter + * reservationRecommendations by properties/scope and + * properties/lookBackPeriod. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ReservationRecommendationsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationRecommendationsListResult} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(options, optionalCallback); + } + } + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * List of recomendations for purchasing reserved instances. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ReservationRecommendationsListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ReservationRecommendationsListResult} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = ReservationRecommendations; diff --git a/lib/services/consumptionManagement/lib/operations/tags.js b/lib/services/consumptionManagement/lib/operations/tags.js new file mode 100644 index 0000000000..cd32865e9c --- /dev/null +++ b/lib/services/consumptionManagement/lib/operations/tags.js @@ -0,0 +1,248 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Get all available tag keys for a billing account. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link TagsResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(billingAccountId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.CostManagement/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/tags'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['TagsResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a Tags. */ +class Tags { + /** + * Create a Tags. + * @param {ConsumptionManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + } + + /** + * Get all available tag keys for a billing account. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(billingAccountId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get all available tag keys for a billing account. + * + * @param {string} billingAccountId BillingAccount ID + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {TagsResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link TagsResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(billingAccountId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(billingAccountId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountId, options, optionalCallback); + } + } + +} + +module.exports = Tags;