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