diff --git a/lib/services/billingManagement/LICENSE.txt b/lib/services/billingManagement/LICENSE.txt index a70e8cf660..8f3d856145 100644 --- a/lib/services/billingManagement/LICENSE.txt +++ b/lib/services/billingManagement/LICENSE.txt @@ -1,21 +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. +The MIT License (MIT) + +Copyright (c) 2019 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/billingManagement/lib/billingManagementClient.d.ts b/lib/services/billingManagement/lib/billingManagementClient.d.ts index 47651c3da9..b26d5c90fb 100644 --- a/lib/services/billingManagement/lib/billingManagementClient.d.ts +++ b/lib/services/billingManagement/lib/billingManagementClient.d.ts @@ -8,7 +8,7 @@ * regenerated. */ -import { ServiceClientCredentials } from 'ms-rest'; +import { ServiceClient, ServiceClientOptions, ServiceCallback, HttpOperationResponse, ServiceClientCredentials } from 'ms-rest'; import { AzureServiceClient, AzureServiceClientOptions } from 'ms-rest-azure'; import * as models from "./models"; import * as operations from "./operations"; @@ -34,11 +34,11 @@ export default class BillingManagementClient extends AzureServiceClient { * * @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 {string} [options.acceptLanguage] - 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 {number} [options.longRunningOperationRetryTimeout] - 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. + * @param {boolean} [options.generateClientRequestId] - Whether a unique x-ms-client-request-id should be generated. 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); @@ -56,10 +56,250 @@ export default class BillingManagementClient extends AzureServiceClient { generateClientRequestId: boolean; // Operation groups + billingAccounts: operations.BillingAccounts; + billingAccountsWithCreateInvoiceSectionPermission: operations.BillingAccountsWithCreateInvoiceSectionPermission; + availableBalanceByBillingProfile: operations.AvailableBalanceByBillingProfile; + paymentMethodsByBillingProfile: operations.PaymentMethodsByBillingProfile; + billingProfilesByBillingAccountId: operations.BillingProfilesByBillingAccountId; + billingProfiles: operations.BillingProfiles; + invoiceSectionsByBillingAccountId: operations.InvoiceSectionsByBillingAccountId; + invoiceSections: operations.InvoiceSections; + invoiceSectionsWithCreateSubscriptionPermission: operations.InvoiceSectionsWithCreateSubscriptionPermission; + departmentsByBillingAccountId: operations.DepartmentsByBillingAccountId; + departments: operations.Departments; + enrollmentAccountsByBillingAccountId: operations.EnrollmentAccountsByBillingAccountId; enrollmentAccounts: operations.EnrollmentAccounts; - billingPeriods: operations.BillingPeriods; - invoices: operations.Invoices; + invoicesByBillingAccount: operations.InvoicesByBillingAccount; + invoicePricesheet: operations.InvoicePricesheet; + invoicesByBillingProfile: operations.InvoicesByBillingProfile; + invoice: operations.Invoice; + productsByBillingSubscriptions: operations.ProductsByBillingSubscriptions; + billingSubscriptionsByBillingProfile: operations.BillingSubscriptionsByBillingProfile; + billingSubscriptionsByInvoiceSection: operations.BillingSubscriptionsByInvoiceSection; + billingSubscription: operations.BillingSubscription; + productsByBillingAccount: operations.ProductsByBillingAccount; + productsByInvoiceSection: operations.ProductsByInvoiceSection; + products: operations.Products; + transactionsByBillingAccount: operations.TransactionsByBillingAccount; + policyOperations: operations.PolicyOperations; + billingPropertyOperations: operations.BillingPropertyOperations; operations: operations.Operations; + + + /** + * Lists the transactions by billingProfileId for given start date and end + * date. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {string} startDate Start date + * + * @param {string} endDate End date + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter by transaction kind. + * 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 {object} [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. + */ + transactionsByBillingProfileWithHttpOperationResponse(billingAccountId: string, billingProfileId: string, startDate: string, endDate: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the transactions by billingProfileId for given start date and end + * date. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {string} startDate Start date + * + * @param {string} endDate End date + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter by transaction kind. + * 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 {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 {TransactionsListResult} - 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. + * + * {TransactionsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link TransactionsListResult} 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. + */ + transactionsByBillingProfile(billingAccountId: string, billingProfileId: string, startDate: string, endDate: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + transactionsByBillingProfile(billingAccountId: string, billingProfileId: string, startDate: string, endDate: string, callback: ServiceCallback): void; + transactionsByBillingProfile(billingAccountId: string, billingProfileId: string, startDate: string, endDate: string, options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Cancel product by product id + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} productName Invoide Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.autoRenew] Request parameters to update auto renew + * policy a product. Possible values include: 'true', 'false' + * + * @param {object} [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. + */ + updateAutoRenewForBillingAccountWithHttpOperationResponse(billingAccountId: string, productName: string, options?: { autoRenew? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Cancel product by product id + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} productName Invoide Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.autoRenew] Request parameters to update auto renew + * policy a product. Possible values include: 'true', 'false' + * + * @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 {UpdateAutoRenewOperationSummary} - 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. + * + * {UpdateAutoRenewOperationSummary} [result] - The deserialized result object if an error did not occur. + * See {@link UpdateAutoRenewOperationSummary} 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. + */ + updateAutoRenewForBillingAccount(billingAccountId: string, productName: string, options?: { autoRenew? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + updateAutoRenewForBillingAccount(billingAccountId: string, productName: string, callback: ServiceCallback): void; + updateAutoRenewForBillingAccount(billingAccountId: string, productName: string, options: { autoRenew? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Cancel auto renew for product by product id + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {string} productName Invoide Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.autoRenew] Request parameters to update auto renew + * policy a product. Possible values include: 'true', 'false' + * + * @param {object} [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. + */ + updateAutoRenewForInvoiceSectionWithHttpOperationResponse(billingAccountId: string, invoiceSectionId: string, productName: string, options?: { autoRenew? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Cancel auto renew for product by product id + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {string} productName Invoide Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.autoRenew] Request parameters to update auto renew + * policy a product. Possible values include: 'true', 'false' + * + * @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 {UpdateAutoRenewOperationSummary} - 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. + * + * {UpdateAutoRenewOperationSummary} [result] - The deserialized result object if an error did not occur. + * See {@link UpdateAutoRenewOperationSummary} 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. + */ + updateAutoRenewForInvoiceSection(billingAccountId: string, invoiceSectionId: string, productName: string, options?: { autoRenew? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + updateAutoRenewForInvoiceSection(billingAccountId: string, invoiceSectionId: string, productName: string, callback: ServiceCallback): void; + updateAutoRenewForInvoiceSection(billingAccountId: string, invoiceSectionId: string, productName: string, options: { autoRenew? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } export { BillingManagementClient, models as BillingManagementModels }; diff --git a/lib/services/billingManagement/lib/billingManagementClient.js b/lib/services/billingManagement/lib/billingManagementClient.js index 8ba64baebe..1da2ef476c 100644 --- a/lib/services/billingManagement/lib/billingManagementClient.js +++ b/lib/services/billingManagement/lib/billingManagementClient.js @@ -17,11 +17,524 @@ const msRest = require('ms-rest'); const msRestAzure = require('ms-rest-azure'); const ServiceClient = msRestAzure.AzureServiceClient; +const WebResource = msRest.WebResource; const models = require('./models'); const operations = require('./operations'); +/** + * Lists the transactions by billingProfileId for given start date and end + * date. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {string} startDate Start date + * + * @param {string} endDate End date + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter by transaction kind. + * 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 {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 TransactionsListResult} for more + * information. + * + * {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 _transactionsByBillingProfile(billingAccountId, billingProfileId, startDate, endDate, options, callback) { + /* jshint validthis: true */ + let client = this; + 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 (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 (billingProfileId === null || billingProfileId === undefined || typeof billingProfileId.valueOf() !== 'string') { + throw new Error('billingProfileId cannot be null or undefined and it must be of type string.'); + } + if (this.apiVersion === null || this.apiVersion === undefined || typeof this.apiVersion.valueOf() !== 'string') { + throw new Error('this.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (startDate === null || startDate === undefined || typeof startDate.valueOf() !== 'string') { + throw new Error('startDate cannot be null or undefined and it must be of type string.'); + } + if (endDate === null || endDate === undefined || typeof endDate.valueOf() !== 'string') { + throw new Error('endDate 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.acceptLanguage !== null && this.acceptLanguage !== undefined && typeof this.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/transactions'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{billingProfileId}', encodeURIComponent(billingProfileId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.apiVersion)); + queryParameters.push('startDate=' + encodeURIComponent(startDate)); + queryParameters.push('endDate=' + encodeURIComponent(endDate)); + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + 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.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.acceptLanguage !== undefined && this.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.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['TransactionsListResult']().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); + }); +} + +/** + * Cancel product by product id + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} productName Invoide Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.autoRenew] Request parameters to update auto renew + * policy a product. Possible values include: 'true', 'false' + * + * @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 UpdateAutoRenewOperationSummary} for more + * information. + * + * {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 _updateAutoRenewForBillingAccount(billingAccountId, productName, options, callback) { + /* jshint validthis: true */ + let client = this; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let autoRenew = (options && options.autoRenew !== undefined) ? options.autoRenew : undefined; + // Validate + try { + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (productName === null || productName === undefined || typeof productName.valueOf() !== 'string') { + throw new Error('productName cannot be null or undefined and it must be of type string.'); + } + if (this.apiVersion === null || this.apiVersion === undefined || typeof this.apiVersion.valueOf() !== 'string') { + throw new Error('this.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (autoRenew !== null && autoRenew !== undefined && typeof autoRenew.valueOf() !== 'string') { + throw new Error('autoRenew must be of type string.'); + } + if (this.acceptLanguage !== null && this.acceptLanguage !== undefined && typeof this.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + let body; + if (autoRenew !== null && autoRenew !== undefined) { + body = new client.models['UpdateAutoRenewRequest'](); + body.autoRenew = autoRenew; + } + + // Construct URL + let baseUrl = this.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/products/{productName}/updateAutoRenew'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{productName}', encodeURIComponent(productName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.acceptLanguage !== undefined && this.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.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 (body !== null && body !== undefined) { + let requestModelMapper = new client.models['UpdateAutoRenewRequest']().mapper(); + requestModel = client.serialize(requestModelMapper, body, 'body'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(body, 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) { + 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['UpdateAutoRenewOperationSummary']().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); + }); +} + +/** + * Cancel auto renew for product by product id + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {string} productName Invoide Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.autoRenew] Request parameters to update auto renew + * policy a product. Possible values include: 'true', 'false' + * + * @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 UpdateAutoRenewOperationSummary} for more + * information. + * + * {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 _updateAutoRenewForInvoiceSection(billingAccountId, invoiceSectionId, productName, options, callback) { + /* jshint validthis: true */ + let client = this; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let autoRenew = (options && options.autoRenew !== undefined) ? options.autoRenew : undefined; + // Validate + try { + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionId === null || invoiceSectionId === undefined || typeof invoiceSectionId.valueOf() !== 'string') { + throw new Error('invoiceSectionId cannot be null or undefined and it must be of type string.'); + } + if (productName === null || productName === undefined || typeof productName.valueOf() !== 'string') { + throw new Error('productName cannot be null or undefined and it must be of type string.'); + } + if (this.apiVersion === null || this.apiVersion === undefined || typeof this.apiVersion.valueOf() !== 'string') { + throw new Error('this.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (autoRenew !== null && autoRenew !== undefined && typeof autoRenew.valueOf() !== 'string') { + throw new Error('autoRenew must be of type string.'); + } + if (this.acceptLanguage !== null && this.acceptLanguage !== undefined && typeof this.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + let body; + if (autoRenew !== null && autoRenew !== undefined) { + body = new client.models['UpdateAutoRenewRequest'](); + body.autoRenew = autoRenew; + } + + // Construct URL + let baseUrl = this.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}/products/{productName}/updateAutoRenew'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{invoiceSectionId}', encodeURIComponent(invoiceSectionId)); + requestUrl = requestUrl.replace('{productName}', encodeURIComponent(productName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.acceptLanguage !== undefined && this.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.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 (body !== null && body !== undefined) { + let requestModelMapper = new client.models['UpdateAutoRenewRequest']().mapper(); + requestModel = client.serialize(requestModelMapper, body, 'body'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(body, 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) { + 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['UpdateAutoRenewOperationSummary']().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 BillingManagementClient. */ class BillingManagementClient extends ServiceClient { /** @@ -34,9 +547,9 @@ class BillingManagementClient extends ServiceClient { * @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. + * @param {string} [options.acceptLanguage] - The preferred language for the response. + * @param {number} [options.longRunningOperationRetryTimeout] - The retry timeout in seconds for Long Running Operations. Default value is 30. + * @param {boolean} [options.generateClientRequestId] - Whether a unique x-ms-client-request-id should be generated. 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) { @@ -50,7 +563,7 @@ class BillingManagementClient extends ServiceClient { super(credentials, options); - this.apiVersion = '2018-03-01-preview'; + this.apiVersion = '2018-11-01-preview'; this.acceptLanguage = 'en-US'; this.longRunningOperationRetryTimeout = 30; this.generateClientRequestId = true; @@ -72,14 +585,338 @@ class BillingManagementClient extends ServiceClient { if(options.generateClientRequestId !== null && options.generateClientRequestId !== undefined) { this.generateClientRequestId = options.generateClientRequestId; } + this.billingAccounts = new operations.BillingAccounts(this); + this.billingAccountsWithCreateInvoiceSectionPermission = new operations.BillingAccountsWithCreateInvoiceSectionPermission(this); + this.availableBalanceByBillingProfile = new operations.AvailableBalanceByBillingProfile(this); + this.paymentMethodsByBillingProfile = new operations.PaymentMethodsByBillingProfile(this); + this.billingProfilesByBillingAccountId = new operations.BillingProfilesByBillingAccountId(this); + this.billingProfiles = new operations.BillingProfiles(this); + this.invoiceSectionsByBillingAccountId = new operations.InvoiceSectionsByBillingAccountId(this); + this.invoiceSections = new operations.InvoiceSections(this); + this.invoiceSectionsWithCreateSubscriptionPermission = new operations.InvoiceSectionsWithCreateSubscriptionPermission(this); + this.departmentsByBillingAccountId = new operations.DepartmentsByBillingAccountId(this); + this.departments = new operations.Departments(this); + this.enrollmentAccountsByBillingAccountId = new operations.EnrollmentAccountsByBillingAccountId(this); this.enrollmentAccounts = new operations.EnrollmentAccounts(this); - this.billingPeriods = new operations.BillingPeriods(this); - this.invoices = new operations.Invoices(this); + this.invoicesByBillingAccount = new operations.InvoicesByBillingAccount(this); + this.invoicePricesheet = new operations.InvoicePricesheet(this); + this.invoicesByBillingProfile = new operations.InvoicesByBillingProfile(this); + this.invoice = new operations.Invoice(this); + this.productsByBillingSubscriptions = new operations.ProductsByBillingSubscriptions(this); + this.billingSubscriptionsByBillingProfile = new operations.BillingSubscriptionsByBillingProfile(this); + this.billingSubscriptionsByInvoiceSection = new operations.BillingSubscriptionsByInvoiceSection(this); + this.billingSubscription = new operations.BillingSubscription(this); + this.productsByBillingAccount = new operations.ProductsByBillingAccount(this); + this.productsByInvoiceSection = new operations.ProductsByInvoiceSection(this); + this.products = new operations.Products(this); + this.transactionsByBillingAccount = new operations.TransactionsByBillingAccount(this); + this.policyOperations = new operations.PolicyOperations(this); + this.billingPropertyOperations = new operations.BillingPropertyOperations(this); this.operations = new operations.Operations(this); this.models = models; + this._transactionsByBillingProfile = _transactionsByBillingProfile; + this._updateAutoRenewForBillingAccount = _updateAutoRenewForBillingAccount; + this._updateAutoRenewForInvoiceSection = _updateAutoRenewForInvoiceSection; msRest.addSerializationMixin(this); } + /** + * Lists the transactions by billingProfileId for given start date and end + * date. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {string} startDate Start date + * + * @param {string} endDate End date + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter by transaction kind. + * 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 {object} [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. + */ + transactionsByBillingProfileWithHttpOperationResponse(billingAccountId, billingProfileId, startDate, endDate, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._transactionsByBillingProfile(billingAccountId, billingProfileId, startDate, endDate, 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 transactions by billingProfileId for given start date and end + * date. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {string} startDate Start date + * + * @param {string} endDate End date + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter by transaction kind. + * 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 {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 {TransactionsListResult} - 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 TransactionsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + transactionsByBillingProfile(billingAccountId, billingProfileId, startDate, endDate, options, optionalCallback) { + let client = this; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._transactionsByBillingProfile(billingAccountId, billingProfileId, startDate, endDate, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._transactionsByBillingProfile(billingAccountId, billingProfileId, startDate, endDate, options, optionalCallback); + } + } + + /** + * Cancel product by product id + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} productName Invoide Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.autoRenew] Request parameters to update auto renew + * policy a product. Possible values include: 'true', 'false' + * + * @param {object} [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. + */ + updateAutoRenewForBillingAccountWithHttpOperationResponse(billingAccountId, productName, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._updateAutoRenewForBillingAccount(billingAccountId, productName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Cancel product by product id + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} productName Invoide Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.autoRenew] Request parameters to update auto renew + * policy a product. Possible values include: 'true', 'false' + * + * @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 {UpdateAutoRenewOperationSummary} - 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 UpdateAutoRenewOperationSummary} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + updateAutoRenewForBillingAccount(billingAccountId, productName, options, optionalCallback) { + let client = this; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._updateAutoRenewForBillingAccount(billingAccountId, productName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._updateAutoRenewForBillingAccount(billingAccountId, productName, options, optionalCallback); + } + } + + /** + * Cancel auto renew for product by product id + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {string} productName Invoide Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.autoRenew] Request parameters to update auto renew + * policy a product. Possible values include: 'true', 'false' + * + * @param {object} [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. + */ + updateAutoRenewForInvoiceSectionWithHttpOperationResponse(billingAccountId, invoiceSectionId, productName, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._updateAutoRenewForInvoiceSection(billingAccountId, invoiceSectionId, productName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Cancel auto renew for product by product id + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {string} productName Invoide Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.autoRenew] Request parameters to update auto renew + * policy a product. Possible values include: 'true', 'false' + * + * @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 {UpdateAutoRenewOperationSummary} - 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 UpdateAutoRenewOperationSummary} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + updateAutoRenewForInvoiceSection(billingAccountId, invoiceSectionId, productName, options, optionalCallback) { + let client = this; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._updateAutoRenewForInvoiceSection(billingAccountId, invoiceSectionId, productName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._updateAutoRenewForInvoiceSection(billingAccountId, invoiceSectionId, productName, options, optionalCallback); + } + } + } module.exports = BillingManagementClient; diff --git a/lib/services/billingManagement/lib/models/address.js b/lib/services/billingManagement/lib/models/address.js new file mode 100644 index 0000000000..b15eb873e8 --- /dev/null +++ b/lib/services/billingManagement/lib/models/address.js @@ -0,0 +1,124 @@ +/* + * 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'; + +/** + * Address details. + * + */ +class Address { + /** + * Create a Address. + * @property {string} [firstName] First Name. + * @property {string} [lastName] Last Name. + * @property {string} [companyName] Company Name. + * @property {string} [addressLine1] Address Line1. + * @property {string} [addressLine2] Address Line2. + * @property {string} [addressLine3] Address Line3. + * @property {string} [city] Address City. + * @property {string} [region] Address Region. + * @property {string} [country] Country code uses ISO2, 2-digit format. + * @property {string} [postalCode] Address Postal Code. + */ + constructor() { + } + + /** + * Defines the metadata of Address + * + * @returns {object} metadata of Address + * + */ + mapper() { + return { + required: false, + serializedName: 'Address', + type: { + name: 'Composite', + className: 'Address', + modelProperties: { + firstName: { + required: false, + serializedName: 'firstName', + type: { + name: 'String' + } + }, + lastName: { + required: false, + serializedName: 'lastName', + type: { + name: 'String' + } + }, + companyName: { + required: false, + serializedName: 'companyName', + type: { + name: 'String' + } + }, + addressLine1: { + required: false, + serializedName: 'addressLine1', + type: { + name: 'String' + } + }, + addressLine2: { + required: false, + serializedName: 'addressLine2', + type: { + name: 'String' + } + }, + addressLine3: { + required: false, + serializedName: 'addressLine3', + type: { + name: 'String' + } + }, + city: { + required: false, + serializedName: 'city', + type: { + name: 'String' + } + }, + region: { + required: false, + serializedName: 'region', + type: { + name: 'String' + } + }, + country: { + required: false, + serializedName: 'country', + type: { + name: 'String' + } + }, + postalCode: { + required: false, + serializedName: 'postalCode', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = Address; diff --git a/lib/services/billingManagement/lib/models/amount.js b/lib/services/billingManagement/lib/models/amount.js new file mode 100644 index 0000000000..8ee3a31108 --- /dev/null +++ b/lib/services/billingManagement/lib/models/amount.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 Amount. + * + */ +class Amount { + /** + * Create a Amount. + * @property {string} [currency] The currency for the amount value. + * @property {number} [value] Amount value. + */ + constructor() { + } + + /** + * Defines the metadata of Amount + * + * @returns {object} metadata of Amount + * + */ + mapper() { + return { + required: false, + serializedName: 'Amount', + type: { + name: 'Composite', + className: 'Amount', + modelProperties: { + currency: { + required: false, + readOnly: true, + serializedName: 'currency', + type: { + name: 'String' + } + }, + value: { + required: false, + readOnly: true, + serializedName: 'value', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = Amount; diff --git a/lib/services/billingManagement/lib/models/availableBalance.js b/lib/services/billingManagement/lib/models/availableBalance.js new file mode 100644 index 0000000000..de61ae5be5 --- /dev/null +++ b/lib/services/billingManagement/lib/models/availableBalance.js @@ -0,0 +1,84 @@ +/* + * 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'); + +/** + * Latest available balance on Monetary Credit PI. + * + * @extends models['Resource'] + */ +class AvailableBalance extends models['Resource'] { + /** + * Create a AvailableBalance. + * @property {object} [amount] Balance Amount. + * @property {string} [amount.currency] The currency for the amount value. + * @property {number} [amount.value] Amount value. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of AvailableBalance + * + * @returns {object} metadata of AvailableBalance + * + */ + mapper() { + return { + required: false, + serializedName: 'AvailableBalance', + type: { + name: 'Composite', + className: 'AvailableBalance', + 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' + } + }, + amount: { + required: false, + readOnly: true, + serializedName: 'properties.amount', + type: { + name: 'Composite', + className: 'Amount' + } + } + } + } + }; + } +} + +module.exports = AvailableBalance; diff --git a/lib/services/billingManagement/lib/models/billingAccount.js b/lib/services/billingManagement/lib/models/billingAccount.js new file mode 100644 index 0000000000..bf048ff410 --- /dev/null +++ b/lib/services/billingManagement/lib/models/billingAccount.js @@ -0,0 +1,232 @@ +/* + * 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 billing account resource. + * + * @extends models['Resource'] + */ +class BillingAccount extends models['Resource'] { + /** + * Create a BillingAccount. + * @property {string} [displayName] The billing account name. + * @property {string} [company] The Company this billing account belongs to. + * @property {string} [accountType] The billing account Type. Possible values + * include: 'Organization', 'Enrollment' + * @property {object} [address] The address associated with billing account. + * @property {string} [address.firstName] First Name. + * @property {string} [address.lastName] Last Name. + * @property {string} [address.companyName] Company Name. + * @property {string} [address.addressLine1] Address Line1. + * @property {string} [address.addressLine2] Address Line2. + * @property {string} [address.addressLine3] Address Line3. + * @property {string} [address.city] Address City. + * @property {string} [address.region] Address Region. + * @property {string} [address.country] Country code uses ISO2, 2-digit + * format. + * @property {string} [address.postalCode] Address Postal Code. + * @property {string} [country] The country associated with billing account.. + * @property {array} [invoiceSections] The invoice sections associated to the + * billing account. + * @property {array} [billingProfiles] The billing profiles associated to the + * billing account. + * @property {object} [enrollmentDetails] The details about the associated + * legacy enrollment. By default this is not populated, unless it's specified + * in $expand. + * @property {date} [enrollmentDetails.startDate] Enrollment Start Date + * @property {date} [enrollmentDetails.endDate] Enrollment End Date + * @property {string} [enrollmentDetails.currency] The currency associated + * with enrollment + * @property {string} [enrollmentDetails.channel] The channel for Enrollment + * @property {object} [enrollmentDetails.policies] The attributes associated + * with legacy enrollment. + * @property {boolean} [enrollmentDetails.policies.accountOwnerViewCharges] + * The accountOwnerViewCharges flag for Enrollment + * @property {boolean} + * [enrollmentDetails.policies.departmentAdminViewCharges] The + * departmentAdminViewCharges flag for Enrollment + * @property {boolean} [enrollmentDetails.policies.marketplacesEnabled] The + * marketplaces flag for Enrollment + * @property {boolean} [enrollmentDetails.policies.reservedInstancesEnabled] + * The reserved instances flag for Enrollment + * @property {string} [enrollmentDetails.language] The language for + * Enrollment + * @property {string} [enrollmentDetails.countryCode] The countryCode for + * Enrollment + * @property {string} [enrollmentDetails.status] Enrollment status + * @property {string} [enrollmentDetails.billingCylce] Enrollment billing + * cycle + * @property {array} [departments] The departments associated to the + * enrollment. + * @property {array} [enrollmentAccounts] The accounts associated to the + * enrollment. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of BillingAccount + * + * @returns {object} metadata of BillingAccount + * + */ + mapper() { + return { + required: false, + serializedName: 'BillingAccount', + type: { + name: 'Composite', + className: 'BillingAccount', + 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' + } + }, + displayName: { + required: false, + readOnly: true, + serializedName: 'properties.displayName', + type: { + name: 'String' + } + }, + company: { + required: false, + readOnly: true, + serializedName: 'properties.company', + type: { + name: 'String' + } + }, + accountType: { + required: false, + readOnly: true, + serializedName: 'properties.accountType', + type: { + name: 'String' + } + }, + address: { + required: false, + serializedName: 'properties.address', + type: { + name: 'Composite', + className: 'Address' + } + }, + country: { + required: false, + readOnly: true, + serializedName: 'properties.country', + type: { + name: 'String' + } + }, + invoiceSections: { + required: false, + serializedName: 'properties.invoiceSections', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'InvoiceSectionElementType', + type: { + name: 'Composite', + className: 'InvoiceSection' + } + } + } + }, + billingProfiles: { + required: false, + serializedName: 'properties.billingProfiles', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'BillingProfileElementType', + type: { + name: 'Composite', + className: 'BillingProfile' + } + } + } + }, + enrollmentDetails: { + required: false, + readOnly: true, + serializedName: 'properties.enrollmentDetails', + type: { + name: 'Composite', + className: 'Enrollment' + } + }, + departments: { + required: false, + serializedName: 'properties.departments', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'DepartmentElementType', + type: { + name: 'Composite', + className: 'Department' + } + } + } + }, + enrollmentAccounts: { + required: false, + serializedName: 'properties.enrollmentAccounts', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'EnrollmentAccountElementType', + type: { + name: 'Composite', + className: 'EnrollmentAccount' + } + } + } + } + } + } + }; + } +} + +module.exports = BillingAccount; diff --git a/lib/services/billingManagement/lib/models/billingAccountListResult.js b/lib/services/billingManagement/lib/models/billingAccountListResult.js new file mode 100644 index 0000000000..5f07032118 --- /dev/null +++ b/lib/services/billingManagement/lib/models/billingAccountListResult.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 billing accounts. + * + */ +class BillingAccountListResult { + /** + * Create a BillingAccountListResult. + * @property {array} [value] The list of billing accounts. + * @property {string} [nextLink] The link (url) to the next page of results. + */ + constructor() { + } + + /** + * Defines the metadata of BillingAccountListResult + * + * @returns {object} metadata of BillingAccountListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'BillingAccountListResult', + type: { + name: 'Composite', + className: 'BillingAccountListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: 'value', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'BillingAccountElementType', + type: { + name: 'Composite', + className: 'BillingAccount' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = BillingAccountListResult; diff --git a/lib/services/billingManagement/lib/models/billingPeriod.js b/lib/services/billingManagement/lib/models/billingPeriod.js index 5d21ba66fb..119dcd2f50 100644 --- a/lib/services/billingManagement/lib/models/billingPeriod.js +++ b/lib/services/billingManagement/lib/models/billingPeriod.js @@ -20,11 +20,11 @@ const models = require('./index'); class BillingPeriod extends models['Resource'] { /** * Create a BillingPeriod. - * @member {date} [billingPeriodStartDate] The start of the date range + * @property {date} [billingPeriodStartDate] The start of the date range * covered by the billing period. - * @member {date} [billingPeriodEndDate] The end of the date range covered by - * the billing period. - * @member {array} [invoiceIds] Array of invoice ids that associated with. + * @property {date} [billingPeriodEndDate] The end of the date range covered + * by the billing period. + * @property {array} [invoiceIds] Array of invoice ids that associated with. */ constructor() { super(); diff --git a/lib/services/billingManagement/lib/models/billingPeriodsListResult.js b/lib/services/billingManagement/lib/models/billingPeriodsListResult.js index 0ae636b929..39c954b521 100644 --- a/lib/services/billingManagement/lib/models/billingPeriodsListResult.js +++ b/lib/services/billingManagement/lib/models/billingPeriodsListResult.js @@ -17,7 +17,7 @@ class BillingPeriodsListResult extends Array { /** * Create a BillingPeriodsListResult. - * @member {string} [nextLink] The link (url) to the next page of results. + * @property {string} [nextLink] The link (url) to the next page of results. */ constructor() { super(); diff --git a/lib/services/billingManagement/lib/models/billingProfile.js b/lib/services/billingManagement/lib/models/billingProfile.js new file mode 100644 index 0000000000..1db4a03618 --- /dev/null +++ b/lib/services/billingManagement/lib/models/billingProfile.js @@ -0,0 +1,179 @@ +/* + * 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 billing profile resource. + * + * @extends models['Resource'] + */ +class BillingProfile extends models['Resource'] { + /** + * Create a BillingProfile. + * @property {string} [displayName] The billing profile name. + * @property {string} [poNumber] Purchase order number. + * @property {object} [billingAddress] Billing address. + * @property {string} [billingAddress.firstName] First Name. + * @property {string} [billingAddress.lastName] Last Name. + * @property {string} [billingAddress.companyName] Company Name. + * @property {string} [billingAddress.addressLine1] Address Line1. + * @property {string} [billingAddress.addressLine2] Address Line2. + * @property {string} [billingAddress.addressLine3] Address Line3. + * @property {string} [billingAddress.city] Address City. + * @property {string} [billingAddress.region] Address Region. + * @property {string} [billingAddress.country] Country code uses ISO2, + * 2-digit format. + * @property {string} [billingAddress.postalCode] Address Postal Code. + * @property {boolean} [invoiceEmailOptIn] If the billing profile is opted in + * to recieve invoices via email. + * @property {boolean} [isClassic] Is OMS bootstrapped billing profile. + * @property {number} [invoiceDay] Invoice day. + * @property {string} [currency] The currency associated with the billing + * profile. + * @property {array} [enabledAzureSKUs] Information about the product. + * @property {array} [invoiceSections] The invoice sections associated to the + * billing profile. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of BillingProfile + * + * @returns {object} metadata of BillingProfile + * + */ + mapper() { + return { + required: false, + serializedName: 'BillingProfile', + type: { + name: 'Composite', + className: 'BillingProfile', + 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' + } + }, + displayName: { + required: false, + serializedName: 'properties.displayName', + type: { + name: 'String' + } + }, + poNumber: { + required: false, + serializedName: 'properties.poNumber', + type: { + name: 'String' + } + }, + billingAddress: { + required: false, + serializedName: 'properties.billingAddress', + type: { + name: 'Composite', + className: 'Address' + } + }, + invoiceEmailOptIn: { + required: false, + readOnly: true, + serializedName: 'properties.invoiceEmailOptIn', + type: { + name: 'Boolean' + } + }, + isClassic: { + required: false, + readOnly: true, + serializedName: 'properties.isClassic', + type: { + name: 'Boolean' + } + }, + invoiceDay: { + required: false, + readOnly: true, + serializedName: 'properties.invoiceDay', + type: { + name: 'Number' + } + }, + currency: { + required: false, + readOnly: true, + serializedName: 'properties.currency', + type: { + name: 'String' + } + }, + enabledAzureSKUs: { + required: false, + serializedName: 'properties.enabledAzureSKUs', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'EnabledAzureSKUsElementType', + type: { + name: 'Composite', + className: 'EnabledAzureSKUs' + } + } + } + }, + invoiceSections: { + required: false, + serializedName: 'properties.invoiceSections', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'InvoiceSectionElementType', + type: { + name: 'Composite', + className: 'InvoiceSection' + } + } + } + } + } + } + }; + } +} + +module.exports = BillingProfile; diff --git a/lib/services/billingManagement/lib/models/billingProfileListResult.js b/lib/services/billingManagement/lib/models/billingProfileListResult.js new file mode 100644 index 0000000000..595266b1a3 --- /dev/null +++ b/lib/services/billingManagement/lib/models/billingProfileListResult.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 billing profiles. + * + */ +class BillingProfileListResult { + /** + * Create a BillingProfileListResult. + * @property {array} [value] The list of billing profiles. + * @property {string} [nextLink] The link (url) to the next page of results. + */ + constructor() { + } + + /** + * Defines the metadata of BillingProfileListResult + * + * @returns {object} metadata of BillingProfileListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'BillingProfileListResult', + type: { + name: 'Composite', + className: 'BillingProfileListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: 'value', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'BillingProfileElementType', + type: { + name: 'Composite', + className: 'BillingProfile' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = BillingProfileListResult; diff --git a/lib/services/billingManagement/lib/models/billingProperty.js b/lib/services/billingManagement/lib/models/billingProperty.js new file mode 100644 index 0000000000..b2d6b760f7 --- /dev/null +++ b/lib/services/billingManagement/lib/models/billingProperty.js @@ -0,0 +1,134 @@ +/* + * 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 billing property. + * + */ +class BillingProperty { + /** + * Create a BillingProperty. + * @property {string} [productId] Product Id. + * @property {string} [billingTenantId] Billing tenant Id. + * @property {string} [billingAccountId] Billing account Id. + * @property {string} [billingAccountName] Billing account name. + * @property {string} [billingProfileId] Billing profile Id. + * @property {string} [billingProflieName] Billing profile name. + * @property {string} [invoiceSectionId] Invoice Section Id. + * @property {string} [invoiceSectionName] Invoice Section name. + * @property {string} [skuId] SKU Id. + * @property {string} [skuDescription] SKU description. + */ + constructor() { + } + + /** + * Defines the metadata of BillingProperty + * + * @returns {object} metadata of BillingProperty + * + */ + mapper() { + return { + required: false, + serializedName: 'BillingProperty', + type: { + name: 'Composite', + className: 'BillingProperty', + modelProperties: { + productId: { + required: false, + readOnly: true, + serializedName: 'productId', + type: { + name: 'String' + } + }, + billingTenantId: { + required: false, + readOnly: true, + serializedName: 'billingTenantId', + type: { + name: 'String' + } + }, + billingAccountId: { + required: false, + readOnly: true, + serializedName: 'billingAccountId', + type: { + name: 'String' + } + }, + billingAccountName: { + required: false, + readOnly: true, + serializedName: 'billingAccountName', + type: { + name: 'String' + } + }, + billingProfileId: { + required: false, + readOnly: true, + serializedName: 'billingProfileId', + type: { + name: 'String' + } + }, + billingProflieName: { + required: false, + readOnly: true, + serializedName: 'billingProflieName', + type: { + name: 'String' + } + }, + invoiceSectionId: { + required: false, + readOnly: true, + serializedName: 'invoiceSectionId', + type: { + name: 'String' + } + }, + invoiceSectionName: { + required: false, + readOnly: true, + serializedName: 'invoiceSectionName', + type: { + name: 'String' + } + }, + skuId: { + required: false, + readOnly: true, + serializedName: 'skuId', + type: { + name: 'String' + } + }, + skuDescription: { + required: false, + readOnly: true, + serializedName: 'skuDescription', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = BillingProperty; diff --git a/lib/services/billingManagement/lib/models/billingSubscriptionSummary.js b/lib/services/billingManagement/lib/models/billingSubscriptionSummary.js new file mode 100644 index 0000000000..761aa96524 --- /dev/null +++ b/lib/services/billingManagement/lib/models/billingSubscriptionSummary.js @@ -0,0 +1,180 @@ +/* + * 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 billing Subscription summary resource. + * + * @extends models['Resource'] + */ +class BillingSubscriptionSummary extends models['Resource'] { + /** + * Create a BillingSubscriptionSummary. + * @property {string} [displayName] display name. + * @property {uuid} [subscriptionId] Subscription Id. + * @property {string} [subscriptionBillingStatus] Subscription billing + * status. Possible values include: 'Active', 'Inactive', 'Abandoned', + * 'Deleted', 'Warning' + * @property {object} [lastMonthCharges] Last month charges. + * @property {string} [lastMonthCharges.currency] The currency for the amount + * value. + * @property {number} [lastMonthCharges.value] Amount value. + * @property {object} [monthToDateCharges] Month to date charges. + * @property {string} [monthToDateCharges.currency] The currency for the + * amount value. + * @property {number} [monthToDateCharges.value] Amount value. + * @property {object} [enrollmentAccountContext] The enrollment account + * context. + * @property {string} [enrollmentAccountContext.costCenter] The cost center + * name. + * @property {date} [enrollmentAccountContext.startDate] Account Start Date + * @property {date} [enrollmentAccountContext.endDate] Account End Date + * @property {string} [enrollmentAccountContext.enrollmentAccountId] The + * enrollment account id. + * @property {string} [billingProfileId] Billing Profile id to which this + * product belongs. + * @property {string} [billingProfileName] Billing Profile name to which this + * product belongs. + * @property {string} [skuId] The sku id. + * @property {string} [skuDescription] The sku description. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of BillingSubscriptionSummary + * + * @returns {object} metadata of BillingSubscriptionSummary + * + */ + mapper() { + return { + required: false, + serializedName: 'BillingSubscriptionSummary', + type: { + name: 'Composite', + className: 'BillingSubscriptionSummary', + 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' + } + }, + displayName: { + required: false, + readOnly: true, + serializedName: 'properties.displayName', + type: { + name: 'String' + } + }, + subscriptionId: { + required: false, + readOnly: true, + serializedName: 'properties.subscriptionId', + type: { + name: 'String' + } + }, + subscriptionBillingStatus: { + required: false, + serializedName: 'properties.subscriptionBillingStatus', + type: { + name: 'String' + } + }, + lastMonthCharges: { + required: false, + readOnly: true, + serializedName: 'properties.lastMonthCharges', + type: { + name: 'Composite', + className: 'Amount' + } + }, + monthToDateCharges: { + required: false, + readOnly: true, + serializedName: 'properties.monthToDateCharges', + type: { + name: 'Composite', + className: 'Amount' + } + }, + enrollmentAccountContext: { + required: false, + readOnly: true, + serializedName: 'properties.enrollmentAccountContext', + type: { + name: 'Composite', + className: 'EnrollmentAccountContext' + } + }, + billingProfileId: { + required: false, + readOnly: true, + serializedName: 'properties.billingProfileId', + type: { + name: 'String' + } + }, + billingProfileName: { + required: false, + readOnly: true, + serializedName: 'properties.billingProfileName', + type: { + name: 'String' + } + }, + skuId: { + required: false, + serializedName: 'properties.skuId', + type: { + name: 'String' + } + }, + skuDescription: { + required: false, + readOnly: true, + serializedName: 'properties.skuDescription', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = BillingSubscriptionSummary; diff --git a/lib/services/billingManagement/lib/models/billingSubscriptionsListResult.js b/lib/services/billingManagement/lib/models/billingSubscriptionsListResult.js new file mode 100644 index 0000000000..b5abc23e44 --- /dev/null +++ b/lib/services/billingManagement/lib/models/billingSubscriptionsListResult.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 billing subscriptions summary. + */ +class BillingSubscriptionsListResult extends Array { + /** + * Create a BillingSubscriptionsListResult. + * @property {string} [nextLink] The link (url) to the next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of BillingSubscriptionsListResult + * + * @returns {object} metadata of BillingSubscriptionsListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'BillingSubscriptionsListResult', + type: { + name: 'Composite', + className: 'BillingSubscriptionsListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'BillingSubscriptionSummaryElementType', + type: { + name: 'Composite', + className: 'BillingSubscriptionSummary' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = BillingSubscriptionsListResult; diff --git a/lib/services/billingManagement/lib/models/department.js b/lib/services/billingManagement/lib/models/department.js new file mode 100644 index 0000000000..eb3cdd9354 --- /dev/null +++ b/lib/services/billingManagement/lib/models/department.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'); + +/** + * A department resource. + * + * @extends models['Resource'] + */ +class Department extends models['Resource'] { + /** + * Create a Department. + * @property {string} [departmentName] The name for department. + * @property {string} [costCenter] The cost center name. + * @property {string} [status] The status for department. + * @property {array} [enrollmentAccounts] Associated enrollment accounts. By + * default this is not populated, unless it's specified in $expand. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Department + * + * @returns {object} metadata of Department + * + */ + mapper() { + return { + required: false, + serializedName: 'Department', + type: { + name: 'Composite', + className: 'Department', + 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' + } + }, + departmentName: { + required: false, + serializedName: 'properties.departmentName', + type: { + name: 'String' + } + }, + costCenter: { + required: false, + serializedName: 'properties.costCenter', + type: { + name: 'String' + } + }, + status: { + required: false, + serializedName: 'properties.status', + type: { + name: 'String' + } + }, + enrollmentAccounts: { + required: false, + serializedName: 'properties.enrollmentAccounts', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'EnrollmentAccountElementType', + type: { + name: 'Composite', + className: 'EnrollmentAccount' + } + } + } + } + } + } + }; + } +} + +module.exports = Department; diff --git a/lib/services/billingManagement/lib/models/departmentListResult.js b/lib/services/billingManagement/lib/models/departmentListResult.js new file mode 100644 index 0000000000..040e76608b --- /dev/null +++ b/lib/services/billingManagement/lib/models/departmentListResult.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 departments. + * + */ +class DepartmentListResult { + /** + * Create a DepartmentListResult. + * @property {array} [value] The list of departments. + * @property {string} [nextLink] The link (url) to the next page of results. + */ + constructor() { + } + + /** + * Defines the metadata of DepartmentListResult + * + * @returns {object} metadata of DepartmentListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'DepartmentListResult', + type: { + name: 'Composite', + className: 'DepartmentListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: 'value', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'DepartmentElementType', + type: { + name: 'Composite', + className: 'Department' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = DepartmentListResult; diff --git a/lib/services/billingManagement/lib/models/downloadProperties.js b/lib/services/billingManagement/lib/models/downloadProperties.js new file mode 100644 index 0000000000..1ccd503544 --- /dev/null +++ b/lib/services/billingManagement/lib/models/downloadProperties.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 properties of the invoice download. + * + */ +class DownloadProperties { + /** + * Create a DownloadProperties. + * @property {string} [kind] Document type. Possible values include: + * 'Invoice', 'VoidNote', 'Receipt', 'CreditNote' + * @property {string} [url] Document URL. + */ + constructor() { + } + + /** + * Defines the metadata of DownloadProperties + * + * @returns {object} metadata of DownloadProperties + * + */ + mapper() { + return { + required: false, + serializedName: 'DownloadProperties', + type: { + name: 'Composite', + className: 'DownloadProperties', + modelProperties: { + kind: { + required: false, + readOnly: true, + serializedName: 'kind', + type: { + name: 'String' + } + }, + url: { + required: false, + readOnly: true, + serializedName: 'url', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = DownloadProperties; diff --git a/lib/services/billingManagement/lib/models/downloadUrl.js b/lib/services/billingManagement/lib/models/downloadUrl.js index 00c621b26c..fe7ed974b5 100644 --- a/lib/services/billingManagement/lib/models/downloadUrl.js +++ b/lib/services/billingManagement/lib/models/downloadUrl.js @@ -11,16 +11,15 @@ 'use strict'; /** - * A secure URL that can be used to download a PDF invoice until the URL - * expires. + * A secure URL that can be used to download a an entity until the URL expires. * */ class DownloadUrl { /** * Create a DownloadUrl. - * @member {date} [expiryTime] The time in UTC at which this download URL + * @property {date} [expiryTime] The time in UTC at which this download URL * will expire. - * @member {string} [url] The URL to the PDF file. + * @property {string} [url] The URL to the PDF file. */ constructor() { } diff --git a/lib/services/billingManagement/lib/models/enabledAzureSKUs.js b/lib/services/billingManagement/lib/models/enabledAzureSKUs.js new file mode 100644 index 0000000000..198c0edbd1 --- /dev/null +++ b/lib/services/billingManagement/lib/models/enabledAzureSKUs.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'; + +/** + * Details about the product. + * + */ +class EnabledAzureSKUs { + /** + * Create a EnabledAzureSKUs. + * @property {string} [skuId] The sku id. + * @property {string} [skuDescription] The sku description. + */ + constructor() { + } + + /** + * Defines the metadata of EnabledAzureSKUs + * + * @returns {object} metadata of EnabledAzureSKUs + * + */ + mapper() { + return { + required: false, + serializedName: 'EnabledAzureSKUs', + type: { + name: 'Composite', + className: 'EnabledAzureSKUs', + modelProperties: { + skuId: { + required: false, + serializedName: 'skuId', + type: { + name: 'String' + } + }, + skuDescription: { + required: false, + readOnly: true, + serializedName: 'skuDescription', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = EnabledAzureSKUs; diff --git a/lib/services/billingManagement/lib/models/enrollment.js b/lib/services/billingManagement/lib/models/enrollment.js new file mode 100644 index 0000000000..26e0ff8204 --- /dev/null +++ b/lib/services/billingManagement/lib/models/enrollment.js @@ -0,0 +1,133 @@ +/* + * 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'; + +/** + * Current entity level details + * + */ +class Enrollment { + /** + * Create a Enrollment. + * @property {date} [startDate] Enrollment Start Date + * @property {date} [endDate] Enrollment End Date + * @property {string} [currency] The currency associated with enrollment + * @property {string} [channel] The channel for Enrollment + * @property {object} [policies] The attributes associated with legacy + * enrollment. + * @property {boolean} [policies.accountOwnerViewCharges] The + * accountOwnerViewCharges flag for Enrollment + * @property {boolean} [policies.departmentAdminViewCharges] The + * departmentAdminViewCharges flag for Enrollment + * @property {boolean} [policies.marketplacesEnabled] The marketplaces flag + * for Enrollment + * @property {boolean} [policies.reservedInstancesEnabled] The reserved + * instances flag for Enrollment + * @property {string} [language] The language for Enrollment + * @property {string} [countryCode] The countryCode for Enrollment + * @property {string} [status] Enrollment status + * @property {string} [billingCylce] Enrollment billing cycle + */ + constructor() { + } + + /** + * Defines the metadata of Enrollment + * + * @returns {object} metadata of Enrollment + * + */ + mapper() { + return { + required: false, + serializedName: 'Enrollment', + type: { + name: 'Composite', + className: 'Enrollment', + modelProperties: { + startDate: { + required: false, + serializedName: 'startDate', + type: { + name: 'DateTime' + } + }, + endDate: { + required: false, + serializedName: 'endDate', + type: { + name: 'DateTime' + } + }, + currency: { + required: false, + readOnly: true, + serializedName: 'currency', + type: { + name: 'String' + } + }, + channel: { + required: false, + readOnly: true, + serializedName: 'channel', + type: { + name: 'String' + } + }, + policies: { + required: false, + readOnly: true, + serializedName: 'policies', + type: { + name: 'Composite', + className: 'EnrollmentPolicies' + } + }, + language: { + required: false, + readOnly: true, + serializedName: 'language', + type: { + name: 'String' + } + }, + countryCode: { + required: false, + readOnly: true, + serializedName: 'countryCode', + type: { + name: 'String' + } + }, + status: { + required: false, + readOnly: true, + serializedName: 'status', + type: { + name: 'String' + } + }, + billingCylce: { + required: false, + readOnly: true, + serializedName: 'billingCylce', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = Enrollment; diff --git a/lib/services/billingManagement/lib/models/enrollmentAccount.js b/lib/services/billingManagement/lib/models/enrollmentAccount.js index e4587b9894..5e57e84d88 100644 --- a/lib/services/billingManagement/lib/models/enrollmentAccount.js +++ b/lib/services/billingManagement/lib/models/enrollmentAccount.js @@ -13,14 +13,27 @@ const models = require('./index'); /** - * An enrollment account resource. + * An account resource. * * @extends models['Resource'] */ class EnrollmentAccount extends models['Resource'] { /** * Create a EnrollmentAccount. - * @member {string} [principalName] The account owner's principal name. + * @property {string} [accountName] The account name. + * @property {string} [costCenter] The cost center name. + * @property {string} [accountOwner] The account owner + * @property {string} [status] The status for account. + * @property {date} [startDate] Account Start Date + * @property {date} [endDate] Account End Date + * @property {object} [department] Associated department. By default this is + * not populated, unless it's specified in $expand. + * @property {string} [department.departmentName] The name for department. + * @property {string} [department.costCenter] The cost center name. + * @property {string} [department.status] The status for department. + * @property {array} [department.enrollmentAccounts] Associated enrollment + * accounts. By default this is not populated, unless it's specified in + * $expand. */ constructor() { super(); @@ -64,13 +77,55 @@ class EnrollmentAccount extends models['Resource'] { name: 'String' } }, - principalName: { + accountName: { required: false, - readOnly: true, - serializedName: 'properties.principalName', + serializedName: 'properties.accountName', + type: { + name: 'String' + } + }, + costCenter: { + required: false, + serializedName: 'properties.costCenter', + type: { + name: 'String' + } + }, + accountOwner: { + required: false, + serializedName: 'properties.accountOwner', + type: { + name: 'String' + } + }, + status: { + required: false, + serializedName: 'properties.status', type: { name: 'String' } + }, + startDate: { + required: false, + serializedName: 'properties.startDate', + type: { + name: 'DateTime' + } + }, + endDate: { + required: false, + serializedName: 'properties.endDate', + type: { + name: 'DateTime' + } + }, + department: { + required: false, + serializedName: 'properties.department', + type: { + name: 'Composite', + className: 'Department' + } } } } diff --git a/lib/services/billingManagement/lib/models/enrollmentAccountContext.js b/lib/services/billingManagement/lib/models/enrollmentAccountContext.js new file mode 100644 index 0000000000..b326cea898 --- /dev/null +++ b/lib/services/billingManagement/lib/models/enrollmentAccountContext.js @@ -0,0 +1,76 @@ +/* + * 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 rating context. + * + */ +class EnrollmentAccountContext { + /** + * Create a EnrollmentAccountContext. + * @property {string} [costCenter] The cost center name. + * @property {date} [startDate] Account Start Date + * @property {date} [endDate] Account End Date + * @property {string} [enrollmentAccountId] The enrollment account id. + */ + constructor() { + } + + /** + * Defines the metadata of EnrollmentAccountContext + * + * @returns {object} metadata of EnrollmentAccountContext + * + */ + mapper() { + return { + required: false, + serializedName: 'EnrollmentAccountContext', + type: { + name: 'Composite', + className: 'EnrollmentAccountContext', + modelProperties: { + costCenter: { + required: false, + serializedName: 'costCenter', + type: { + name: 'String' + } + }, + startDate: { + required: false, + serializedName: 'startDate', + type: { + name: 'DateTime' + } + }, + endDate: { + required: false, + serializedName: 'endDate', + type: { + name: 'DateTime' + } + }, + enrollmentAccountId: { + required: false, + serializedName: 'enrollmentAccountId', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = EnrollmentAccountContext; diff --git a/lib/services/billingManagement/lib/models/enrollmentAccountListResult.js b/lib/services/billingManagement/lib/models/enrollmentAccountListResult.js index d84e7e4399..1ff21e6762 100644 --- a/lib/services/billingManagement/lib/models/enrollmentAccountListResult.js +++ b/lib/services/billingManagement/lib/models/enrollmentAccountListResult.js @@ -12,14 +12,15 @@ /** * Result of listing enrollment accounts. + * */ -class EnrollmentAccountListResult extends Array { +class EnrollmentAccountListResult { /** * Create a EnrollmentAccountListResult. - * @member {string} [nextLink] The link (url) to the next page of results. + * @property {array} [value] The list of enrollment accounts. + * @property {string} [nextLink] The link (url) to the next page of results. */ constructor() { - super(); } /** @@ -39,7 +40,7 @@ class EnrollmentAccountListResult extends Array { value: { required: false, readOnly: true, - serializedName: '', + serializedName: 'value', type: { name: 'Sequence', element: { diff --git a/lib/services/billingManagement/lib/models/enrollmentPolicies.js b/lib/services/billingManagement/lib/models/enrollmentPolicies.js new file mode 100644 index 0000000000..9c6dbeb19f --- /dev/null +++ b/lib/services/billingManagement/lib/models/enrollmentPolicies.js @@ -0,0 +1,84 @@ +/* + * 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 attributes associated with legacy enrollment + * + */ +class EnrollmentPolicies { + /** + * Create a EnrollmentPolicies. + * @property {boolean} [accountOwnerViewCharges] The accountOwnerViewCharges + * flag for Enrollment + * @property {boolean} [departmentAdminViewCharges] The + * departmentAdminViewCharges flag for Enrollment + * @property {boolean} [marketplacesEnabled] The marketplaces flag for + * Enrollment + * @property {boolean} [reservedInstancesEnabled] The reserved instances flag + * for Enrollment + */ + constructor() { + } + + /** + * Defines the metadata of EnrollmentPolicies + * + * @returns {object} metadata of EnrollmentPolicies + * + */ + mapper() { + return { + required: false, + serializedName: 'EnrollmentPolicies', + type: { + name: 'Composite', + className: 'EnrollmentPolicies', + modelProperties: { + accountOwnerViewCharges: { + required: false, + readOnly: true, + serializedName: 'accountOwnerViewCharges', + type: { + name: 'Boolean' + } + }, + departmentAdminViewCharges: { + required: false, + readOnly: true, + serializedName: 'departmentAdminViewCharges', + type: { + name: 'Boolean' + } + }, + marketplacesEnabled: { + required: false, + readOnly: true, + serializedName: 'marketplacesEnabled', + type: { + name: 'Boolean' + } + }, + reservedInstancesEnabled: { + required: false, + readOnly: true, + serializedName: 'reservedInstancesEnabled', + type: { + name: 'Boolean' + } + } + } + } + }; + } +} + +module.exports = EnrollmentPolicies; diff --git a/lib/services/billingManagement/lib/models/errorDetails.js b/lib/services/billingManagement/lib/models/errorDetails.js index ffdd5a5df0..cbaec9ce69 100644 --- a/lib/services/billingManagement/lib/models/errorDetails.js +++ b/lib/services/billingManagement/lib/models/errorDetails.js @@ -17,10 +17,10 @@ class ErrorDetails { /** * Create a ErrorDetails. - * @member {string} [code] Error code. - * @member {string} [message] Error message indicating why the operation + * @property {string} [code] Error code. + * @property {string} [message] Error message indicating why the operation * failed. - * @member {string} [target] The target of the particular error. + * @property {string} [target] The target of the particular error. */ constructor() { } diff --git a/lib/services/billingManagement/lib/models/errorResponse.js b/lib/services/billingManagement/lib/models/errorResponse.js index 5dfae6f5d3..dbbd68693f 100644 --- a/lib/services/billingManagement/lib/models/errorResponse.js +++ b/lib/services/billingManagement/lib/models/errorResponse.js @@ -10,8 +10,6 @@ '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. @@ -20,11 +18,11 @@ const models = require('./index'); 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 + * @property {object} [error] The details of the error. + * @property {string} [error.code] Error code. + * @property {string} [error.message] Error message indicating why the * operation failed. - * @member {string} [error.target] The target of the particular error. + * @property {string} [error.target] The target of the particular error. */ constructor() { } diff --git a/lib/services/billingManagement/lib/models/index.d.ts b/lib/services/billingManagement/lib/models/index.d.ts index 31c9232006..0e8c84e0ca 100644 --- a/lib/services/billingManagement/lib/models/index.d.ts +++ b/lib/services/billingManagement/lib/models/index.d.ts @@ -1,227 +1,1037 @@ /* * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * 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. + * 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'; +import { BaseResource, CloudError } from "ms-rest-azure"; +import * as moment from "moment"; -export { BaseResource } from 'ms-rest-azure'; -export { CloudError } from 'ms-rest-azure'; +export { + BaseResource, + CloudError +}; + +/** + * The properties of the product to initiate a transfer. + */ +export interface TransferProductRequestProperties { + /** + * Destination invoice section id. + */ + destinationInvoiceSectionId?: string; +} + +/** + * Request parameters to transfer billing subscription. + */ +export interface TransferBillingSubscriptionResult { + /** + * The destination billing subscription id. + */ + billingSubscriptionId?: string; +} + +/** + * Request parameters to transfer billing subscription. + */ +export interface TransferBillingSubscriptionRequestProperties { + /** + * The destination invoiceSectionId. + */ + destinationInvoiceSectionId?: string; +} + +/** + * Request parameters to transfer billing subscription. + */ +export interface TransferBillingSubscriptionRequest { + /** + * The destination invoiceSectionId. + */ + destinationInvoiceSectionId?: string; +} + +/** + * Summary of cancel product operation + */ +export interface UpdateAutoRenewOperationSummary { + /** + * The end date of this asset + */ + endDate?: Date; +} + +/** + * Address details. + */ +export interface Address { + /** + * First Name. + */ + firstName?: string; + /** + * Last Name. + */ + lastName?: string; + /** + * Company Name. + */ + companyName?: string; + /** + * Address Line1. + */ + addressLine1?: string; + /** + * Address Line2. + */ + addressLine2?: string; + /** + * Address Line3. + */ + addressLine3?: string; + /** + * Address City. + */ + city?: string; + /** + * Address Region. + */ + region?: string; + /** + * Country code uses ISO2, 2-digit format. + */ + country?: string; + /** + * Address Postal Code. + */ + postalCode?: string; +} + +/** + * Details about the product. + */ +export interface EnabledAzureSKUs { + /** + * The sku id. + */ + skuId?: string; + /** + * The sku description. + */ + readonly skuDescription?: string; +} /** - * @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. */ export interface Resource extends BaseResource { + /** + * Resource Id. + */ readonly id?: string; + /** + * Resource name. + */ readonly name?: string; + /** + * Resource type. + */ readonly type?: string; } /** - * @class - * Initializes a new instance of the EnrollmentAccount class. - * @constructor - * An enrollment account resource. - * - * @member {string} [principalName] The account owner's principal name. + * A billing profile resource. + */ +export interface BillingProfile extends Resource { + /** + * The billing profile name. + */ + displayName?: string; + /** + * Purchase order number. + */ + poNumber?: string; + /** + * Billing address. + */ + billingAddress?: Address; + /** + * If the billing profile is opted in to recieve invoices via email. + */ + readonly invoiceEmailOptIn?: boolean; + /** + * Is OMS bootstrapped billing profile. + */ + readonly isClassic?: boolean; + /** + * Invoice day. + */ + readonly invoiceDay?: number; + /** + * The currency associated with the billing profile. + */ + readonly currency?: string; + /** + * Information about the product. + */ + enabledAzureSKUs?: EnabledAzureSKUs[]; + /** + * The invoice sections associated to the billing profile. + */ + invoiceSections?: InvoiceSection[]; +} + +/** + * The properties of an InvoiceSection. + */ +export interface InvoiceSectionProperties { + /** + * The name of the InvoiceSection. + */ + displayName?: string; + /** + * The billing profiles associated to the billing account. + */ + billingProfiles?: BillingProfile[]; +} + +/** + * An InvoiceSection resource. + */ +export interface InvoiceSection extends Resource { + /** + * The name of the InvoiceSection. + */ + displayName?: string; + /** + * The billing profiles associated to the billing account. + */ + billingProfiles?: BillingProfile[]; +} + +/** + * The attributes associated with legacy enrollment + */ +export interface EnrollmentPolicies { + /** + * The accountOwnerViewCharges flag for Enrollment + */ + readonly accountOwnerViewCharges?: boolean; + /** + * The departmentAdminViewCharges flag for Enrollment + */ + readonly departmentAdminViewCharges?: boolean; + /** + * The marketplaces flag for Enrollment + */ + readonly marketplacesEnabled?: boolean; + /** + * The reserved instances flag for Enrollment + */ + readonly reservedInstancesEnabled?: boolean; +} + +/** + * Current entity level details + */ +export interface Enrollment { + /** + * Enrollment Start Date + */ + startDate?: Date; + /** + * Enrollment End Date + */ + endDate?: Date; + /** + * The currency associated with enrollment + */ + readonly currency?: string; + /** + * The channel for Enrollment + */ + readonly channel?: string; + /** + * The attributes associated with legacy enrollment. + */ + readonly policies?: EnrollmentPolicies; + /** + * The language for Enrollment + */ + readonly language?: string; + /** + * The countryCode for Enrollment + */ + readonly countryCode?: string; + /** + * Enrollment status + */ + readonly status?: string; + /** + * Enrollment billing cycle + */ + readonly billingCylce?: string; +} + +/** + * An account resource. */ export interface EnrollmentAccount extends Resource { - readonly principalName?: string; + /** + * The account name. + */ + accountName?: string; + /** + * The cost center name. + */ + costCenter?: string; + /** + * The account owner + */ + accountOwner?: string; + /** + * The status for account. + */ + status?: string; + /** + * Account Start Date + */ + startDate?: Date; + /** + * Account End Date + */ + endDate?: Date; + /** + * Associated department. By default this is not populated, unless it's specified in $expand. + */ + department?: Department; } /** - * @class - * Initializes a new instance of the BillingPeriod class. - * @constructor - * A billing period resource. - * - * @member {date} [billingPeriodStartDate] The start of the date range covered - * by the billing period. - * @member {date} [billingPeriodEndDate] The end of the date range covered by - * the billing period. - * @member {array} [invoiceIds] Array of invoice ids that associated with. + * A department resource. */ -export interface BillingPeriod extends Resource { - readonly billingPeriodStartDate?: Date; - readonly billingPeriodEndDate?: Date; - readonly invoiceIds?: string[]; +export interface Department extends Resource { + /** + * The name for department. + */ + departmentName?: string; + /** + * The cost center name. + */ + costCenter?: string; + /** + * The status for department. + */ + status?: string; + /** + * Associated enrollment accounts. By default this is not populated, unless it's specified in + * $expand. + */ + enrollmentAccounts?: EnrollmentAccount[]; } /** - * @class - * Initializes a new instance of the DownloadUrl class. - * @constructor - * A secure URL that can be used to download a PDF invoice until the URL - * expires. - * - * @member {date} [expiryTime] The time in UTC at which this download URL will - * expire. - * @member {string} [url] The URL to the PDF file. + * A billing account resource. + */ +export interface BillingAccount extends Resource { + /** + * The billing account name. + */ + readonly displayName?: string; + /** + * The Company this billing account belongs to. + */ + readonly company?: string; + /** + * The billing account Type. Possible values include: 'Organization', 'Enrollment' + */ + readonly accountType?: string; + /** + * The address associated with billing account. + */ + address?: Address; + /** + * The country associated with billing account.. + */ + readonly country?: string; + /** + * The invoice sections associated to the billing account. + */ + invoiceSections?: InvoiceSection[]; + /** + * The billing profiles associated to the billing account. + */ + billingProfiles?: BillingProfile[]; + /** + * The details about the associated legacy enrollment. By default this is not populated, unless + * it's specified in $expand. + */ + readonly enrollmentDetails?: Enrollment; + /** + * The departments associated to the enrollment. + */ + departments?: Department[]; + /** + * The accounts associated to the enrollment. + */ + enrollmentAccounts?: EnrollmentAccount[]; +} + +/** + * Result of listing billing accounts. + */ +export interface BillingAccountListResult { + /** + * The list of billing accounts. + */ + readonly value?: BillingAccount[]; + /** + * The link (url) to the next page of results. + */ + readonly nextLink?: string; +} + +/** + * The billing property. + */ +export interface BillingProperty { + /** + * Product Id. + */ + readonly productId?: string; + /** + * Billing tenant Id. + */ + readonly billingTenantId?: string; + /** + * Billing account Id. + */ + readonly billingAccountId?: string; + /** + * Billing account name. + */ + readonly billingAccountName?: string; + /** + * Billing profile Id. + */ + readonly billingProfileId?: string; + /** + * Billing profile name. + */ + readonly billingProflieName?: string; + /** + * Invoice Section Id. + */ + readonly invoiceSectionId?: string; + /** + * Invoice Section name. + */ + readonly invoiceSectionName?: string; + /** + * SKU Id. + */ + readonly skuId?: string; + /** + * SKU description. + */ + readonly skuDescription?: string; +} + +/** + * Result of listing departments. + */ +export interface DepartmentListResult { + /** + * The list of departments. + */ + readonly value?: Department[]; + /** + * The link (url) to the next page of results. + */ + readonly nextLink?: string; +} + +/** + * Result of listing enrollment accounts. + */ +export interface EnrollmentAccountListResult { + /** + * The list of enrollment accounts. + */ + readonly value?: EnrollmentAccount[]; + /** + * The link (url) to the next page of results. + */ + readonly nextLink?: string; +} + +/** + * Result of listing billing profiles. + */ +export interface BillingProfileListResult { + /** + * The list of billing profiles. + */ + readonly value?: BillingProfile[]; + /** + * The link (url) to the next page of results. + */ + readonly nextLink?: string; +} + +/** + * Result of listing invoice sections. + */ +export interface InvoiceSectionListResult { + /** + * The list of invoice sections. + */ + readonly value?: InvoiceSection[]; + /** + * The link (url) to the next page of results. + */ + readonly nextLink?: string; +} + +/** + * status of the Billing POST/PUT operation. + */ +export interface OperationStatus { + /** + * The operation Id. + */ + readonly id?: string; + /** + * Status of the pending operation + */ + status?: string; + /** + * Status Detail of the pending operation + */ + statusDetail?: string; +} + +/** + * A secure URL that can be used to download a an entity until the URL expires. */ export interface DownloadUrl { + /** + * The time in UTC at which this download URL will expire. + */ readonly expiryTime?: Date; + /** + * The URL to the PDF file. + */ readonly url?: string; } /** - * @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. - * @member {string} [target] The target of the particular error. */ export interface ErrorDetails { + /** + * Error code. + */ readonly code?: string; + /** + * Error message indicating why the operation failed. + */ readonly message?: string; + /** + * The target of the particular error. + */ readonly target?: 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. - * @member {string} [error.target] The target of the particular error. + * Error response indicates that the service is not able to process the incoming request. The + * reason is provided in the error message. */ export interface ErrorResponse { + /** + * The details of the error. + */ error?: ErrorDetails; } /** - * @class - * Initializes a new instance of the Invoice class. - * @constructor - * An invoice resource can be used download a PDF version of an invoice. - * - * @member {object} [downloadUrl] A secure link to download the PDF version of - * an invoice. The link will cease to work after its expiry time is reached. - * @member {date} [downloadUrl.expiryTime] The time in UTC at which this - * download URL will expire. - * @member {string} [downloadUrl.url] The URL to the PDF file. - * @member {date} [invoicePeriodStartDate] The start of the date range covered - * by the invoice. - * @member {date} [invoicePeriodEndDate] The end of the date range covered by - * the invoice. - * @member {array} [billingPeriodIds] Array of billing perdiod ids that the - * invoice is attributed to. - */ -export interface Invoice extends Resource { - downloadUrl?: DownloadUrl; + * The Amount. + */ +export interface Amount { + /** + * The currency for the amount value. + */ + readonly currency?: string; + /** + * Amount value. + */ + readonly value?: number; +} + +/** + * The properties of the invoice download. + */ +export interface DownloadProperties { + /** + * Document type. Possible values include: 'Invoice', 'VoidNote', 'Receipt', 'CreditNote' + */ + readonly kind?: string; + /** + * Document URL. + */ + readonly url?: string; +} + +/** + * The properties of the payment. + */ +export interface PaymentProperties { + /** + * The type of payment. + */ + readonly paymentType?: string; + /** + * The paid amount. + */ + readonly amount?: Amount; + /** + * The date of the payment. + */ + readonly date?: Date; +} + +/** + * An invoice resource. + */ +export interface InvoiceSummary extends Resource { + /** + * The due date for invoice. + */ + readonly dueDate?: Date; + /** + * The date when invoice was created. + */ + readonly invoiceDate?: Date; + /** + * Invoice status. Possible values include: 'PastDue', 'Due', 'Paid', 'Void' + */ + readonly status?: string; + /** + * Amount due. + */ + readonly amountDue?: Amount; + /** + * Amount billed. + */ + readonly billedAmount?: Amount; + /** + * The start date of the billing period. + */ readonly invoicePeriodStartDate?: Date; + /** + * The end date of the billing period. + */ readonly invoicePeriodEndDate?: Date; - readonly billingPeriodIds?: string[]; + /** + * The profile id which invoice belongs to. + */ + readonly billingProfile?: string; + /** + * The profile name which invoice belongs to. + */ + readonly billingProfileName?: string; + /** + * The purchase identifier for the invoice. + */ + readonly purchaseOrderNumber?: string; + /** + * List of document urls available to download including invoice and tax documents. + */ + readonly documentUrls?: DownloadProperties[]; + /** + * List of payments. + */ + readonly payments?: PaymentProperties[]; +} + +/** + * Result of listing invoices. + */ +export interface InvoiceListResult { + /** + * The list of invoices. + */ + readonly value?: InvoiceSummary[]; + /** + * The link (url) to the next page of results. + */ + readonly nextLink?: string; +} + +/** + * A product summary resource. + */ +export interface ProductSummary extends Resource { + /** + * The display name of the product. + */ + readonly displayName?: string; + /** + * The date of purchase. + */ + readonly purchaseDate?: Date; + /** + * The product type id. + */ + readonly productTypeId?: string; + /** + * The type of product. + */ + readonly productType?: string; + /** + * Product status. Possible values include: 'Active', 'Inactive', 'PastDue', 'Expiring', + * 'Expired', 'Disabled', 'Cancelled', 'AutoRenew' + */ + status?: string; + /** + * end date. + */ + readonly endDate?: Date; + /** + * Billing frequency. Possible values include: 'OneTime', 'Monthly', 'UsageBased' + */ + billingFrequency?: string; + /** + * Last month charges. + */ + readonly lastCharge?: Amount; + /** + * The date of the last charge. + */ + readonly lastChargeDate?: Date; + /** + * The purchased product quantity. + */ + readonly quantity?: number; + /** + * Sku Id. + */ + readonly skuId?: string; + /** + * Sku description. + */ + readonly skuDescription?: string; + /** + * Availability Id. + */ + readonly availabilityId?: string; + /** + * Parent Product Id. + */ + readonly parentProductId?: string; + /** + * Invoice section id to which this product belongs. + */ + readonly invoiceSectionId?: string; + /** + * Invoice section name to which this product belongs. + */ + readonly invoiceSectionName?: string; + /** + * Billing Profile id to which this product belongs. + */ + readonly billingProfileId?: string; + /** + * Billing Profile name to which this product belongs. + */ + readonly billingProfileName?: string; +} + +/** + * The rating context. + */ +export interface EnrollmentAccountContext { + /** + * The cost center name. + */ + costCenter?: string; + /** + * Account Start Date + */ + startDate?: Date; + /** + * Account End Date + */ + endDate?: Date; + /** + * The enrollment account id. + */ + enrollmentAccountId?: string; +} + +/** + * A billing Subscription summary resource. + */ +export interface BillingSubscriptionSummary extends Resource { + /** + * display name. + */ + readonly displayName?: string; + /** + * Subscription Id. + */ + readonly subscriptionId?: string; + /** + * Subscription billing status. Possible values include: 'Active', 'Inactive', 'Abandoned', + * 'Deleted', 'Warning' + */ + subscriptionBillingStatus?: string; + /** + * Last month charges. + */ + readonly lastMonthCharges?: Amount; + /** + * Month to date charges. + */ + readonly monthToDateCharges?: Amount; + /** + * The enrollment account context. + */ + readonly enrollmentAccountContext?: EnrollmentAccountContext; + /** + * Billing Profile id to which this product belongs. + */ + readonly billingProfileId?: string; + /** + * Billing Profile name to which this product belongs. + */ + readonly billingProfileName?: string; + /** + * The sku id. + */ + skuId?: string; + /** + * The sku description. + */ + readonly skuDescription?: string; +} + +/** + * A reservation transaction summary resource. + */ +export interface TransactionsSummary extends Resource { + /** + * The kind of transaction. Choices are all and reservation. Possible values include: 'all', + * 'reservation' + */ + kind?: string; + /** + * The date of reservation transaction. + */ + readonly date?: Date; + /** + * Invoice number or 'pending' if not invoiced. + */ + readonly invoice?: string; + /** + * The reservation order id. + */ + readonly orderId?: string; + /** + * The reservation order name. + */ + readonly orderName?: string; + /** + * The product type id. + */ + readonly productTypeId?: string; + /** + * The type of product. + */ + readonly productType?: string; + /** + * Product description. + */ + readonly productDescription?: string; + /** + * Transaction types. Possible values include: 'Purchase', 'Usage Charge' + */ + transactionType?: string; + /** + * Last charge associated with the purchase. + */ + readonly transactionAmount?: Amount; + /** + * Purchase quantity. + */ + readonly quantity?: number; + /** + * Invoice section id to which this product belongs. + */ + readonly invoiceSectionId?: string; + /** + * Invoice section name to which this product belongs. + */ + readonly invoiceSectionName?: string; + /** + * Billing Profile id to which this product belongs. + */ + readonly billingProfileId?: string; + /** + * Billing Profile name to which this product belongs. + */ + readonly billingProfileName?: string; + /** + * The subscription id. + */ + readonly subscriptionId?: string; + /** + * The subscription name. + */ + readonly subscriptionName?: string; +} + +/** + * The Policy. + */ +export interface Policy extends Resource { + /** + * The reservationPurchasesAllowed flag. + */ + reservationPurchasesAllowed?: boolean; + /** + * The marketplacePurchasesAllowed flag. + */ + marketplacePurchasesAllowed?: boolean; +} + +/** + * Latest available balance on Monetary Credit PI. + */ +export interface AvailableBalance extends Resource { + /** + * Balance Amount. + */ + readonly amount?: Amount; +} + +/** + * A payment method resource. + */ +export interface PaymentMethod extends Resource { + /** + * Payment method type. Possible values include: 'Credits', 'ChequeWire' + */ + methodType?: string; + /** + * Details about the payment method. + */ + readonly details?: string; + /** + * Expiration date. + */ + readonly expiration?: Date; + /** + * The currency associated with the payment method. + */ + readonly currency?: string; +} + +/** + * Request parameters to update auto renew for support prouct. + */ +export interface UpdateAutoRenewRequest { + /** + * Request parameters to update auto renew policy a product. Possible values include: 'true', + * 'false' + */ + autoRenew?: string; } /** - * @class - * Initializes a new instance of the OperationDisplay class. - * @constructor * The object that represents the operation. - * - * @member {string} [provider] Service provider: Microsoft.Billing. - * @member {string} [resource] Resource on which the operation is performed: - * Invoice, etc. - * @member {string} [operation] Operation type: Read, write, delete, etc. */ export interface OperationDisplay { + /** + * Service provider: Microsoft.Billing. + */ readonly provider?: string; + /** + * Resource on which the operation is performed: Invoice, etc. + */ readonly resource?: string; + /** + * Operation type: Read, write, delete, etc. + */ readonly operation?: string; } /** - * @class - * Initializes a new instance of the Operation class. - * @constructor * A Billing 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.Billing. - * @member {string} [display.resource] Resource on which the operation is - * performed: Invoice, etc. - * @member {string} [display.operation] Operation type: Read, write, delete, - * etc. */ export interface Operation { + /** + * Operation name: {provider}/{resource}/{operation}. + */ readonly name?: string; + /** + * The object that represents the operation. + */ display?: OperationDisplay; } +/** + * Result of listing payment methods. + */ +export interface PaymentMethodsListResult extends Array { + /** + * The link (url) to the next page of results. + */ + readonly nextLink?: string; +} /** - * @class - * Initializes a new instance of the EnrollmentAccountListResult class. - * @constructor - * Result of listing enrollment accounts. - * - * @member {string} [nextLink] The link (url) to the next page of results. + * Result of listing billing subscriptions summary. */ -export interface EnrollmentAccountListResult extends Array { +export interface BillingSubscriptionsListResult extends Array { + /** + * The link (url) to the next page of results. + */ readonly nextLink?: string; } /** - * @class - * Initializes a new instance of the BillingPeriodsListResult class. - * @constructor - * Result of listing billing periods. It contains a list of available billing - * periods in reverse chronological order. - * - * @member {string} [nextLink] The link (url) to the next page of results. + * Result of listing products summary. It contains a list of available products summaries in + * reverse chronological order by purchase date. */ -export interface BillingPeriodsListResult extends Array { +export interface ProductsListResult extends Array { + /** + * The link (url) to the next page of results. + */ readonly nextLink?: string; } /** - * @class - * Initializes a new instance of the InvoicesListResult class. - * @constructor - * Result of listing invoices. It contains a list of available invoices in - * reverse chronological order. - * - * @member {string} [nextLink] The link (url) to the next page of results. + * Result of listing reservation transactions summary. */ -export interface InvoicesListResult extends Array { +export interface TransactionsListResult extends Array { + /** + * The link (url) to the next page of results. + */ readonly nextLink?: string; } /** - * @class - * Initializes a new instance of the OperationListResult class. - * @constructor - * Result listing billing 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. + * Result listing billing operations. It contains a list of operations and a URL link to get the + * next set of results. */ export interface OperationListResult extends Array { + /** + * URL to get the next set of operation list results if there are any. + */ readonly nextLink?: string; } diff --git a/lib/services/billingManagement/lib/models/index.js b/lib/services/billingManagement/lib/models/index.js index 046580e949..92c3336cf1 100644 --- a/lib/services/billingManagement/lib/models/index.js +++ b/lib/services/billingManagement/lib/models/index.js @@ -18,16 +18,49 @@ var msRestAzure = require('ms-rest-azure'); exports.BaseResource = msRestAzure.BaseResource; exports.CloudError = msRestAzure.CloudError; +exports.TransferProductRequestProperties = require('./transferProductRequestProperties'); +exports.TransferBillingSubscriptionResult = require('./transferBillingSubscriptionResult'); +exports.TransferBillingSubscriptionRequestProperties = require('./transferBillingSubscriptionRequestProperties'); +exports.TransferBillingSubscriptionRequest = require('./transferBillingSubscriptionRequest'); +exports.UpdateAutoRenewOperationSummary = require('./updateAutoRenewOperationSummary'); +exports.Address = require('./address'); +exports.EnabledAzureSKUs = require('./enabledAzureSKUs'); exports.Resource = require('./resource'); +exports.BillingProfile = require('./billingProfile'); +exports.InvoiceSectionProperties = require('./invoiceSectionProperties'); +exports.InvoiceSection = require('./invoiceSection'); +exports.EnrollmentPolicies = require('./enrollmentPolicies'); +exports.Enrollment = require('./enrollment'); exports.EnrollmentAccount = require('./enrollmentAccount'); -exports.BillingPeriod = require('./billingPeriod'); +exports.Department = require('./department'); +exports.BillingAccount = require('./billingAccount'); +exports.BillingAccountListResult = require('./billingAccountListResult'); +exports.BillingProperty = require('./billingProperty'); +exports.DepartmentListResult = require('./departmentListResult'); +exports.EnrollmentAccountListResult = require('./enrollmentAccountListResult'); +exports.BillingProfileListResult = require('./billingProfileListResult'); +exports.InvoiceSectionListResult = require('./invoiceSectionListResult'); +exports.OperationStatus = require('./operationStatus'); exports.DownloadUrl = require('./downloadUrl'); exports.ErrorDetails = require('./errorDetails'); exports.ErrorResponse = require('./errorResponse'); -exports.Invoice = require('./invoice'); +exports.Amount = require('./amount'); +exports.DownloadProperties = require('./downloadProperties'); +exports.PaymentProperties = require('./paymentProperties'); +exports.InvoiceSummary = require('./invoiceSummary'); +exports.InvoiceListResult = require('./invoiceListResult'); +exports.ProductSummary = require('./productSummary'); +exports.EnrollmentAccountContext = require('./enrollmentAccountContext'); +exports.BillingSubscriptionSummary = require('./billingSubscriptionSummary'); +exports.TransactionsSummary = require('./transactionsSummary'); +exports.Policy = require('./policy'); +exports.AvailableBalance = require('./availableBalance'); +exports.PaymentMethod = require('./paymentMethod'); +exports.UpdateAutoRenewRequest = require('./updateAutoRenewRequest'); exports.OperationDisplay = require('./operationDisplay'); exports.Operation = require('./operation'); -exports.EnrollmentAccountListResult = require('./enrollmentAccountListResult'); -exports.BillingPeriodsListResult = require('./billingPeriodsListResult'); -exports.InvoicesListResult = require('./invoicesListResult'); +exports.PaymentMethodsListResult = require('./paymentMethodsListResult'); +exports.BillingSubscriptionsListResult = require('./billingSubscriptionsListResult'); +exports.ProductsListResult = require('./productsListResult'); +exports.TransactionsListResult = require('./transactionsListResult'); exports.OperationListResult = require('./operationListResult'); diff --git a/lib/services/billingManagement/lib/models/invoice.js b/lib/services/billingManagement/lib/models/invoice.js index ac20623b30..655b86be14 100644 --- a/lib/services/billingManagement/lib/models/invoice.js +++ b/lib/services/billingManagement/lib/models/invoice.js @@ -20,17 +20,17 @@ const models = require('./index'); class Invoice extends models['Resource'] { /** * Create a Invoice. - * @member {object} [downloadUrl] A secure link to download the PDF version + * @property {object} [downloadUrl] A secure link to download the PDF version * of an invoice. The link will cease to work after its expiry time is * reached. - * @member {date} [downloadUrl.expiryTime] The time in UTC at which this + * @property {date} [downloadUrl.expiryTime] The time in UTC at which this * download URL will expire. - * @member {string} [downloadUrl.url] The URL to the PDF file. - * @member {date} [invoicePeriodStartDate] The start of the date range + * @property {string} [downloadUrl.url] The URL to the PDF file. + * @property {date} [invoicePeriodStartDate] The start of the date range * covered by the invoice. - * @member {date} [invoicePeriodEndDate] The end of the date range covered by - * the invoice. - * @member {array} [billingPeriodIds] Array of billing perdiod ids that the + * @property {date} [invoicePeriodEndDate] The end of the date range covered + * by the invoice. + * @property {array} [billingPeriodIds] Array of billing period ids that the * invoice is attributed to. */ constructor() { diff --git a/lib/services/billingManagement/lib/models/invoiceListResult.js b/lib/services/billingManagement/lib/models/invoiceListResult.js new file mode 100644 index 0000000000..9b6cdc3364 --- /dev/null +++ b/lib/services/billingManagement/lib/models/invoiceListResult.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 invoices. + * + */ +class InvoiceListResult { + /** + * Create a InvoiceListResult. + * @property {array} [value] The list of invoices. + * @property {string} [nextLink] The link (url) to the next page of results. + */ + constructor() { + } + + /** + * Defines the metadata of InvoiceListResult + * + * @returns {object} metadata of InvoiceListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'InvoiceListResult', + type: { + name: 'Composite', + className: 'InvoiceListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: 'value', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'InvoiceSummaryElementType', + type: { + name: 'Composite', + className: 'InvoiceSummary' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = InvoiceListResult; diff --git a/lib/services/billingManagement/lib/models/invoiceSection.js b/lib/services/billingManagement/lib/models/invoiceSection.js new file mode 100644 index 0000000000..50e214dc41 --- /dev/null +++ b/lib/services/billingManagement/lib/models/invoiceSection.js @@ -0,0 +1,97 @@ +/* + * 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 InvoiceSection resource. + * + * @extends models['Resource'] + */ +class InvoiceSection extends models['Resource'] { + /** + * Create a InvoiceSection. + * @property {string} [displayName] The name of the InvoiceSection. + * @property {array} [billingProfiles] The billing profiles associated to the + * billing account. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of InvoiceSection + * + * @returns {object} metadata of InvoiceSection + * + */ + mapper() { + return { + required: false, + serializedName: 'InvoiceSection', + type: { + name: 'Composite', + className: 'InvoiceSection', + 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' + } + }, + displayName: { + required: false, + serializedName: 'properties.displayName', + type: { + name: 'String' + } + }, + billingProfiles: { + required: false, + serializedName: 'properties.billingProfiles', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'BillingProfileElementType', + type: { + name: 'Composite', + className: 'BillingProfile' + } + } + } + } + } + } + }; + } +} + +module.exports = InvoiceSection; diff --git a/lib/services/billingManagement/lib/models/invoiceSectionListResult.js b/lib/services/billingManagement/lib/models/invoiceSectionListResult.js new file mode 100644 index 0000000000..0d38dc49cb --- /dev/null +++ b/lib/services/billingManagement/lib/models/invoiceSectionListResult.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 invoice sections. + * + */ +class InvoiceSectionListResult { + /** + * Create a InvoiceSectionListResult. + * @property {array} [value] The list of invoice sections. + * @property {string} [nextLink] The link (url) to the next page of results. + */ + constructor() { + } + + /** + * Defines the metadata of InvoiceSectionListResult + * + * @returns {object} metadata of InvoiceSectionListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'InvoiceSectionListResult', + type: { + name: 'Composite', + className: 'InvoiceSectionListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: 'value', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'InvoiceSectionElementType', + type: { + name: 'Composite', + className: 'InvoiceSection' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = InvoiceSectionListResult; diff --git a/lib/services/billingManagement/lib/models/invoiceSectionProperties.js b/lib/services/billingManagement/lib/models/invoiceSectionProperties.js new file mode 100644 index 0000000000..077cbbf882 --- /dev/null +++ b/lib/services/billingManagement/lib/models/invoiceSectionProperties.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'; + +/** + * The properties of an InvoiceSection. + * + */ +class InvoiceSectionProperties { + /** + * Create a InvoiceSectionProperties. + * @property {string} [displayName] The name of the InvoiceSection. + * @property {array} [billingProfiles] The billing profiles associated to the + * billing account. + */ + constructor() { + } + + /** + * Defines the metadata of InvoiceSectionProperties + * + * @returns {object} metadata of InvoiceSectionProperties + * + */ + mapper() { + return { + required: false, + serializedName: 'InvoiceSectionProperties', + type: { + name: 'Composite', + className: 'InvoiceSectionProperties', + modelProperties: { + displayName: { + required: false, + serializedName: 'displayName', + type: { + name: 'String' + } + }, + billingProfiles: { + required: false, + serializedName: 'billingProfiles', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'BillingProfileElementType', + type: { + name: 'Composite', + className: 'BillingProfile' + } + } + } + } + } + } + }; + } +} + +module.exports = InvoiceSectionProperties; diff --git a/lib/services/billingManagement/lib/models/invoiceSummary.js b/lib/services/billingManagement/lib/models/invoiceSummary.js new file mode 100644 index 0000000000..e3204d08a1 --- /dev/null +++ b/lib/services/billingManagement/lib/models/invoiceSummary.js @@ -0,0 +1,210 @@ +/* + * 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 invoice resource. + * + * @extends models['Resource'] + */ +class InvoiceSummary extends models['Resource'] { + /** + * Create a InvoiceSummary. + * @property {date} [dueDate] The due date for invoice. + * @property {date} [invoiceDate] The date when invoice was created. + * @property {string} [status] Invoice status. Possible values include: + * 'PastDue', 'Due', 'Paid', 'Void' + * @property {object} [amountDue] Amount due. + * @property {string} [amountDue.currency] The currency for the amount value. + * @property {number} [amountDue.value] Amount value. + * @property {object} [billedAmount] Amount billed. + * @property {string} [billedAmount.currency] The currency for the amount + * value. + * @property {number} [billedAmount.value] Amount value. + * @property {date} [invoicePeriodStartDate] The start date of the billing + * period. + * @property {date} [invoicePeriodEndDate] The end date of the billing + * period. + * @property {string} [billingProfile] The profile id which invoice belongs + * to. + * @property {string} [billingProfileName] The profile name which invoice + * belongs to. + * @property {string} [purchaseOrderNumber] The purchase identifier for the + * invoice. + * @property {array} [documentUrls] List of document urls available to + * download including invoice and tax documents. + * @property {array} [payments] List of payments. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of InvoiceSummary + * + * @returns {object} metadata of InvoiceSummary + * + */ + mapper() { + return { + required: false, + serializedName: 'InvoiceSummary', + type: { + name: 'Composite', + className: 'InvoiceSummary', + 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' + } + }, + dueDate: { + required: false, + readOnly: true, + serializedName: 'properties.dueDate', + type: { + name: 'DateTime' + } + }, + invoiceDate: { + required: false, + readOnly: true, + serializedName: 'properties.invoiceDate', + type: { + name: 'DateTime' + } + }, + status: { + required: false, + readOnly: true, + serializedName: 'properties.status', + type: { + name: 'String' + } + }, + amountDue: { + required: false, + readOnly: true, + serializedName: 'properties.amountDue', + type: { + name: 'Composite', + className: 'Amount' + } + }, + billedAmount: { + required: false, + readOnly: true, + serializedName: 'properties.billedAmount', + type: { + name: 'Composite', + className: 'Amount' + } + }, + invoicePeriodStartDate: { + required: false, + readOnly: true, + serializedName: 'properties.invoicePeriodStartDate', + type: { + name: 'DateTime' + } + }, + invoicePeriodEndDate: { + required: false, + readOnly: true, + serializedName: 'properties.invoicePeriodEndDate', + type: { + name: 'DateTime' + } + }, + billingProfile: { + required: false, + readOnly: true, + serializedName: 'properties.billingProfile', + type: { + name: 'String' + } + }, + billingProfileName: { + required: false, + readOnly: true, + serializedName: 'properties.billingProfileName', + type: { + name: 'String' + } + }, + purchaseOrderNumber: { + required: false, + readOnly: true, + serializedName: 'properties.purchaseOrderNumber', + type: { + name: 'String' + } + }, + documentUrls: { + required: false, + readOnly: true, + serializedName: 'properties.documentUrls', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'DownloadPropertiesElementType', + type: { + name: 'Composite', + className: 'DownloadProperties' + } + } + } + }, + payments: { + required: false, + readOnly: true, + serializedName: 'properties.payments', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'PaymentPropertiesElementType', + type: { + name: 'Composite', + className: 'PaymentProperties' + } + } + } + } + } + } + }; + } +} + +module.exports = InvoiceSummary; diff --git a/lib/services/billingManagement/lib/models/invoicesListResult.js b/lib/services/billingManagement/lib/models/invoicesListResult.js index 235e9bb395..03d15a7976 100644 --- a/lib/services/billingManagement/lib/models/invoicesListResult.js +++ b/lib/services/billingManagement/lib/models/invoicesListResult.js @@ -17,7 +17,7 @@ class InvoicesListResult extends Array { /** * Create a InvoicesListResult. - * @member {string} [nextLink] The link (url) to the next page of results. + * @property {string} [nextLink] The link (url) to the next page of results. */ constructor() { super(); diff --git a/lib/services/billingManagement/lib/models/operation.js b/lib/services/billingManagement/lib/models/operation.js index 1129eb5181..d447495594 100644 --- a/lib/services/billingManagement/lib/models/operation.js +++ b/lib/services/billingManagement/lib/models/operation.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * A Billing REST API operation. * @@ -19,13 +17,14 @@ const models = require('./index'); 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.Billing. - * @member {string} [display.resource] Resource on which the operation is + * @property {string} [name] Operation name: + * {provider}/{resource}/{operation}. + * @property {object} [display] The object that represents the operation. + * @property {string} [display.provider] Service provider: Microsoft.Billing. + * @property {string} [display.resource] Resource on which the operation is * performed: Invoice, etc. - * @member {string} [display.operation] Operation type: Read, write, delete, - * etc. + * @property {string} [display.operation] Operation type: Read, write, + * delete, etc. */ constructor() { } diff --git a/lib/services/billingManagement/lib/models/operationDisplay.js b/lib/services/billingManagement/lib/models/operationDisplay.js index 8d0282da7b..d5ffa5affd 100644 --- a/lib/services/billingManagement/lib/models/operationDisplay.js +++ b/lib/services/billingManagement/lib/models/operationDisplay.js @@ -17,10 +17,10 @@ class OperationDisplay { /** * Create a OperationDisplay. - * @member {string} [provider] Service provider: Microsoft.Billing. - * @member {string} [resource] Resource on which the operation is performed: - * Invoice, etc. - * @member {string} [operation] Operation type: Read, write, delete, etc. + * @property {string} [provider] Service provider: Microsoft.Billing. + * @property {string} [resource] Resource on which the operation is + * performed: Invoice, etc. + * @property {string} [operation] Operation type: Read, write, delete, etc. */ constructor() { } diff --git a/lib/services/billingManagement/lib/models/operationListResult.js b/lib/services/billingManagement/lib/models/operationListResult.js index 50990fa087..29cd6ed9e6 100644 --- a/lib/services/billingManagement/lib/models/operationListResult.js +++ b/lib/services/billingManagement/lib/models/operationListResult.js @@ -17,7 +17,7 @@ class OperationListResult extends Array { /** * Create a OperationListResult. - * @member {string} [nextLink] URL to get the next set of operation list + * @property {string} [nextLink] URL to get the next set of operation list * results if there are any. */ constructor() { diff --git a/lib/services/billingManagement/lib/models/operationStatus.js b/lib/services/billingManagement/lib/models/operationStatus.js new file mode 100644 index 0000000000..0cac4e719d --- /dev/null +++ b/lib/services/billingManagement/lib/models/operationStatus.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'; + +/** + * status of the Billing POST/PUT operation. + * + */ +class OperationStatus { + /** + * Create a OperationStatus. + * @property {string} [id] The operation Id. + * @property {string} [status] Status of the pending operation + * @property {string} [statusDetail] Status Detail of the pending operation + */ + constructor() { + } + + /** + * Defines the metadata of OperationStatus + * + * @returns {object} metadata of OperationStatus + * + */ + mapper() { + return { + required: false, + serializedName: 'OperationStatus', + type: { + name: 'Composite', + className: 'OperationStatus', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + status: { + required: false, + serializedName: 'status', + type: { + name: 'String' + } + }, + statusDetail: { + required: false, + serializedName: 'statusDetail', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = OperationStatus; diff --git a/lib/services/billingManagement/lib/models/paymentMethod.js b/lib/services/billingManagement/lib/models/paymentMethod.js new file mode 100644 index 0000000000..aa9dd09ba2 --- /dev/null +++ b/lib/services/billingManagement/lib/models/paymentMethod.js @@ -0,0 +1,109 @@ +/* + * 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 payment method resource. + * + * @extends models['Resource'] + */ +class PaymentMethod extends models['Resource'] { + /** + * Create a PaymentMethod. + * @property {string} [methodType] Payment method type. Possible values + * include: 'Credits', 'ChequeWire' + * @property {string} [details] Details about the payment method. + * @property {date} [expiration] Expiration date. + * @property {string} [currency] The currency associated with the payment + * method. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of PaymentMethod + * + * @returns {object} metadata of PaymentMethod + * + */ + mapper() { + return { + required: false, + serializedName: 'PaymentMethod', + type: { + name: 'Composite', + className: 'PaymentMethod', + 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' + } + }, + methodType: { + required: false, + serializedName: 'properties.methodType', + type: { + name: 'String' + } + }, + details: { + required: false, + readOnly: true, + serializedName: 'properties.details', + type: { + name: 'String' + } + }, + expiration: { + required: false, + readOnly: true, + serializedName: 'properties.expiration', + type: { + name: 'DateTime' + } + }, + currency: { + required: false, + readOnly: true, + serializedName: 'properties.currency', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = PaymentMethod; diff --git a/lib/services/billingManagement/lib/models/paymentMethodsListResult.js b/lib/services/billingManagement/lib/models/paymentMethodsListResult.js new file mode 100644 index 0000000000..7db6fa774d --- /dev/null +++ b/lib/services/billingManagement/lib/models/paymentMethodsListResult.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 payment methods. + */ +class PaymentMethodsListResult extends Array { + /** + * Create a PaymentMethodsListResult. + * @property {string} [nextLink] The link (url) to the next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of PaymentMethodsListResult + * + * @returns {object} metadata of PaymentMethodsListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'PaymentMethodsListResult', + type: { + name: 'Composite', + className: 'PaymentMethodsListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'PaymentMethodElementType', + type: { + name: 'Composite', + className: 'PaymentMethod' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = PaymentMethodsListResult; diff --git a/lib/services/billingManagement/lib/models/paymentProperties.js b/lib/services/billingManagement/lib/models/paymentProperties.js new file mode 100644 index 0000000000..1d104cefe7 --- /dev/null +++ b/lib/services/billingManagement/lib/models/paymentProperties.js @@ -0,0 +1,74 @@ +/* + * 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 payment. + * + */ +class PaymentProperties { + /** + * Create a PaymentProperties. + * @property {string} [paymentType] The type of payment. + * @property {object} [amount] The paid amount. + * @property {string} [amount.currency] The currency for the amount value. + * @property {number} [amount.value] Amount value. + * @property {date} [date] The date of the payment. + */ + constructor() { + } + + /** + * Defines the metadata of PaymentProperties + * + * @returns {object} metadata of PaymentProperties + * + */ + mapper() { + return { + required: false, + serializedName: 'PaymentProperties', + type: { + name: 'Composite', + className: 'PaymentProperties', + modelProperties: { + paymentType: { + required: false, + readOnly: true, + serializedName: 'paymentType', + type: { + name: 'String' + } + }, + amount: { + required: false, + readOnly: true, + serializedName: 'amount', + type: { + name: 'Composite', + className: 'Amount' + } + }, + date: { + required: false, + readOnly: true, + serializedName: 'date', + type: { + name: 'DateTime' + } + } + } + } + }; + } +} + +module.exports = PaymentProperties; diff --git a/lib/services/billingManagement/lib/models/policy.js b/lib/services/billingManagement/lib/models/policy.js new file mode 100644 index 0000000000..ad5e47e4da --- /dev/null +++ b/lib/services/billingManagement/lib/models/policy.js @@ -0,0 +1,90 @@ +/* + * 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 Policy. + * + * @extends models['Resource'] + */ +class Policy extends models['Resource'] { + /** + * Create a Policy. + * @property {boolean} [reservationPurchasesAllowed] The + * reservationPurchasesAllowed flag. + * @property {boolean} [marketplacePurchasesAllowed] The + * marketplacePurchasesAllowed flag. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Policy + * + * @returns {object} metadata of Policy + * + */ + mapper() { + return { + required: false, + serializedName: 'Policy', + type: { + name: 'Composite', + className: 'Policy', + 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' + } + }, + reservationPurchasesAllowed: { + required: false, + serializedName: 'properties.reservationPurchasesAllowed', + type: { + name: 'Boolean' + } + }, + marketplacePurchasesAllowed: { + required: false, + serializedName: 'properties.marketplacePurchasesAllowed', + type: { + name: 'Boolean' + } + } + } + } + }; + } +} + +module.exports = Policy; diff --git a/lib/services/billingManagement/lib/models/productSummary.js b/lib/services/billingManagement/lib/models/productSummary.js new file mode 100644 index 0000000000..dc82eeddb4 --- /dev/null +++ b/lib/services/billingManagement/lib/models/productSummary.js @@ -0,0 +1,243 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * A product summary resource. + * + * @extends models['Resource'] + */ +class ProductSummary extends models['Resource'] { + /** + * Create a ProductSummary. + * @property {string} [displayName] The display name of the product. + * @property {date} [purchaseDate] The date of purchase. + * @property {string} [productTypeId] The product type id. + * @property {string} [productType] The type of product. + * @property {string} [status] Product status. Possible values include: + * 'Active', 'Inactive', 'PastDue', 'Expiring', 'Expired', 'Disabled', + * 'Cancelled', 'AutoRenew' + * @property {date} [endDate] end date. + * @property {string} [billingFrequency] Billing frequency. Possible values + * include: 'OneTime', 'Monthly', 'UsageBased' + * @property {object} [lastCharge] Last month charges. + * @property {string} [lastCharge.currency] The currency for the amount + * value. + * @property {number} [lastCharge.value] Amount value. + * @property {date} [lastChargeDate] The date of the last charge. + * @property {number} [quantity] The purchased product quantity. + * @property {string} [skuId] Sku Id. + * @property {string} [skuDescription] Sku description. + * @property {string} [availabilityId] Availability Id. + * @property {string} [parentProductId] Parent Product Id. + * @property {string} [invoiceSectionId] Invoice section id to which this + * product belongs. + * @property {string} [invoiceSectionName] Invoice section name to which this + * product belongs. + * @property {string} [billingProfileId] Billing Profile id to which this + * product belongs. + * @property {string} [billingProfileName] Billing Profile name to which this + * product belongs. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ProductSummary + * + * @returns {object} metadata of ProductSummary + * + */ + mapper() { + return { + required: false, + serializedName: 'ProductSummary', + type: { + name: 'Composite', + className: 'ProductSummary', + 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' + } + }, + displayName: { + required: false, + readOnly: true, + serializedName: 'properties.displayName', + type: { + name: 'String' + } + }, + purchaseDate: { + required: false, + readOnly: true, + serializedName: 'properties.purchaseDate', + type: { + name: 'DateTime' + } + }, + productTypeId: { + required: false, + readOnly: true, + serializedName: 'properties.productTypeId', + type: { + name: 'String' + } + }, + productType: { + required: false, + readOnly: true, + serializedName: 'properties.productType', + type: { + name: 'String' + } + }, + status: { + required: false, + serializedName: 'properties.status', + type: { + name: 'String' + } + }, + endDate: { + required: false, + readOnly: true, + serializedName: 'properties.endDate', + type: { + name: 'DateTime' + } + }, + billingFrequency: { + required: false, + serializedName: 'properties.billingFrequency', + type: { + name: 'String' + } + }, + lastCharge: { + required: false, + readOnly: true, + serializedName: 'properties.lastCharge', + type: { + name: 'Composite', + className: 'Amount' + } + }, + lastChargeDate: { + required: false, + readOnly: true, + serializedName: 'properties.lastChargeDate', + type: { + name: 'DateTime' + } + }, + quantity: { + required: false, + readOnly: true, + serializedName: 'properties.quantity', + type: { + name: 'Number' + } + }, + skuId: { + required: false, + readOnly: true, + serializedName: 'properties.skuId', + type: { + name: 'String' + } + }, + skuDescription: { + required: false, + readOnly: true, + serializedName: 'properties.skuDescription', + type: { + name: 'String' + } + }, + availabilityId: { + required: false, + readOnly: true, + serializedName: 'properties.availabilityId', + type: { + name: 'String' + } + }, + parentProductId: { + required: false, + readOnly: true, + serializedName: 'properties.parentProductId', + type: { + name: 'String' + } + }, + invoiceSectionId: { + required: false, + readOnly: true, + serializedName: 'properties.invoiceSectionId', + type: { + name: 'String' + } + }, + invoiceSectionName: { + required: false, + readOnly: true, + serializedName: 'properties.invoiceSectionName', + type: { + name: 'String' + } + }, + billingProfileId: { + required: false, + readOnly: true, + serializedName: 'properties.billingProfileId', + type: { + name: 'String' + } + }, + billingProfileName: { + required: false, + readOnly: true, + serializedName: 'properties.billingProfileName', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ProductSummary; diff --git a/lib/services/billingManagement/lib/models/productsListResult.js b/lib/services/billingManagement/lib/models/productsListResult.js new file mode 100644 index 0000000000..b82fa8e13c --- /dev/null +++ b/lib/services/billingManagement/lib/models/productsListResult.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 products summary. It contains a list of available products + * summaries in reverse chronological order by purchase date. + */ +class ProductsListResult extends Array { + /** + * Create a ProductsListResult. + * @property {string} [nextLink] The link (url) to the next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ProductsListResult + * + * @returns {object} metadata of ProductsListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'ProductsListResult', + type: { + name: 'Composite', + className: 'ProductsListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ProductSummaryElementType', + type: { + name: 'Composite', + className: 'ProductSummary' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ProductsListResult; diff --git a/lib/services/billingManagement/lib/models/resource.js b/lib/services/billingManagement/lib/models/resource.js index 4b5fc4f7c0..5576a7e77d 100644 --- a/lib/services/billingManagement/lib/models/resource.js +++ b/lib/services/billingManagement/lib/models/resource.js @@ -20,9 +20,9 @@ const models = require('./index'); class Resource extends models['BaseResource'] { /** * Create a Resource. - * @member {string} [id] Resource Id. - * @member {string} [name] Resource name. - * @member {string} [type] Resource type. + * @property {string} [id] Resource Id. + * @property {string} [name] Resource name. + * @property {string} [type] Resource type. */ constructor() { super(); diff --git a/lib/services/billingManagement/lib/models/transactionsListResult.js b/lib/services/billingManagement/lib/models/transactionsListResult.js new file mode 100644 index 0000000000..7b33c5468d --- /dev/null +++ b/lib/services/billingManagement/lib/models/transactionsListResult.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 transactions summary. + */ +class TransactionsListResult extends Array { + /** + * Create a TransactionsListResult. + * @property {string} [nextLink] The link (url) to the next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of TransactionsListResult + * + * @returns {object} metadata of TransactionsListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'TransactionsListResult', + type: { + name: 'Composite', + className: 'TransactionsListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'TransactionsSummaryElementType', + type: { + name: 'Composite', + className: 'TransactionsSummary' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = TransactionsListResult; diff --git a/lib/services/billingManagement/lib/models/transactionsSummary.js b/lib/services/billingManagement/lib/models/transactionsSummary.js new file mode 100644 index 0000000000..a569994e8c --- /dev/null +++ b/lib/services/billingManagement/lib/models/transactionsSummary.js @@ -0,0 +1,234 @@ +/* + * 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 reservation transaction summary resource. + * + * @extends models['Resource'] + */ +class TransactionsSummary extends models['Resource'] { + /** + * Create a TransactionsSummary. + * @property {string} [kind] The kind of transaction. Choices are all and + * reservation. Possible values include: 'all', 'reservation' + * @property {date} [date] The date of reservation transaction. + * @property {string} [invoice] Invoice number or 'pending' if not invoiced. + * @property {string} [orderId] The reservation order id. + * @property {string} [orderName] The reservation order name. + * @property {string} [productTypeId] The product type id. + * @property {string} [productType] The type of product. + * @property {string} [productDescription] Product description. + * @property {string} [transactionType] Transaction types. Possible values + * include: 'Purchase', 'Usage Charge' + * @property {object} [transactionAmount] Last charge associated with the + * purchase. + * @property {string} [transactionAmount.currency] The currency for the + * amount value. + * @property {number} [transactionAmount.value] Amount value. + * @property {number} [quantity] Purchase quantity. + * @property {string} [invoiceSectionId] Invoice section id to which this + * product belongs. + * @property {string} [invoiceSectionName] Invoice section name to which this + * product belongs. + * @property {string} [billingProfileId] Billing Profile id to which this + * product belongs. + * @property {string} [billingProfileName] Billing Profile name to which this + * product belongs. + * @property {string} [subscriptionId] The subscription id. + * @property {string} [subscriptionName] The subscription name. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of TransactionsSummary + * + * @returns {object} metadata of TransactionsSummary + * + */ + mapper() { + return { + required: false, + serializedName: 'TransactionsSummary', + type: { + name: 'Composite', + className: 'TransactionsSummary', + 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' + } + }, + kind: { + required: false, + serializedName: 'properties.kind', + type: { + name: 'String' + } + }, + date: { + required: false, + readOnly: true, + serializedName: 'properties.date', + type: { + name: 'DateTime' + } + }, + invoice: { + required: false, + readOnly: true, + serializedName: 'properties.invoice', + type: { + name: 'String' + } + }, + orderId: { + required: false, + readOnly: true, + serializedName: 'properties.orderId', + type: { + name: 'String' + } + }, + orderName: { + required: false, + readOnly: true, + serializedName: 'properties.orderName', + type: { + name: 'String' + } + }, + productTypeId: { + required: false, + readOnly: true, + serializedName: 'properties.productTypeId', + type: { + name: 'String' + } + }, + productType: { + required: false, + readOnly: true, + serializedName: 'properties.productType', + type: { + name: 'String' + } + }, + productDescription: { + required: false, + readOnly: true, + serializedName: 'properties.productDescription', + type: { + name: 'String' + } + }, + transactionType: { + required: false, + serializedName: 'properties.transactionType', + type: { + name: 'String' + } + }, + transactionAmount: { + required: false, + readOnly: true, + serializedName: 'properties.transactionAmount', + type: { + name: 'Composite', + className: 'Amount' + } + }, + quantity: { + required: false, + readOnly: true, + serializedName: 'properties.quantity', + type: { + name: 'Number' + } + }, + invoiceSectionId: { + required: false, + readOnly: true, + serializedName: 'properties.invoiceSectionId', + type: { + name: 'String' + } + }, + invoiceSectionName: { + required: false, + readOnly: true, + serializedName: 'properties.invoiceSectionName', + type: { + name: 'String' + } + }, + billingProfileId: { + required: false, + readOnly: true, + serializedName: 'properties.billingProfileId', + type: { + name: 'String' + } + }, + billingProfileName: { + required: false, + readOnly: true, + serializedName: 'properties.billingProfileName', + type: { + name: 'String' + } + }, + subscriptionId: { + required: false, + readOnly: true, + serializedName: 'properties.subscriptionId', + type: { + name: 'String' + } + }, + subscriptionName: { + required: false, + readOnly: true, + serializedName: 'properties.subscriptionName', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = TransactionsSummary; diff --git a/lib/services/billingManagement/lib/models/transferBillingSubscriptionRequest.js b/lib/services/billingManagement/lib/models/transferBillingSubscriptionRequest.js new file mode 100644 index 0000000000..6dcb9242a2 --- /dev/null +++ b/lib/services/billingManagement/lib/models/transferBillingSubscriptionRequest.js @@ -0,0 +1,53 @@ +/* + * 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'; + +/** + * Request parameters to transfer billing subscription. + * + */ +class TransferBillingSubscriptionRequest { + /** + * Create a TransferBillingSubscriptionRequest. + * @property {string} [destinationInvoiceSectionId] The destination + * invoiceSectionId. + */ + constructor() { + } + + /** + * Defines the metadata of TransferBillingSubscriptionRequest + * + * @returns {object} metadata of TransferBillingSubscriptionRequest + * + */ + mapper() { + return { + required: false, + serializedName: 'TransferBillingSubscriptionRequest', + type: { + name: 'Composite', + className: 'TransferBillingSubscriptionRequest', + modelProperties: { + destinationInvoiceSectionId: { + required: false, + serializedName: 'properties.destinationInvoiceSectionId', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = TransferBillingSubscriptionRequest; diff --git a/lib/services/billingManagement/lib/models/transferBillingSubscriptionRequestProperties.js b/lib/services/billingManagement/lib/models/transferBillingSubscriptionRequestProperties.js new file mode 100644 index 0000000000..d885fcef13 --- /dev/null +++ b/lib/services/billingManagement/lib/models/transferBillingSubscriptionRequestProperties.js @@ -0,0 +1,53 @@ +/* + * 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'; + +/** + * Request parameters to transfer billing subscription. + * + */ +class TransferBillingSubscriptionRequestProperties { + /** + * Create a TransferBillingSubscriptionRequestProperties. + * @property {string} [destinationInvoiceSectionId] The destination + * invoiceSectionId. + */ + constructor() { + } + + /** + * Defines the metadata of TransferBillingSubscriptionRequestProperties + * + * @returns {object} metadata of TransferBillingSubscriptionRequestProperties + * + */ + mapper() { + return { + required: false, + serializedName: 'TransferBillingSubscriptionRequestProperties', + type: { + name: 'Composite', + className: 'TransferBillingSubscriptionRequestProperties', + modelProperties: { + destinationInvoiceSectionId: { + required: false, + serializedName: 'destinationInvoiceSectionId', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = TransferBillingSubscriptionRequestProperties; diff --git a/lib/services/billingManagement/lib/models/transferBillingSubscriptionResult.js b/lib/services/billingManagement/lib/models/transferBillingSubscriptionResult.js new file mode 100644 index 0000000000..ba0af698cd --- /dev/null +++ b/lib/services/billingManagement/lib/models/transferBillingSubscriptionResult.js @@ -0,0 +1,53 @@ +/* + * 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'; + +/** + * Request parameters to transfer billing subscription. + * + */ +class TransferBillingSubscriptionResult { + /** + * Create a TransferBillingSubscriptionResult. + * @property {string} [billingSubscriptionId] The destination billing + * subscription id. + */ + constructor() { + } + + /** + * Defines the metadata of TransferBillingSubscriptionResult + * + * @returns {object} metadata of TransferBillingSubscriptionResult + * + */ + mapper() { + return { + required: false, + serializedName: 'TransferBillingSubscriptionResult', + type: { + name: 'Composite', + className: 'TransferBillingSubscriptionResult', + modelProperties: { + billingSubscriptionId: { + required: false, + serializedName: 'properties.billingSubscriptionId', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = TransferBillingSubscriptionResult; diff --git a/lib/services/billingManagement/lib/models/transferProductRequestProperties.js b/lib/services/billingManagement/lib/models/transferProductRequestProperties.js new file mode 100644 index 0000000000..e08414c2a2 --- /dev/null +++ b/lib/services/billingManagement/lib/models/transferProductRequestProperties.js @@ -0,0 +1,53 @@ +/* + * 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 product to initiate a transfer. + * + */ +class TransferProductRequestProperties { + /** + * Create a TransferProductRequestProperties. + * @property {string} [destinationInvoiceSectionId] Destination invoice + * section id. + */ + constructor() { + } + + /** + * Defines the metadata of TransferProductRequestProperties + * + * @returns {object} metadata of TransferProductRequestProperties + * + */ + mapper() { + return { + required: false, + serializedName: 'TransferProductRequestProperties', + type: { + name: 'Composite', + className: 'TransferProductRequestProperties', + modelProperties: { + destinationInvoiceSectionId: { + required: false, + serializedName: 'destinationInvoiceSectionId', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = TransferProductRequestProperties; diff --git a/lib/services/billingManagement/lib/models/updateAutoRenewOperationSummary.js b/lib/services/billingManagement/lib/models/updateAutoRenewOperationSummary.js new file mode 100644 index 0000000000..7245df67df --- /dev/null +++ b/lib/services/billingManagement/lib/models/updateAutoRenewOperationSummary.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'; + +/** + * Summary of cancel product operation + * + */ +class UpdateAutoRenewOperationSummary { + /** + * Create a UpdateAutoRenewOperationSummary. + * @property {date} [endDate] The end date of this asset + */ + constructor() { + } + + /** + * Defines the metadata of UpdateAutoRenewOperationSummary + * + * @returns {object} metadata of UpdateAutoRenewOperationSummary + * + */ + mapper() { + return { + required: false, + serializedName: 'UpdateAutoRenewOperationSummary', + type: { + name: 'Composite', + className: 'UpdateAutoRenewOperationSummary', + modelProperties: { + endDate: { + required: false, + serializedName: 'properties.endDate', + type: { + name: 'DateTime' + } + } + } + } + }; + } +} + +module.exports = UpdateAutoRenewOperationSummary; diff --git a/lib/services/billingManagement/lib/models/updateAutoRenewRequest.js b/lib/services/billingManagement/lib/models/updateAutoRenewRequest.js new file mode 100644 index 0000000000..2092954d7e --- /dev/null +++ b/lib/services/billingManagement/lib/models/updateAutoRenewRequest.js @@ -0,0 +1,53 @@ +/* + * 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'; + +/** + * Request parameters to update auto renew for support prouct. + * + */ +class UpdateAutoRenewRequest { + /** + * Create a UpdateAutoRenewRequest. + * @property {string} [autoRenew] Request parameters to update auto renew + * policy a product. Possible values include: 'true', 'false' + */ + constructor() { + } + + /** + * Defines the metadata of UpdateAutoRenewRequest + * + * @returns {object} metadata of UpdateAutoRenewRequest + * + */ + mapper() { + return { + required: false, + serializedName: 'UpdateAutoRenewRequest', + type: { + name: 'Composite', + className: 'UpdateAutoRenewRequest', + modelProperties: { + autoRenew: { + required: false, + serializedName: 'autoRenew', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = UpdateAutoRenewRequest; diff --git a/lib/services/billingManagement/lib/operations/availableBalanceByBillingProfile.js b/lib/services/billingManagement/lib/operations/availableBalanceByBillingProfile.js new file mode 100644 index 0000000000..7328a77310 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/availableBalanceByBillingProfile.js @@ -0,0 +1,261 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * The latest available credit balance for a given billingAccountId and + * billingProfileId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile 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 AvailableBalance} for more information. + * + * {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, billingProfileId, 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 (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 (billingProfileId === null || billingProfileId === undefined || typeof billingProfileId.valueOf() !== 'string') { + throw new Error('billingProfileId 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/availableBalance/default'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{billingProfileId}', encodeURIComponent(billingProfileId)); + 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['AvailableBalance']().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 AvailableBalanceByBillingProfile. */ +class AvailableBalanceByBillingProfile { + /** + * Create a AvailableBalanceByBillingProfile. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + } + + /** + * The latest available credit balance for a given billingAccountId and + * billingProfileId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile 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, billingProfileId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountId, billingProfileId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * The latest available credit balance for a given billingAccountId and + * billingProfileId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile 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 {AvailableBalance} - 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 AvailableBalance} for more information. + * + * {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, billingProfileId, 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, billingProfileId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountId, billingProfileId, options, optionalCallback); + } + } + +} + +module.exports = AvailableBalanceByBillingProfile; diff --git a/lib/services/billingManagement/lib/operations/billingAccounts.js b/lib/services/billingManagement/lib/operations/billingAccounts.js new file mode 100644 index 0000000000..ecedfbf53f --- /dev/null +++ b/lib/services/billingManagement/lib/operations/billingAccounts.js @@ -0,0 +1,491 @@ +/* + * 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 billing accounts for a user which he has access to. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections + * and billingProfiles. + * + * @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 BillingAccountListResult} for more + * information. + * + * {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; + // 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 (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts'; + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + 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['BillingAccountListResult']().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 billing account by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections + * and billingProfiles. + * + * @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 BillingAccount} for more information. + * + * {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.'); + } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + // 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 (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + 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['BillingAccount']().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 BillingAccounts. */ +class BillingAccounts { + /** + * Create a BillingAccounts. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._get = _get; + } + + /** + * Lists all billing accounts for a user which he has access to. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections + * and billingProfiles. + * + * @param {object} [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 billing accounts for a user which he has access to. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections + * and billingProfiles. + * + * @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 {BillingAccountListResult} - 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 BillingAccountListResult} for more + * information. + * + * {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); + } + } + + /** + * Get the billing account by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections + * and billingProfiles. + * + * @param {object} [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 the billing account by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections + * and billingProfiles. + * + * @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 {BillingAccount} - 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 BillingAccount} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(billingAccountId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(billingAccountId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountId, options, optionalCallback); + } + } + +} + +module.exports = BillingAccounts; diff --git a/lib/services/billingManagement/lib/operations/billingAccountsWithCreateInvoiceSectionPermission.js b/lib/services/billingManagement/lib/operations/billingAccountsWithCreateInvoiceSectionPermission.js new file mode 100644 index 0000000000..816da4c1a0 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/billingAccountsWithCreateInvoiceSectionPermission.js @@ -0,0 +1,256 @@ +/* + * 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 billing accounts with create invoiceSection permission for a user. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections + * and billingProfiles. + * + * @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 BillingAccountListResult} for more + * information. + * + * {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; + // 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 (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/listBillingAccountsWithCreateInvoiceSectionPermission'; + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + 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['BillingAccountListResult']().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 BillingAccountsWithCreateInvoiceSectionPermission. */ +class BillingAccountsWithCreateInvoiceSectionPermission { + /** + * Create a BillingAccountsWithCreateInvoiceSectionPermission. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + } + + /** + * Lists all billing accounts with create invoiceSection permission for a user. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections + * and billingProfiles. + * + * @param {object} [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 billing accounts with create invoiceSection permission for a user. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections + * and billingProfiles. + * + * @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 {BillingAccountListResult} - 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 BillingAccountListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(options, optionalCallback); + } + } + +} + +module.exports = BillingAccountsWithCreateInvoiceSectionPermission; diff --git a/lib/services/billingManagement/lib/operations/billingProfiles.js b/lib/services/billingManagement/lib/operations/billingProfiles.js new file mode 100644 index 0000000000..f1fdb205a4 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/billingProfiles.js @@ -0,0 +1,892 @@ +/* + * 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 the billing profile by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections. + * + * @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 BillingProfile} for more information. + * + * {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, billingProfileId, 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; + // 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 (billingProfileId === null || billingProfileId === undefined || typeof billingProfileId.valueOf() !== 'string') { + throw new Error('billingProfileId 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 (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{billingProfileId}', encodeURIComponent(billingProfileId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + 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['BillingProfile']().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 update a billing profile. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {object} parameters Parameters supplied to the update billing profile + * operation. + * + * @param {string} [parameters.displayName] The billing profile name. + * + * @param {string} [parameters.poNumber] Purchase order number. + * + * @param {object} [parameters.billingAddress] Billing address. + * + * @param {string} [parameters.billingAddress.firstName] First Name. + * + * @param {string} [parameters.billingAddress.lastName] Last Name. + * + * @param {string} [parameters.billingAddress.companyName] Company Name. + * + * @param {string} [parameters.billingAddress.addressLine1] Address Line1. + * + * @param {string} [parameters.billingAddress.addressLine2] Address Line2. + * + * @param {string} [parameters.billingAddress.addressLine3] Address Line3. + * + * @param {string} [parameters.billingAddress.city] Address City. + * + * @param {string} [parameters.billingAddress.region] Address Region. + * + * @param {string} [parameters.billingAddress.country] Country code uses ISO2, + * 2-digit format. + * + * @param {string} [parameters.billingAddress.postalCode] Address Postal Code. + * + * @param {array} [parameters.enabledAzureSKUs] Information about the product. + * + * @param {array} [parameters.invoiceSections] The invoice sections associated + * to the billing profile. + * + * @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 BillingProfile} for more information. + * + * {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 _update(billingAccountId, billingProfileId, 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.'); + } + + // Send request + this.beginUpdate(billingAccountId, billingProfileId, parameters, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['BillingProfile']().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 update a billing profile. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {object} parameters Parameters supplied to the update billing profile + * operation. + * + * @param {string} [parameters.displayName] The billing profile name. + * + * @param {string} [parameters.poNumber] Purchase order number. + * + * @param {object} [parameters.billingAddress] Billing address. + * + * @param {string} [parameters.billingAddress.firstName] First Name. + * + * @param {string} [parameters.billingAddress.lastName] Last Name. + * + * @param {string} [parameters.billingAddress.companyName] Company Name. + * + * @param {string} [parameters.billingAddress.addressLine1] Address Line1. + * + * @param {string} [parameters.billingAddress.addressLine2] Address Line2. + * + * @param {string} [parameters.billingAddress.addressLine3] Address Line3. + * + * @param {string} [parameters.billingAddress.city] Address City. + * + * @param {string} [parameters.billingAddress.region] Address Region. + * + * @param {string} [parameters.billingAddress.country] Country code uses ISO2, + * 2-digit format. + * + * @param {string} [parameters.billingAddress.postalCode] Address Postal Code. + * + * @param {array} [parameters.enabledAzureSKUs] Information about the product. + * + * @param {array} [parameters.invoiceSections] The invoice sections associated + * to the billing profile. + * + * @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 BillingProfile} for more information. + * + * {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 _beginUpdate(billingAccountId, billingProfileId, 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 (billingProfileId === null || billingProfileId === undefined || typeof billingProfileId.valueOf() !== 'string') { + throw new Error('billingProfileId cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{billingProfileId}', encodeURIComponent(billingProfileId)); + 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['BillingProfile']().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 !== 202) { + 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['BillingProfile']().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 BillingProfiles. */ +class BillingProfiles { + /** + * Create a BillingProfiles. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._update = _update; + this._beginUpdate = _beginUpdate; + } + + /** + * Get the billing profile by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections. + * + * @param {object} [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, billingProfileId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountId, billingProfileId, 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 billing profile by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections. + * + * @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 {BillingProfile} - 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 BillingProfile} for more information. + * + * {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, billingProfileId, 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, billingProfileId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountId, billingProfileId, options, optionalCallback); + } + } + + /** + * The operation to update a billing profile. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {object} parameters Parameters supplied to the update billing profile + * operation. + * + * @param {string} [parameters.displayName] The billing profile name. + * + * @param {string} [parameters.poNumber] Purchase order number. + * + * @param {object} [parameters.billingAddress] Billing address. + * + * @param {string} [parameters.billingAddress.firstName] First Name. + * + * @param {string} [parameters.billingAddress.lastName] Last Name. + * + * @param {string} [parameters.billingAddress.companyName] Company Name. + * + * @param {string} [parameters.billingAddress.addressLine1] Address Line1. + * + * @param {string} [parameters.billingAddress.addressLine2] Address Line2. + * + * @param {string} [parameters.billingAddress.addressLine3] Address Line3. + * + * @param {string} [parameters.billingAddress.city] Address City. + * + * @param {string} [parameters.billingAddress.region] Address Region. + * + * @param {string} [parameters.billingAddress.country] Country code uses ISO2, + * 2-digit format. + * + * @param {string} [parameters.billingAddress.postalCode] Address Postal Code. + * + * @param {array} [parameters.enabledAzureSKUs] Information about the product. + * + * @param {array} [parameters.invoiceSections] The invoice sections associated + * to the billing profile. + * + * @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. + */ + updateWithHttpOperationResponse(billingAccountId, billingProfileId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(billingAccountId, billingProfileId, 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 update a billing profile. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {object} parameters Parameters supplied to the update billing profile + * operation. + * + * @param {string} [parameters.displayName] The billing profile name. + * + * @param {string} [parameters.poNumber] Purchase order number. + * + * @param {object} [parameters.billingAddress] Billing address. + * + * @param {string} [parameters.billingAddress.firstName] First Name. + * + * @param {string} [parameters.billingAddress.lastName] Last Name. + * + * @param {string} [parameters.billingAddress.companyName] Company Name. + * + * @param {string} [parameters.billingAddress.addressLine1] Address Line1. + * + * @param {string} [parameters.billingAddress.addressLine2] Address Line2. + * + * @param {string} [parameters.billingAddress.addressLine3] Address Line3. + * + * @param {string} [parameters.billingAddress.city] Address City. + * + * @param {string} [parameters.billingAddress.region] Address Region. + * + * @param {string} [parameters.billingAddress.country] Country code uses ISO2, + * 2-digit format. + * + * @param {string} [parameters.billingAddress.postalCode] Address Postal Code. + * + * @param {array} [parameters.enabledAzureSKUs] Information about the product. + * + * @param {array} [parameters.invoiceSections] The invoice sections associated + * to the billing profile. + * + * @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 {BillingProfile} - 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 BillingProfile} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + update(billingAccountId, billingProfileId, 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._update(billingAccountId, billingProfileId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(billingAccountId, billingProfileId, parameters, options, optionalCallback); + } + } + + /** + * The operation to update a billing profile. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {object} parameters Parameters supplied to the update billing profile + * operation. + * + * @param {string} [parameters.displayName] The billing profile name. + * + * @param {string} [parameters.poNumber] Purchase order number. + * + * @param {object} [parameters.billingAddress] Billing address. + * + * @param {string} [parameters.billingAddress.firstName] First Name. + * + * @param {string} [parameters.billingAddress.lastName] Last Name. + * + * @param {string} [parameters.billingAddress.companyName] Company Name. + * + * @param {string} [parameters.billingAddress.addressLine1] Address Line1. + * + * @param {string} [parameters.billingAddress.addressLine2] Address Line2. + * + * @param {string} [parameters.billingAddress.addressLine3] Address Line3. + * + * @param {string} [parameters.billingAddress.city] Address City. + * + * @param {string} [parameters.billingAddress.region] Address Region. + * + * @param {string} [parameters.billingAddress.country] Country code uses ISO2, + * 2-digit format. + * + * @param {string} [parameters.billingAddress.postalCode] Address Postal Code. + * + * @param {array} [parameters.enabledAzureSKUs] Information about the product. + * + * @param {array} [parameters.invoiceSections] The invoice sections associated + * to the billing profile. + * + * @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. + */ + beginUpdateWithHttpOperationResponse(billingAccountId, billingProfileId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginUpdate(billingAccountId, billingProfileId, 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 update a billing profile. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {object} parameters Parameters supplied to the update billing profile + * operation. + * + * @param {string} [parameters.displayName] The billing profile name. + * + * @param {string} [parameters.poNumber] Purchase order number. + * + * @param {object} [parameters.billingAddress] Billing address. + * + * @param {string} [parameters.billingAddress.firstName] First Name. + * + * @param {string} [parameters.billingAddress.lastName] Last Name. + * + * @param {string} [parameters.billingAddress.companyName] Company Name. + * + * @param {string} [parameters.billingAddress.addressLine1] Address Line1. + * + * @param {string} [parameters.billingAddress.addressLine2] Address Line2. + * + * @param {string} [parameters.billingAddress.addressLine3] Address Line3. + * + * @param {string} [parameters.billingAddress.city] Address City. + * + * @param {string} [parameters.billingAddress.region] Address Region. + * + * @param {string} [parameters.billingAddress.country] Country code uses ISO2, + * 2-digit format. + * + * @param {string} [parameters.billingAddress.postalCode] Address Postal Code. + * + * @param {array} [parameters.enabledAzureSKUs] Information about the product. + * + * @param {array} [parameters.invoiceSections] The invoice sections associated + * to the billing profile. + * + * @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 {BillingProfile} - 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 BillingProfile} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + beginUpdate(billingAccountId, billingProfileId, 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._beginUpdate(billingAccountId, billingProfileId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginUpdate(billingAccountId, billingProfileId, parameters, options, optionalCallback); + } + } + +} + +module.exports = BillingProfiles; diff --git a/lib/services/billingManagement/lib/operations/billingProfilesByBillingAccountId.js b/lib/services/billingManagement/lib/operations/billingProfilesByBillingAccountId.js new file mode 100644 index 0000000000..eb39a9d19e --- /dev/null +++ b/lib/services/billingManagement/lib/operations/billingProfilesByBillingAccountId.js @@ -0,0 +1,263 @@ +/* + * 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 billing profiles for a user which that user has access to. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections. + * + * @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 BillingProfileListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(billingAccountId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + // 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 (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + 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['BillingProfileListResult']().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 BillingProfilesByBillingAccountId. */ +class BillingProfilesByBillingAccountId { + /** + * Create a BillingProfilesByBillingAccountId. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + } + + /** + * Lists all billing profiles for a user which that user has access to. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(billingAccountId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all billing profiles for a user which that user has access to. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections. + * + * @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 {BillingProfileListResult} - 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 BillingProfileListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(billingAccountId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(billingAccountId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountId, options, optionalCallback); + } + } + +} + +module.exports = BillingProfilesByBillingAccountId; diff --git a/lib/services/billingManagement/lib/operations/billingPropertyOperations.js b/lib/services/billingManagement/lib/operations/billingPropertyOperations.js new file mode 100644 index 0000000000..02ff5d9274 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/billingPropertyOperations.js @@ -0,0 +1,242 @@ +/* + * 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 billing property by subscription 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 BillingProperty} for more information. + * + * {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.'); + } + // 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 (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.Billing/billingProperty'; + 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['BillingProperty']().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 BillingPropertyOperations. */ +class BillingPropertyOperations { + /** + * Create a BillingPropertyOperations. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + } + + /** + * Get billing property by subscription 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(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; + }); + }); + } + + /** + * Get billing property by subscription 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 {BillingProperty} - 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 BillingProperty} for more information. + * + * {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); + } + } + +} + +module.exports = BillingPropertyOperations; diff --git a/lib/services/billingManagement/lib/operations/billingSubscription.js b/lib/services/billingManagement/lib/operations/billingSubscription.js new file mode 100644 index 0000000000..83d49ea539 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/billingSubscription.js @@ -0,0 +1,715 @@ +/* + * 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 a single billing subscription by name. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {string} billingSubscriptionId Billing Subscription 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 BillingSubscriptionSummary} for more + * information. + * + * {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, invoiceSectionId, billingSubscriptionId, 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 (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 (invoiceSectionId === null || invoiceSectionId === undefined || typeof invoiceSectionId.valueOf() !== 'string') { + throw new Error('invoiceSectionId cannot be null or undefined and it must be of type string.'); + } + if (billingSubscriptionId === null || billingSubscriptionId === undefined || typeof billingSubscriptionId.valueOf() !== 'string') { + throw new Error('billingSubscriptionId 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.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}/billingSubscriptions/{billingSubscriptionId}'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{invoiceSectionId}', encodeURIComponent(invoiceSectionId)); + requestUrl = requestUrl.replace('{billingSubscriptionId}', encodeURIComponent(billingSubscriptionId)); + 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['BillingSubscriptionSummary']().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); + }); +} + + +/** + * Transfers the GTM subscription from one invoice section to another within a + * billing account. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionId] The destination + * invoiceSectionId. + * + * @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 TransferBillingSubscriptionResult} for more + * information. + * + * {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 _transfer(billingAccountId, invoiceSectionId, 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.'); + } + + // Send request + this.beginTransfer(billingAccountId, invoiceSectionId, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['TransferBillingSubscriptionResult']().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); + }); + }); +} + +/** + * Transfers the GTM subscription from one invoice section to another within a + * billing account. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionId] The destination + * invoiceSectionId. + * + * @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 TransferBillingSubscriptionResult} for more + * information. + * + * {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 _beginTransfer(billingAccountId, invoiceSectionId, 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 destinationInvoiceSectionId = (options && options.destinationInvoiceSectionId !== undefined) ? options.destinationInvoiceSectionId : undefined; + // Validate + try { + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionId === null || invoiceSectionId === undefined || typeof invoiceSectionId.valueOf() !== 'string') { + throw new Error('invoiceSectionId 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 (destinationInvoiceSectionId !== null && destinationInvoiceSectionId !== undefined && typeof destinationInvoiceSectionId.valueOf() !== 'string') { + throw new Error('destinationInvoiceSectionId 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 parameters; + if (destinationInvoiceSectionId !== null && destinationInvoiceSectionId !== undefined) { + parameters = new client.models['TransferBillingSubscriptionRequestProperties'](); + parameters.destinationInvoiceSectionId = destinationInvoiceSectionId; + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}/billingSubscriptions/{subscriptionId}/transfer'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{invoiceSectionId}', encodeURIComponent(invoiceSectionId)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + 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['TransferBillingSubscriptionRequestProperties']().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 !== 202) { + 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['TransferBillingSubscriptionResult']().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 BillingSubscription. */ +class BillingSubscription { + /** + * Create a BillingSubscription. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._transfer = _transfer; + this._beginTransfer = _beginTransfer; + } + + /** + * Get a single billing subscription by name. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {string} billingSubscriptionId Billing Subscription 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, invoiceSectionId, billingSubscriptionId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountId, invoiceSectionId, billingSubscriptionId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get a single billing subscription by name. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {string} billingSubscriptionId Billing Subscription 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 {BillingSubscriptionSummary} - 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 BillingSubscriptionSummary} for more + * information. + * + * {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, invoiceSectionId, billingSubscriptionId, 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, invoiceSectionId, billingSubscriptionId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountId, invoiceSectionId, billingSubscriptionId, options, optionalCallback); + } + } + + /** + * Transfers the GTM subscription from one invoice section to another within a + * billing account. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionId] The destination + * invoiceSectionId. + * + * @param {object} [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. + */ + transferWithHttpOperationResponse(billingAccountId, invoiceSectionId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._transfer(billingAccountId, invoiceSectionId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Transfers the GTM subscription from one invoice section to another within a + * billing account. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionId] The destination + * invoiceSectionId. + * + * @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 {TransferBillingSubscriptionResult} - 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 TransferBillingSubscriptionResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + transfer(billingAccountId, invoiceSectionId, 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._transfer(billingAccountId, invoiceSectionId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._transfer(billingAccountId, invoiceSectionId, options, optionalCallback); + } + } + + /** + * Transfers the GTM subscription from one invoice section to another within a + * billing account. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionId] The destination + * invoiceSectionId. + * + * @param {object} [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. + */ + beginTransferWithHttpOperationResponse(billingAccountId, invoiceSectionId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginTransfer(billingAccountId, invoiceSectionId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Transfers the GTM subscription from one invoice section to another within a + * billing account. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionId] The destination + * invoiceSectionId. + * + * @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 {TransferBillingSubscriptionResult} - 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 TransferBillingSubscriptionResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + beginTransfer(billingAccountId, invoiceSectionId, 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._beginTransfer(billingAccountId, invoiceSectionId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginTransfer(billingAccountId, invoiceSectionId, options, optionalCallback); + } + } + +} + +module.exports = BillingSubscription; diff --git a/lib/services/billingManagement/lib/operations/billingSubscriptionsByBillingProfile.js b/lib/services/billingManagement/lib/operations/billingSubscriptionsByBillingProfile.js new file mode 100644 index 0000000000..913db69552 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/billingSubscriptionsByBillingProfile.js @@ -0,0 +1,260 @@ +/* + * 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 billing subscriptions by billingProfileId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile 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 BillingSubscriptionsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(billingAccountId, billingProfileId, 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 (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 (billingProfileId === null || billingProfileId === undefined || typeof billingProfileId.valueOf() !== 'string') { + throw new Error('billingProfileId 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.Billing/billingAccounts/{billingAccountId}/billingProfile/{billingProfileId}/billingSubscriptions'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{billingProfileId}', encodeURIComponent(billingProfileId)); + 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['BillingSubscriptionsListResult']().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 BillingSubscriptionsByBillingProfile. */ +class BillingSubscriptionsByBillingProfile { + /** + * Create a BillingSubscriptionsByBillingProfile. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + } + + /** + * Lists billing subscriptions by billingProfileId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile 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. + */ + listWithHttpOperationResponse(billingAccountId, billingProfileId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountId, billingProfileId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists billing subscriptions by billingProfileId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile 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 {BillingSubscriptionsListResult} - 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 BillingSubscriptionsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(billingAccountId, billingProfileId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(billingAccountId, billingProfileId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountId, billingProfileId, options, optionalCallback); + } + } + +} + +module.exports = BillingSubscriptionsByBillingProfile; diff --git a/lib/services/billingManagement/lib/operations/billingSubscriptionsByInvoiceSection.js b/lib/services/billingManagement/lib/operations/billingSubscriptionsByInvoiceSection.js new file mode 100644 index 0000000000..f4a209f9d6 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/billingSubscriptionsByInvoiceSection.js @@ -0,0 +1,260 @@ +/* + * 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 billing subscription by invoiceSectionId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection 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 BillingSubscriptionsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(billingAccountId, invoiceSectionId, 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 (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 (invoiceSectionId === null || invoiceSectionId === undefined || typeof invoiceSectionId.valueOf() !== 'string') { + throw new Error('invoiceSectionId 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.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}/billingSubscriptions'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{invoiceSectionId}', encodeURIComponent(invoiceSectionId)); + 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['BillingSubscriptionsListResult']().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 BillingSubscriptionsByInvoiceSection. */ +class BillingSubscriptionsByInvoiceSection { + /** + * Create a BillingSubscriptionsByInvoiceSection. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + } + + /** + * Lists billing subscription by invoiceSectionId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection 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. + */ + listWithHttpOperationResponse(billingAccountId, invoiceSectionId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountId, invoiceSectionId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists billing subscription by invoiceSectionId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection 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 {BillingSubscriptionsListResult} - 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 BillingSubscriptionsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(billingAccountId, invoiceSectionId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(billingAccountId, invoiceSectionId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountId, invoiceSectionId, options, optionalCallback); + } + } + +} + +module.exports = BillingSubscriptionsByInvoiceSection; diff --git a/lib/services/billingManagement/lib/operations/departments.js b/lib/services/billingManagement/lib/operations/departments.js new file mode 100644 index 0000000000..704b05a4bb --- /dev/null +++ b/lib/services/billingManagement/lib/operations/departments.js @@ -0,0 +1,296 @@ +/* + * 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 the department by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} departmentId Department Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * enrollmentAccounts. + * + * @param {string} [options.filter] 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 {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 Department} for more information. + * + * {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, departmentId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + // 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 (departmentId === null || departmentId === undefined || typeof departmentId.valueOf() !== 'string') { + throw new Error('departmentId cannot be null or undefined and it must be of type string.'); + } + if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{departmentId}', encodeURIComponent(departmentId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + 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['Department']().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 Departments. */ +class Departments { + /** + * Create a Departments. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + } + + /** + * Get the department by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} departmentId Department Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * enrollmentAccounts. + * + * @param {string} [options.filter] 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 {object} [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, departmentId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountId, departmentId, 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 department by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} departmentId Department Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * enrollmentAccounts. + * + * @param {string} [options.filter] 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 {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 {Department} - 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 Department} for more information. + * + * {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, departmentId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(billingAccountId, departmentId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountId, departmentId, options, optionalCallback); + } + } + +} + +module.exports = Departments; diff --git a/lib/services/billingManagement/lib/operations/departmentsByBillingAccountId.js b/lib/services/billingManagement/lib/operations/departmentsByBillingAccountId.js new file mode 100644 index 0000000000..7999b8a40f --- /dev/null +++ b/lib/services/billingManagement/lib/operations/departmentsByBillingAccountId.js @@ -0,0 +1,286 @@ +/* + * 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 departments for a user which he has access to. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * enrollmentAccounts. + * + * @param {string} [options.filter] 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 {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 DepartmentListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(billingAccountId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + // 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 (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 (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + 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['DepartmentListResult']().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 DepartmentsByBillingAccountId. */ +class DepartmentsByBillingAccountId { + /** + * Create a DepartmentsByBillingAccountId. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + } + + /** + * Lists all departments for a user which he has access to. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * enrollmentAccounts. + * + * @param {string} [options.filter] 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(billingAccountId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all departments for a user which he has access to. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * enrollmentAccounts. + * + * @param {string} [options.filter] 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 {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 {DepartmentListResult} - 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 DepartmentListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(billingAccountId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(billingAccountId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountId, options, optionalCallback); + } + } + +} + +module.exports = DepartmentsByBillingAccountId; diff --git a/lib/services/billingManagement/lib/operations/enrollmentAccounts.js b/lib/services/billingManagement/lib/operations/enrollmentAccounts.js index d616f11d45..487d1cac2b 100644 --- a/lib/services/billingManagement/lib/operations/enrollmentAccounts.js +++ b/lib/services/billingManagement/lib/operations/enrollmentAccounts.js @@ -15,142 +15,20 @@ const msRestAzure = require('ms-rest-azure'); const WebResource = msRest.WebResource; /** - * Lists the enrollment accounts the caller has access to. + * Get the enrollment account by id. * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request + * @param {string} billingAccountId billing Account Id. * - * @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 EnrollmentAccountListResult} for more - * information. - * - * {object} [request] - The HTTP Request object if an error did not occur. + * @param {string} enrollmentAccountId Enrollment Account Id. * - * {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.Billing/enrollmentAccounts'; - 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['EnrollmentAccountListResult']().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 a enrollment account by name. + * @param {object} [options] Optional Parameters. * - * @param {string} name Enrollment Account name. + * @param {string} [options.expand] May be used to expand the Department. * - * @param {object} [options] Optional Parameters. + * @param {string} [options.filter] 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 {object} [options.customHeaders] Headers that will be added to the * request @@ -168,7 +46,7 @@ function _list(options, callback) { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _get(name, options, callback) { +function _getByEnrollmentAccountAccountId(billingAccountId, enrollmentAccountId, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -178,14 +56,25 @@ function _get(name, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + let filter = (options && options.filter !== undefined) ? options.filter : undefined; // Validate try { - if (name === null || name === undefined || typeof name.valueOf() !== 'string') { - throw new Error('name 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 (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 (enrollmentAccountId === null || enrollmentAccountId === undefined || typeof enrollmentAccountId.valueOf() !== 'string') { + throw new Error('enrollmentAccountId cannot be null or undefined and it must be of type string.'); + } + if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } if (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.'); } @@ -195,10 +84,17 @@ function _get(name, options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/enrollmentAccounts/{name}'; - requestUrl = requestUrl.replace('{name}', encodeURIComponent(name)); + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{enrollmentAccountId}', encodeURIComponent(enrollmentAccountId)); let queryParameters = []; queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); } @@ -281,135 +177,6 @@ function _get(name, options, callback) { }); } -/** - * Lists the enrollment accounts the caller has access to. - * - * @param {string} nextPageLink The NextLink from 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 EnrollmentAccountListResult} for more - * information. - * - * {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['EnrollmentAccountListResult']().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 EnrollmentAccounts. */ class EnrollmentAccounts { /** @@ -418,96 +185,24 @@ class EnrollmentAccounts { */ constructor(client) { this.client = client; - this._list = _list; - this._get = _get; - this._listNext = _listNext; + this._getByEnrollmentAccountAccountId = _getByEnrollmentAccountAccountId; } /** - * Lists the enrollment accounts the caller has access to. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned + * Get the enrollment account by id. * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @param {string} billingAccountId billing Account Id. * - * @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 enrollment accounts the caller has access to. + * @param {string} enrollmentAccountId Enrollment 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 {EnrollmentAccountListResult} - 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 EnrollmentAccountListResult} for more - * information. - * - * {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); - } - } - - /** - * Gets a enrollment account by name. - * - * @param {string} name Enrollment Account name. + * @param {string} [options.expand] May be used to expand the Department. * - * @param {object} [options] Optional Parameters. + * @param {string} [options.filter] 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 {object} [options.customHeaders] Headers that will be added to the * request @@ -518,11 +213,11 @@ class EnrollmentAccounts { * * @reject {Error} - The error object. */ - getWithHttpOperationResponse(name, options) { + getByEnrollmentAccountAccountIdWithHttpOperationResponse(billingAccountId, enrollmentAccountId, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._get(name, options, (err, result, request, response) => { + self._getByEnrollmentAccountAccountId(billingAccountId, enrollmentAccountId, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -533,95 +228,20 @@ class EnrollmentAccounts { } /** - * Gets a enrollment account by name. - * - * @param {string} name Enrollment Account 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 {EnrollmentAccount} - 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 EnrollmentAccount} for more information. - * - * {object} [request] - The HTTP Request object if an error did not occur. + * Get the enrollment account by id. * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - get(name, 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(name, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._get(name, options, optionalCallback); - } - } - - /** - * Lists the enrollment accounts the caller has access to. + * @param {string} billingAccountId billing Account Id. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} enrollmentAccountId Enrollment 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. - */ - 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 enrollment accounts the caller has access to. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} [options.expand] May be used to expand the Department. * - * @param {object} [options] Optional Parameters. + * @param {string} [options.filter] 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 {object} [options.customHeaders] Headers that will be added to the * request @@ -633,7 +253,7 @@ class EnrollmentAccounts { * * {Promise} A promise is returned * - * @resolve {EnrollmentAccountListResult} - The deserialized result object. + * @resolve {EnrollmentAccount} - The deserialized result object. * * @reject {Error} - The error object. * @@ -642,14 +262,13 @@ class EnrollmentAccounts { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link EnrollmentAccountListResult} for more - * information. + * See {@link EnrollmentAccount} for more information. * * {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) { + getByEnrollmentAccountAccountId(billingAccountId, enrollmentAccountId, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -658,14 +277,14 @@ class EnrollmentAccounts { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._listNext(nextPageLink, options, (err, result, request, response) => { + self._getByEnrollmentAccountAccountId(billingAccountId, enrollmentAccountId, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._listNext(nextPageLink, options, optionalCallback); + return self._getByEnrollmentAccountAccountId(billingAccountId, enrollmentAccountId, options, optionalCallback); } } diff --git a/lib/services/billingManagement/lib/operations/enrollmentAccountsByBillingAccountId.js b/lib/services/billingManagement/lib/operations/enrollmentAccountsByBillingAccountId.js new file mode 100644 index 0000000000..4f74f0a8e8 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/enrollmentAccountsByBillingAccountId.js @@ -0,0 +1,285 @@ +/* + * 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 Enrollment Accounts for a user which he has access to. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the department. + * + * @param {string} [options.filter] 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 {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 EnrollmentAccountListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(billingAccountId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + // 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 (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 (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + 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['EnrollmentAccountListResult']().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 EnrollmentAccountsByBillingAccountId. */ +class EnrollmentAccountsByBillingAccountId { + /** + * Create a EnrollmentAccountsByBillingAccountId. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + } + + /** + * Lists all Enrollment Accounts for a user which he has access to. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the department. + * + * @param {string} [options.filter] 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(billingAccountId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all Enrollment Accounts for a user which he has access to. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the department. + * + * @param {string} [options.filter] 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 {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 {EnrollmentAccountListResult} - 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 EnrollmentAccountListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(billingAccountId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(billingAccountId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountId, options, optionalCallback); + } + } + +} + +module.exports = EnrollmentAccountsByBillingAccountId; diff --git a/lib/services/billingManagement/lib/operations/index.d.ts b/lib/services/billingManagement/lib/operations/index.d.ts index 3131b77c2e..2e1d6b97e0 100644 --- a/lib/services/billingManagement/lib/operations/index.d.ts +++ b/lib/services/billingManagement/lib/operations/index.d.ts @@ -12,17 +12,2249 @@ import { ServiceClientOptions, RequestOptions, ServiceCallback, HttpOperationRes import * as models from '../models'; +/** + * @class + * BillingAccounts + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface BillingAccounts { + + + /** + * Lists all billing accounts for a user which he has access to. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections + * and billingProfiles. + * + * @param {object} [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, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all billing accounts for a user which he has access to. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections + * and billingProfiles. + * + * @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 {BillingAccountListResult} - 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. + * + * {BillingAccountListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BillingAccountListResult} 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, customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { expand? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get the billing account by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections + * and billingProfiles. + * + * @param {object} [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?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the billing account by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections + * and billingProfiles. + * + * @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 {BillingAccount} - 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. + * + * {BillingAccount} [result] - The deserialized result object if an error did not occur. + * See {@link BillingAccount} 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?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountId: string, callback: ServiceCallback): void; + get(billingAccountId: string, options: { expand? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * BillingAccountsWithCreateInvoiceSectionPermission + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface BillingAccountsWithCreateInvoiceSectionPermission { + + + /** + * Lists all billing accounts with create invoiceSection permission for a user. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections + * and billingProfiles. + * + * @param {object} [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, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all billing accounts with create invoiceSection permission for a user. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections + * and billingProfiles. + * + * @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 {BillingAccountListResult} - 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. + * + * {BillingAccountListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BillingAccountListResult} 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, customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { expand? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * AvailableBalanceByBillingProfile + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface AvailableBalanceByBillingProfile { + + + /** + * The latest available credit balance for a given billingAccountId and + * billingProfileId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile 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, billingProfileId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The latest available credit balance for a given billingAccountId and + * billingProfileId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile 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 {AvailableBalance} - 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. + * + * {AvailableBalance} [result] - The deserialized result object if an error did not occur. + * See {@link AvailableBalance} 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, billingProfileId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountId: string, billingProfileId: string, callback: ServiceCallback): void; + get(billingAccountId: string, billingProfileId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * PaymentMethodsByBillingProfile + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface PaymentMethodsByBillingProfile { + + + /** + * Lists the Payment Methods by billing profile Id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile 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. + */ + listWithHttpOperationResponse(billingAccountId: string, billingProfileId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the Payment Methods by billing profile Id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile 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 {PaymentMethodsListResult} - 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. + * + * {PaymentMethodsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link PaymentMethodsListResult} 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(billingAccountId: string, billingProfileId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountId: string, billingProfileId: string, callback: ServiceCallback): void; + list(billingAccountId: string, billingProfileId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the Payment Methods by billing profile Id. + * + * @param {string} nextPageLink The NextLink from 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 Payment Methods by billing profile Id. + * + * @param {string} nextPageLink The NextLink from 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 {PaymentMethodsListResult} - 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. + * + * {PaymentMethodsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link PaymentMethodsListResult} 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 + * BillingProfilesByBillingAccountId + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface BillingProfilesByBillingAccountId { + + + /** + * Lists all billing profiles for a user which that user has access to. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections. + * + * @param {object} [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(billingAccountId: string, options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all billing profiles for a user which that user has access to. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections. + * + * @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 {BillingProfileListResult} - 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. + * + * {BillingProfileListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BillingProfileListResult} 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(billingAccountId: string, options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountId: string, callback: ServiceCallback): void; + list(billingAccountId: string, options: { expand? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * BillingProfiles + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface BillingProfiles { + + + /** + * Get the billing profile by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections. + * + * @param {object} [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, billingProfileId: string, options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the billing profile by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the invoiceSections. + * + * @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 {BillingProfile} - 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. + * + * {BillingProfile} [result] - The deserialized result object if an error did not occur. + * See {@link BillingProfile} 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, billingProfileId: string, options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountId: string, billingProfileId: string, callback: ServiceCallback): void; + get(billingAccountId: string, billingProfileId: string, options: { expand? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to update a billing profile. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {object} parameters Parameters supplied to the update billing profile + * operation. + * + * @param {string} [parameters.displayName] The billing profile name. + * + * @param {string} [parameters.poNumber] Purchase order number. + * + * @param {object} [parameters.billingAddress] Billing address. + * + * @param {string} [parameters.billingAddress.firstName] First Name. + * + * @param {string} [parameters.billingAddress.lastName] Last Name. + * + * @param {string} [parameters.billingAddress.companyName] Company Name. + * + * @param {string} [parameters.billingAddress.addressLine1] Address Line1. + * + * @param {string} [parameters.billingAddress.addressLine2] Address Line2. + * + * @param {string} [parameters.billingAddress.addressLine3] Address Line3. + * + * @param {string} [parameters.billingAddress.city] Address City. + * + * @param {string} [parameters.billingAddress.region] Address Region. + * + * @param {string} [parameters.billingAddress.country] Country code uses ISO2, + * 2-digit format. + * + * @param {string} [parameters.billingAddress.postalCode] Address Postal Code. + * + * @param {array} [parameters.enabledAzureSKUs] Information about the product. + * + * @param {array} [parameters.invoiceSections] The invoice sections associated + * to the billing profile. + * + * @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. + */ + updateWithHttpOperationResponse(billingAccountId: string, billingProfileId: string, parameters: models.BillingProfile, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to update a billing profile. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {object} parameters Parameters supplied to the update billing profile + * operation. + * + * @param {string} [parameters.displayName] The billing profile name. + * + * @param {string} [parameters.poNumber] Purchase order number. + * + * @param {object} [parameters.billingAddress] Billing address. + * + * @param {string} [parameters.billingAddress.firstName] First Name. + * + * @param {string} [parameters.billingAddress.lastName] Last Name. + * + * @param {string} [parameters.billingAddress.companyName] Company Name. + * + * @param {string} [parameters.billingAddress.addressLine1] Address Line1. + * + * @param {string} [parameters.billingAddress.addressLine2] Address Line2. + * + * @param {string} [parameters.billingAddress.addressLine3] Address Line3. + * + * @param {string} [parameters.billingAddress.city] Address City. + * + * @param {string} [parameters.billingAddress.region] Address Region. + * + * @param {string} [parameters.billingAddress.country] Country code uses ISO2, + * 2-digit format. + * + * @param {string} [parameters.billingAddress.postalCode] Address Postal Code. + * + * @param {array} [parameters.enabledAzureSKUs] Information about the product. + * + * @param {array} [parameters.invoiceSections] The invoice sections associated + * to the billing profile. + * + * @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 {BillingProfile} - 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. + * + * {BillingProfile} [result] - The deserialized result object if an error did not occur. + * See {@link BillingProfile} 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. + */ + update(billingAccountId: string, billingProfileId: string, parameters: models.BillingProfile, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(billingAccountId: string, billingProfileId: string, parameters: models.BillingProfile, callback: ServiceCallback): void; + update(billingAccountId: string, billingProfileId: string, parameters: models.BillingProfile, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to update a billing profile. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {object} parameters Parameters supplied to the update billing profile + * operation. + * + * @param {string} [parameters.displayName] The billing profile name. + * + * @param {string} [parameters.poNumber] Purchase order number. + * + * @param {object} [parameters.billingAddress] Billing address. + * + * @param {string} [parameters.billingAddress.firstName] First Name. + * + * @param {string} [parameters.billingAddress.lastName] Last Name. + * + * @param {string} [parameters.billingAddress.companyName] Company Name. + * + * @param {string} [parameters.billingAddress.addressLine1] Address Line1. + * + * @param {string} [parameters.billingAddress.addressLine2] Address Line2. + * + * @param {string} [parameters.billingAddress.addressLine3] Address Line3. + * + * @param {string} [parameters.billingAddress.city] Address City. + * + * @param {string} [parameters.billingAddress.region] Address Region. + * + * @param {string} [parameters.billingAddress.country] Country code uses ISO2, + * 2-digit format. + * + * @param {string} [parameters.billingAddress.postalCode] Address Postal Code. + * + * @param {array} [parameters.enabledAzureSKUs] Information about the product. + * + * @param {array} [parameters.invoiceSections] The invoice sections associated + * to the billing profile. + * + * @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. + */ + beginUpdateWithHttpOperationResponse(billingAccountId: string, billingProfileId: string, parameters: models.BillingProfile, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to update a billing profile. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {object} parameters Parameters supplied to the update billing profile + * operation. + * + * @param {string} [parameters.displayName] The billing profile name. + * + * @param {string} [parameters.poNumber] Purchase order number. + * + * @param {object} [parameters.billingAddress] Billing address. + * + * @param {string} [parameters.billingAddress.firstName] First Name. + * + * @param {string} [parameters.billingAddress.lastName] Last Name. + * + * @param {string} [parameters.billingAddress.companyName] Company Name. + * + * @param {string} [parameters.billingAddress.addressLine1] Address Line1. + * + * @param {string} [parameters.billingAddress.addressLine2] Address Line2. + * + * @param {string} [parameters.billingAddress.addressLine3] Address Line3. + * + * @param {string} [parameters.billingAddress.city] Address City. + * + * @param {string} [parameters.billingAddress.region] Address Region. + * + * @param {string} [parameters.billingAddress.country] Country code uses ISO2, + * 2-digit format. + * + * @param {string} [parameters.billingAddress.postalCode] Address Postal Code. + * + * @param {array} [parameters.enabledAzureSKUs] Information about the product. + * + * @param {array} [parameters.invoiceSections] The invoice sections associated + * to the billing profile. + * + * @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 {BillingProfile} - 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. + * + * {BillingProfile} [result] - The deserialized result object if an error did not occur. + * See {@link BillingProfile} 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. + */ + beginUpdate(billingAccountId: string, billingProfileId: string, parameters: models.BillingProfile, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginUpdate(billingAccountId: string, billingProfileId: string, parameters: models.BillingProfile, callback: ServiceCallback): void; + beginUpdate(billingAccountId: string, billingProfileId: string, parameters: models.BillingProfile, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * InvoiceSectionsByBillingAccountId + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface InvoiceSectionsByBillingAccountId { + + + /** + * Lists all invoice sections for a user which he has access to. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the billingProfiles. + * + * @param {object} [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(billingAccountId: string, options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all invoice sections for a user which he has access to. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the billingProfiles. + * + * @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 {InvoiceSectionListResult} - 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. + * + * {InvoiceSectionListResult} [result] - The deserialized result object if an error did not occur. + * See {@link InvoiceSectionListResult} 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(billingAccountId: string, options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountId: string, callback: ServiceCallback): void; + list(billingAccountId: string, options: { expand? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * InvoiceSections + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface InvoiceSections { + + + /** + * The operation to create a InvoiceSection. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} parameters Parameters supplied to the Create InvoiceSection + * operation. + * + * @param {string} [parameters.displayName] The name of the InvoiceSection. + * + * @param {array} [parameters.billingProfiles] The billing profiles associated + * to the billing account. + * + * @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. + */ + createWithHttpOperationResponse(billingAccountId: string, parameters: models.InvoiceSectionProperties, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to create a InvoiceSection. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} parameters Parameters supplied to the Create InvoiceSection + * operation. + * + * @param {string} [parameters.displayName] The name of the InvoiceSection. + * + * @param {array} [parameters.billingProfiles] The billing profiles associated + * to the billing account. + * + * @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 {InvoiceSection} - 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. + * + * {InvoiceSection} [result] - The deserialized result object if an error did not occur. + * See {@link InvoiceSection} 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. + */ + create(billingAccountId: string, parameters: models.InvoiceSectionProperties, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + create(billingAccountId: string, parameters: models.InvoiceSectionProperties, callback: ServiceCallback): void; + create(billingAccountId: string, parameters: models.InvoiceSectionProperties, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get the InvoiceSection by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the billingProfiles. + * + * @param {object} [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, invoiceSectionId: string, options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the InvoiceSection by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the billingProfiles. + * + * @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 {InvoiceSection} - 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. + * + * {InvoiceSection} [result] - The deserialized result object if an error did not occur. + * See {@link InvoiceSection} 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, invoiceSectionId: string, options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountId: string, invoiceSectionId: string, callback: ServiceCallback): void; + get(billingAccountId: string, invoiceSectionId: string, options: { expand? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to update a InvoiceSection. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} parameters Parameters supplied to the Create InvoiceSection + * operation. + * + * @param {string} [parameters.displayName] The name of the InvoiceSection. + * + * @param {array} [parameters.billingProfiles] The billing profiles associated + * to the billing account. + * + * @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. + */ + updateWithHttpOperationResponse(billingAccountId: string, invoiceSectionId: string, parameters: models.InvoiceSection, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to update a InvoiceSection. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} parameters Parameters supplied to the Create InvoiceSection + * operation. + * + * @param {string} [parameters.displayName] The name of the InvoiceSection. + * + * @param {array} [parameters.billingProfiles] The billing profiles associated + * to the billing account. + * + * @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 {InvoiceSection} - 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. + * + * {InvoiceSection} [result] - The deserialized result object if an error did not occur. + * See {@link InvoiceSection} 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. + */ + update(billingAccountId: string, invoiceSectionId: string, parameters: models.InvoiceSection, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(billingAccountId: string, invoiceSectionId: string, parameters: models.InvoiceSection, callback: ServiceCallback): void; + update(billingAccountId: string, invoiceSectionId: string, parameters: models.InvoiceSection, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to create a InvoiceSection. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} parameters Parameters supplied to the Create InvoiceSection + * operation. + * + * @param {string} [parameters.displayName] The name of the InvoiceSection. + * + * @param {array} [parameters.billingProfiles] The billing profiles associated + * to the billing account. + * + * @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. + */ + beginCreateWithHttpOperationResponse(billingAccountId: string, parameters: models.InvoiceSectionProperties, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to create a InvoiceSection. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} parameters Parameters supplied to the Create InvoiceSection + * operation. + * + * @param {string} [parameters.displayName] The name of the InvoiceSection. + * + * @param {array} [parameters.billingProfiles] The billing profiles associated + * to the billing account. + * + * @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 {InvoiceSection} - 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. + * + * {InvoiceSection} [result] - The deserialized result object if an error did not occur. + * See {@link InvoiceSection} 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. + */ + beginCreate(billingAccountId: string, parameters: models.InvoiceSectionProperties, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginCreate(billingAccountId: string, parameters: models.InvoiceSectionProperties, callback: ServiceCallback): void; + beginCreate(billingAccountId: string, parameters: models.InvoiceSectionProperties, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to update a InvoiceSection. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} parameters Parameters supplied to the Create InvoiceSection + * operation. + * + * @param {string} [parameters.displayName] The name of the InvoiceSection. + * + * @param {array} [parameters.billingProfiles] The billing profiles associated + * to the billing account. + * + * @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. + */ + beginUpdateWithHttpOperationResponse(billingAccountId: string, invoiceSectionId: string, parameters: models.InvoiceSection, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to update a InvoiceSection. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} parameters Parameters supplied to the Create InvoiceSection + * operation. + * + * @param {string} [parameters.displayName] The name of the InvoiceSection. + * + * @param {array} [parameters.billingProfiles] The billing profiles associated + * to the billing account. + * + * @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 {InvoiceSection} - 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. + * + * {InvoiceSection} [result] - The deserialized result object if an error did not occur. + * See {@link InvoiceSection} 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. + */ + beginUpdate(billingAccountId: string, invoiceSectionId: string, parameters: models.InvoiceSection, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginUpdate(billingAccountId: string, invoiceSectionId: string, parameters: models.InvoiceSection, callback: ServiceCallback): void; + beginUpdate(billingAccountId: string, invoiceSectionId: string, parameters: models.InvoiceSection, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * InvoiceSectionsWithCreateSubscriptionPermission + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface InvoiceSectionsWithCreateSubscriptionPermission { + + + /** + * Lists all invoiceSections with create subscription permission for a user. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the billingProfiles. + * + * @param {object} [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(billingAccountId: string, options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all invoiceSections with create subscription permission for a user. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the billingProfiles. + * + * @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 {InvoiceSectionListResult} - 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. + * + * {InvoiceSectionListResult} [result] - The deserialized result object if an error did not occur. + * See {@link InvoiceSectionListResult} 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(billingAccountId: string, options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountId: string, callback: ServiceCallback): void; + list(billingAccountId: string, options: { expand? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * DepartmentsByBillingAccountId + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface DepartmentsByBillingAccountId { + + + /** + * Lists all departments for a user which he has access to. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * enrollmentAccounts. + * + * @param {string} [options.filter] 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 {object} [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(billingAccountId: string, options?: { expand? : string, filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all departments for a user which he has access to. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * enrollmentAccounts. + * + * @param {string} [options.filter] 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 {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 {DepartmentListResult} - 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. + * + * {DepartmentListResult} [result] - The deserialized result object if an error did not occur. + * See {@link DepartmentListResult} 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(billingAccountId: string, options?: { expand? : string, filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountId: string, callback: ServiceCallback): void; + list(billingAccountId: string, options: { expand? : string, filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * Departments + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface Departments { + + + /** + * Get the department by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} departmentId Department Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * enrollmentAccounts. + * + * @param {string} [options.filter] 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 {object} [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, departmentId: string, options?: { expand? : string, filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the department by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} departmentId Department Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the + * enrollmentAccounts. + * + * @param {string} [options.filter] 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 {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 {Department} - 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. + * + * {Department} [result] - The deserialized result object if an error did not occur. + * See {@link Department} 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, departmentId: string, options?: { expand? : string, filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountId: string, departmentId: string, callback: ServiceCallback): void; + get(billingAccountId: string, departmentId: string, options: { expand? : string, filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * EnrollmentAccountsByBillingAccountId + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface EnrollmentAccountsByBillingAccountId { + + + /** + * Lists all Enrollment Accounts for a user which he has access to. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the department. + * + * @param {string} [options.filter] 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 {object} [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(billingAccountId: string, options?: { expand? : string, filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all Enrollment Accounts for a user which he has access to. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the department. + * + * @param {string} [options.filter] 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 {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 {EnrollmentAccountListResult} - 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. + * + * {EnrollmentAccountListResult} [result] - The deserialized result object if an error did not occur. + * See {@link EnrollmentAccountListResult} 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(billingAccountId: string, options?: { expand? : string, filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountId: string, callback: ServiceCallback): void; + list(billingAccountId: string, options: { expand? : string, filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + /** * @class * EnrollmentAccounts * __NOTE__: An instance of this class is automatically created for an * instance of the BillingManagementClient. */ -export interface EnrollmentAccounts { +export interface EnrollmentAccounts { + + + /** + * Get the enrollment account by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} enrollmentAccountId Enrollment Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the Department. + * + * @param {string} [options.filter] 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 {object} [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. + */ + getByEnrollmentAccountAccountIdWithHttpOperationResponse(billingAccountId: string, enrollmentAccountId: string, options?: { expand? : string, filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the enrollment account by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} enrollmentAccountId Enrollment Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the Department. + * + * @param {string} [options.filter] 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 {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 {EnrollmentAccount} - 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. + * + * {EnrollmentAccount} [result] - The deserialized result object if an error did not occur. + * See {@link EnrollmentAccount} 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. + */ + getByEnrollmentAccountAccountId(billingAccountId: string, enrollmentAccountId: string, options?: { expand? : string, filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + getByEnrollmentAccountAccountId(billingAccountId: string, enrollmentAccountId: string, callback: ServiceCallback): void; + getByEnrollmentAccountAccountId(billingAccountId: string, enrollmentAccountId: string, options: { expand? : string, filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * InvoicesByBillingAccount + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface InvoicesByBillingAccount { + + + /** + * List of invoices for a billing account. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} periodStartDate Invoice period start date. + * + * @param {string} periodEndDate Invoice period end date. + * + * @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(billingAccountId: string, periodStartDate: string, periodEndDate: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * List of invoices for a billing account. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} periodStartDate Invoice period start date. + * + * @param {string} periodEndDate Invoice period end date. + * + * @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 {InvoiceListResult} - 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. + * + * {InvoiceListResult} [result] - The deserialized result object if an error did not occur. + * See {@link InvoiceListResult} 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(billingAccountId: string, periodStartDate: string, periodEndDate: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountId: string, periodStartDate: string, periodEndDate: string, callback: ServiceCallback): void; + list(billingAccountId: string, periodStartDate: string, periodEndDate: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * InvoicePricesheet + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface InvoicePricesheet { + + + /** + * Get pricesheet data for invoice id (invoiceName). + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {string} invoiceName The name of an invoice resource. + * + * @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. + */ + downloadWithHttpOperationResponse(billingAccountId: string, invoiceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get pricesheet data for invoice id (invoiceName). + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {string} invoiceName The name of an invoice resource. + * + * @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 {DownloadUrl} - 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. + * + * {DownloadUrl} [result] - The deserialized result object if an error did not occur. + * See {@link DownloadUrl} 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. + */ + download(billingAccountId: string, invoiceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + download(billingAccountId: string, invoiceName: string, callback: ServiceCallback): void; + download(billingAccountId: string, invoiceName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get pricesheet data for invoice id (invoiceName). + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {string} invoiceName The name of an invoice resource. + * + * @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. + */ + beginDownloadWithHttpOperationResponse(billingAccountId: string, invoiceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get pricesheet data for invoice id (invoiceName). + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {string} invoiceName The name of an invoice resource. + * + * @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 {DownloadUrl} - 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. + * + * {DownloadUrl} [result] - The deserialized result object if an error did not occur. + * See {@link DownloadUrl} 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. + */ + beginDownload(billingAccountId: string, invoiceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginDownload(billingAccountId: string, invoiceName: string, callback: ServiceCallback): void; + beginDownload(billingAccountId: string, invoiceName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * InvoicesByBillingProfile + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface InvoicesByBillingProfile { + + + /** + * List of invoices for a billing profile. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {string} periodStartDate Invoice period start date. + * + * @param {string} periodEndDate Invoice period end date. + * + * @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(billingAccountId: string, billingProfileId: string, periodStartDate: string, periodEndDate: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * List of invoices for a billing profile. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {string} periodStartDate Invoice period start date. + * + * @param {string} periodEndDate Invoice period end date. + * + * @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 {InvoiceListResult} - 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. + * + * {InvoiceListResult} [result] - The deserialized result object if an error did not occur. + * See {@link InvoiceListResult} 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(billingAccountId: string, billingProfileId: string, periodStartDate: string, periodEndDate: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountId: string, billingProfileId: string, periodStartDate: string, periodEndDate: string, callback: ServiceCallback): void; + list(billingAccountId: string, billingProfileId: string, periodStartDate: string, periodEndDate: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * Invoice + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface Invoice { + + + /** + * Get the invoice by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {string} invoiceName Invoide 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, billingProfileId: string, invoiceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the invoice by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {string} invoiceName Invoide 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 {InvoiceSummary} - 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. + * + * {InvoiceSummary} [result] - The deserialized result object if an error did not occur. + * See {@link InvoiceSummary} 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, billingProfileId: string, invoiceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountId: string, billingProfileId: string, invoiceName: string, callback: ServiceCallback): void; + get(billingAccountId: string, billingProfileId: string, invoiceName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ProductsByBillingSubscriptions + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface ProductsByBillingSubscriptions { + + + /** + * Lists billing subscriptions by billingAccountId. + * + * @param {string} billingAccountId 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. + */ + listWithHttpOperationResponse(billingAccountId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists billing subscriptions by billingAccountId. + * + * @param {string} billingAccountId 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 {BillingSubscriptionsListResult} - 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. + * + * {BillingSubscriptionsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BillingSubscriptionsListResult} 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(billingAccountId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountId: string, callback: ServiceCallback): void; + list(billingAccountId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists billing subscriptions by billingAccountId. + * + * @param {string} nextPageLink The NextLink from 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 billing subscriptions by billingAccountId. + * + * @param {string} nextPageLink The NextLink from 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 {BillingSubscriptionsListResult} - 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. + * + * {BillingSubscriptionsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BillingSubscriptionsListResult} 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 + * BillingSubscriptionsByBillingProfile + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface BillingSubscriptionsByBillingProfile { + + + /** + * Lists billing subscriptions by billingProfileId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile 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. + */ + listWithHttpOperationResponse(billingAccountId: string, billingProfileId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists billing subscriptions by billingProfileId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile 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 {BillingSubscriptionsListResult} - 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. + * + * {BillingSubscriptionsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BillingSubscriptionsListResult} 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(billingAccountId: string, billingProfileId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountId: string, billingProfileId: string, callback: ServiceCallback): void; + list(billingAccountId: string, billingProfileId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * BillingSubscriptionsByInvoiceSection + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface BillingSubscriptionsByInvoiceSection { + + + /** + * Lists billing subscription by invoiceSectionId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection 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. + */ + listWithHttpOperationResponse(billingAccountId: string, invoiceSectionId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists billing subscription by invoiceSectionId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection 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 {BillingSubscriptionsListResult} - 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. + * + * {BillingSubscriptionsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BillingSubscriptionsListResult} 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(billingAccountId: string, invoiceSectionId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountId: string, invoiceSectionId: string, callback: ServiceCallback): void; + list(billingAccountId: string, invoiceSectionId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * BillingSubscription + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface BillingSubscription { /** - * Lists the enrollment accounts the caller has access to. + * Get a single billing subscription by name. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {string} billingSubscriptionId Billing Subscription Id. * * @param {object} [options] Optional Parameters. * @@ -31,14 +2263,20 @@ export interface EnrollmentAccounts { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + getWithHttpOperationResponse(billingAccountId: string, invoiceSectionId: string, billingSubscriptionId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Lists the enrollment accounts the caller has access to. + * Get a single billing subscription by name. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {string} billingSubscriptionId Billing Subscription Id. * * @param {object} [options] Optional Parameters. * @@ -52,7 +2290,7 @@ export interface EnrollmentAccounts { * * {Promise} A promise is returned. * - * @resolve {EnrollmentAccountListResult} - The deserialized result object. + * @resolve {BillingSubscriptionSummary} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -60,44 +2298,56 @@ export interface EnrollmentAccounts { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {EnrollmentAccountListResult} [result] - The deserialized result object if an error did not occur. - * See {@link EnrollmentAccountListResult} for more + * {BillingSubscriptionSummary} [result] - The deserialized result object if an error did not occur. + * See {@link BillingSubscriptionSummary} 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; + get(billingAccountId: string, invoiceSectionId: string, billingSubscriptionId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountId: string, invoiceSectionId: string, billingSubscriptionId: string, callback: ServiceCallback): void; + get(billingAccountId: string, invoiceSectionId: string, billingSubscriptionId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Gets a enrollment account by name. + * Transfers the GTM subscription from one invoice section to another within a + * billing account. * - * @param {string} name Enrollment Account name. + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. * * @param {object} [options] Optional Parameters. * + * @param {string} [options.destinationInvoiceSectionId] The destination + * invoiceSectionId. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - getWithHttpOperationResponse(name: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + transferWithHttpOperationResponse(billingAccountId: string, invoiceSectionId: string, options?: { destinationInvoiceSectionId? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets a enrollment account by name. + * Transfers the GTM subscription from one invoice section to another within a + * billing account. + * + * @param {string} billingAccountId billing Account Id. * - * @param {string} name Enrollment Account name. + * @param {string} invoiceSectionId InvoiceSection Id. * * @param {object} [options] Optional Parameters. * + * @param {string} [options.destinationInvoiceSectionId] The destination + * invoiceSectionId. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -108,7 +2358,7 @@ export interface EnrollmentAccounts { * * {Promise} A promise is returned. * - * @resolve {EnrollmentAccount} - The deserialized result object. + * @resolve {TransferBillingSubscriptionResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -116,20 +2366,163 @@ export interface EnrollmentAccounts { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {EnrollmentAccount} [result] - The deserialized result object if an error did not occur. - * See {@link EnrollmentAccount} for more information. + * {TransferBillingSubscriptionResult} [result] - The deserialized result object if an error did not occur. + * See {@link TransferBillingSubscriptionResult} 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. + */ + transfer(billingAccountId: string, invoiceSectionId: string, options?: { destinationInvoiceSectionId? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + transfer(billingAccountId: string, invoiceSectionId: string, callback: ServiceCallback): void; + transfer(billingAccountId: string, invoiceSectionId: string, options: { destinationInvoiceSectionId? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Transfers the GTM subscription from one invoice section to another within a + * billing account. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionId] The destination + * invoiceSectionId. + * + * @param {object} [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. + */ + beginTransferWithHttpOperationResponse(billingAccountId: string, invoiceSectionId: string, options?: { destinationInvoiceSectionId? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Transfers the GTM subscription from one invoice section to another within a + * billing account. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionId] The destination + * invoiceSectionId. + * + * @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 {TransferBillingSubscriptionResult} - 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. + * + * {TransferBillingSubscriptionResult} [result] - The deserialized result object if an error did not occur. + * See {@link TransferBillingSubscriptionResult} 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. + */ + beginTransfer(billingAccountId: string, invoiceSectionId: string, options?: { destinationInvoiceSectionId? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + beginTransfer(billingAccountId: string, invoiceSectionId: string, callback: ServiceCallback): void; + beginTransfer(billingAccountId: string, invoiceSectionId: string, options: { destinationInvoiceSectionId? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ProductsByBillingAccount + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface ProductsByBillingAccount { + + + /** + * Lists products by billingAccountId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter by product type. 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 {object} [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(billingAccountId: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists products by billingAccountId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter by product type. 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 {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 {ProductsListResult} - 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. + * + * {ProductsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ProductsListResult} 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(name: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - get(name: string, callback: ServiceCallback): void; - get(name: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + list(billingAccountId: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountId: string, callback: ServiceCallback): void; + list(billingAccountId: string, options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Lists the enrollment accounts the caller has access to. + * Lists products by billingAccountId. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -141,14 +2534,14 @@ export interface EnrollmentAccounts { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Lists the enrollment accounts the caller has access to. + * Lists products by billingAccountId. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -165,7 +2558,7 @@ export interface EnrollmentAccounts { * * {Promise} A promise is returned. * - * @resolve {EnrollmentAccountListResult} - The deserialized result object. + * @resolve {ProductsListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -173,78 +2566,65 @@ export interface EnrollmentAccounts { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {EnrollmentAccountListResult} [result] - The deserialized result object if an error did not occur. - * See {@link EnrollmentAccountListResult} for more - * information. + * {ProductsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ProductsListResult} 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; + 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 - * BillingPeriods + * ProductsByInvoiceSection * __NOTE__: An instance of this class is automatically created for an * instance of the BillingManagementClient. */ -export interface BillingPeriods { +export interface ProductsByInvoiceSection { /** - * Lists the available billing periods for a subscription in reverse - * chronological order. This is only supported for Azure Web-Direct - * subscriptions. Other subscription types which were not purchased directly - * through the Azure web portal are not supported through this preview API. + * Lists products by invoiceSectionId. * - * @param {object} [options] Optional Parameters. + * @param {string} billingAccountId billing Account Id. * - * @param {string} [options.filter] May be used to filter billing periods by - * billingPeriodEndDate. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and - * 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param {string} invoiceSectionId InvoiceSection Id. * - * @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] Optional Parameters. * - * @param {number} [options.top] May be used to limit the number of results to - * the most recent N billing periods. + * @param {string} [options.filter] May be used to filter by product type. 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 {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listWithHttpOperationResponse(options?: { filter? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + listWithHttpOperationResponse(billingAccountId: string, invoiceSectionId: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Lists the available billing periods for a subscription in reverse - * chronological order. This is only supported for Azure Web-Direct - * subscriptions. Other subscription types which were not purchased directly - * through the Azure web portal are not supported through this preview API. + * Lists products by invoiceSectionId. * - * @param {object} [options] Optional Parameters. + * @param {string} billingAccountId billing Account Id. * - * @param {string} [options.filter] May be used to filter billing periods by - * billingPeriodEndDate. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and - * 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param {string} invoiceSectionId InvoiceSection Id. * - * @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] Optional Parameters. * - * @param {number} [options.top] May be used to limit the number of results to - * the most recent N billing periods. + * @param {string} [options.filter] May be used to filter by product type. 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 {object} [options.customHeaders] Headers that will be added to the * request @@ -256,7 +2636,7 @@ export interface BillingPeriods { * * {Promise} A promise is returned. * - * @resolve {BillingPeriodsListResult} - The deserialized result object. + * @resolve {ProductsListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -264,25 +2644,35 @@ export interface BillingPeriods { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {BillingPeriodsListResult} [result] - The deserialized result object if an error did not occur. - * See {@link BillingPeriodsListResult} for more - * information. + * {ProductsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ProductsListResult} 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, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; - list(callback: ServiceCallback): void; - list(options: { filter? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + list(billingAccountId: string, invoiceSectionId: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountId: string, invoiceSectionId: string, callback: ServiceCallback): void; + list(billingAccountId: string, invoiceSectionId: string, options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * Products + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface Products { /** - * Gets a named billing period. This is only supported for Azure Web-Direct - * subscriptions. Other subscription types which were not purchased directly - * through the Azure web portal are not supported through this preview API. + * Get a single product by name. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. * - * @param {string} billingPeriodName The name of a BillingPeriod resource. + * @param {string} productName Invoide Id. * * @param {object} [options] Optional Parameters. * @@ -291,18 +2681,20 @@ export interface BillingPeriods { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - getWithHttpOperationResponse(billingPeriodName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + getWithHttpOperationResponse(billingAccountId: string, invoiceSectionId: string, productName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets a named billing period. This is only supported for Azure Web-Direct - * subscriptions. Other subscription types which were not purchased directly - * through the Azure web portal are not supported through this preview API. + * Get a single product by name. * - * @param {string} billingPeriodName The name of a BillingPeriod resource. + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {string} productName Invoide Id. * * @param {object} [options] Optional Parameters. * @@ -316,7 +2708,7 @@ export interface BillingPeriods { * * {Promise} A promise is returned. * - * @resolve {BillingPeriod} - The deserialized result object. + * @resolve {ProductSummary} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -324,51 +2716,57 @@ export interface BillingPeriods { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {BillingPeriod} [result] - The deserialized result object if an error did not occur. - * See {@link BillingPeriod} for more information. + * {ProductSummary} [result] - The deserialized result object if an error did not occur. + * See {@link ProductSummary} 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(billingPeriodName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - get(billingPeriodName: string, callback: ServiceCallback): void; - get(billingPeriodName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + get(billingAccountId: string, invoiceSectionId: string, productName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountId: string, invoiceSectionId: string, productName: string, callback: ServiceCallback): void; + get(billingAccountId: string, invoiceSectionId: string, productName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Lists the available billing periods for a subscription in reverse - * chronological order. This is only supported for Azure Web-Direct - * subscriptions. Other subscription types which were not purchased directly - * through the Azure web portal are not supported through this preview API. + * The operation to transfer a Product to another InvoiceSection. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {string} productName Invoide Id. * * @param {object} [options] Optional Parameters. * + * @param {string} [options.destinationInvoiceSectionId] Destination invoice + * section id. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + transferWithHttpOperationResponse(billingAccountId: string, invoiceSectionId: string, productName: string, options?: { destinationInvoiceSectionId? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Lists the available billing periods for a subscription in reverse - * chronological order. This is only supported for Azure Web-Direct - * subscriptions. Other subscription types which were not purchased directly - * through the Azure web portal are not supported through this preview API. + * The operation to transfer a Product to another InvoiceSection. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {string} productName Invoide Id. * * @param {object} [options] Optional Parameters. * + * @param {string} [options.destinationInvoiceSectionId] Destination invoice + * section id. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -379,7 +2777,7 @@ export interface BillingPeriods { * * {Promise} A promise is returned. * - * @resolve {BillingPeriodsListResult} - The deserialized result object. + * @resolve {ProductSummary} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -387,92 +2785,69 @@ export interface BillingPeriods { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {BillingPeriodsListResult} [result] - The deserialized result object if an error did not occur. - * See {@link BillingPeriodsListResult} for more - * information. + * {ProductSummary} [result] - The deserialized result object if an error did not occur. + * See {@link ProductSummary} 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; + transfer(billingAccountId: string, invoiceSectionId: string, productName: string, options?: { destinationInvoiceSectionId? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + transfer(billingAccountId: string, invoiceSectionId: string, productName: string, callback: ServiceCallback): void; + transfer(billingAccountId: string, invoiceSectionId: string, productName: string, options: { destinationInvoiceSectionId? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } /** * @class - * Invoices + * TransactionsByBillingAccount * __NOTE__: An instance of this class is automatically created for an * instance of the BillingManagementClient. */ -export interface Invoices { +export interface TransactionsByBillingAccount { /** - * Lists the available invoices for a subscription in reverse chronological - * order beginning with the most recent invoice. In preview, invoices are - * available via this API only for invoice periods which end December 1, 2016 - * or later. This is only supported for Azure Web-Direct subscriptions. Other - * subscription types which were not purchased directly through the Azure web - * portal are not supported through this preview API. + * Lists the transactions by billingAccountId for given start and end date. * - * @param {object} [options] Optional Parameters. + * @param {string} billingAccountId billing Account Id. * - * @param {string} [options.expand] May be used to expand the downloadUrl - * property within a list of invoices. This enables download links to be - * generated for multiple invoices at once. By default, downloadURLs are not - * included when listing invoices. + * @param {string} startDate Start date * - * @param {string} [options.filter] May be used to filter invoices by - * invoicePeriodEndDate. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and - * 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param {string} endDate End date * - * @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] Optional Parameters. * - * @param {number} [options.top] May be used to limit the number of results to - * the most recent N invoices. + * @param {string} [options.filter] May be used to filter by transaction kind. + * 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 {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listWithHttpOperationResponse(options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + listWithHttpOperationResponse(billingAccountId: string, startDate: string, endDate: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Lists the available invoices for a subscription in reverse chronological - * order beginning with the most recent invoice. In preview, invoices are - * available via this API only for invoice periods which end December 1, 2016 - * or later. This is only supported for Azure Web-Direct subscriptions. Other - * subscription types which were not purchased directly through the Azure web - * portal are not supported through this preview API. + * Lists the transactions by billingAccountId for given start and end date. * - * @param {object} [options] Optional Parameters. + * @param {string} billingAccountId billing Account Id. * - * @param {string} [options.expand] May be used to expand the downloadUrl - * property within a list of invoices. This enables download links to be - * generated for multiple invoices at once. By default, downloadURLs are not - * included when listing invoices. + * @param {string} startDate Start date * - * @param {string} [options.filter] May be used to filter invoices by - * invoicePeriodEndDate. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and - * 'and'. It does not currently support 'ne', 'or', or 'not'. + * @param {string} endDate End date * - * @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] Optional Parameters. * - * @param {number} [options.top] May be used to limit the number of results to - * the most recent N invoices. + * @param {string} [options.filter] May be used to filter by transaction kind. + * 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 {object} [options.customHeaders] Headers that will be added to the * request @@ -484,7 +2859,7 @@ export interface Invoices { * * {Promise} A promise is returned. * - * @resolve {InvoicesListResult} - The deserialized result object. + * @resolve {TransactionsListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -492,26 +2867,24 @@ export interface Invoices { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {InvoicesListResult} [result] - The deserialized result object if an error did not occur. - * See {@link InvoicesListResult} for more information. + * {TransactionsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link TransactionsListResult} 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, 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(billingAccountId: string, startDate: string, endDate: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountId: string, startDate: string, endDate: string, callback: ServiceCallback): void; + list(billingAccountId: string, startDate: string, endDate: string, options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Gets a named invoice resource. When getting a single invoice, the - * downloadUrl property is expanded automatically. This is only supported for - * Azure Web-Direct subscriptions. Other subscription types which were not - * purchased directly through the Azure web portal are not supported through - * this preview API. + * Lists the transactions by billingAccountId for given start and end date. * - * @param {string} invoiceName The name of an invoice resource. + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. * * @param {object} [options] Optional Parameters. * @@ -520,20 +2893,17 @@ export interface Invoices { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - getWithHttpOperationResponse(invoiceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets a named invoice resource. When getting a single invoice, the - * downloadUrl property is expanded automatically. This is only supported for - * Azure Web-Direct subscriptions. Other subscription types which were not - * purchased directly through the Azure web portal are not supported through - * this preview API. + * Lists the transactions by billingAccountId for given start and end date. * - * @param {string} invoiceName The name of an invoice resource. + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. * * @param {object} [options] Optional Parameters. * @@ -547,7 +2917,7 @@ export interface Invoices { * * {Promise} A promise is returned. * - * @resolve {Invoice} - The deserialized result object. + * @resolve {TransactionsListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -555,24 +2925,34 @@ export interface Invoices { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {Invoice} [result] - The deserialized result object if an error did not occur. - * See {@link Invoice} for more information. + * {TransactionsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link TransactionsListResult} 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(invoiceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - get(invoiceName: string, callback: ServiceCallback): void; - get(invoiceName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + 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 + * PolicyOperations + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface PolicyOperations { /** - * Gets the most recent invoice. When getting a single invoice, the downloadUrl - * property is expanded automatically. This is only supported for Azure - * Web-Direct subscriptions. Other subscription types which were not purchased - * directly through the Azure web portal are not supported through this preview - * API. + * The policy for a given billingAccountId and billingProfileId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. * * @param {object} [options] Optional Parameters. * @@ -581,18 +2961,18 @@ export interface Invoices { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - getLatestWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + getByBillingProfileWithHttpOperationResponse(billingAccountId: string, billingProfileId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets the most recent invoice. When getting a single invoice, the downloadUrl - * property is expanded automatically. This is only supported for Azure - * Web-Direct subscriptions. Other subscription types which were not purchased - * directly through the Azure web portal are not supported through this preview - * API. + * The policy for a given billingAccountId and billingProfileId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. * * @param {object} [options] Optional Parameters. * @@ -606,7 +2986,7 @@ export interface Invoices { * * {Promise} A promise is returned. * - * @resolve {Invoice} - The deserialized result object. + * @resolve {Policy} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -614,28 +2994,33 @@ export interface Invoices { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {Invoice} [result] - The deserialized result object if an error did not occur. - * See {@link Invoice} for more information. + * {Policy} [result] - The deserialized result object if an error did not occur. + * See {@link Policy} 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. */ - getLatest(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - getLatest(callback: ServiceCallback): void; - getLatest(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + getByBillingProfile(billingAccountId: string, billingProfileId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getByBillingProfile(billingAccountId: string, billingProfileId: string, callback: ServiceCallback): void; + getByBillingProfile(billingAccountId: string, billingProfileId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Lists the available invoices for a subscription in reverse chronological - * order beginning with the most recent invoice. In preview, invoices are - * available via this API only for invoice periods which end December 1, 2016 - * or later. This is only supported for Azure Web-Direct subscriptions. Other - * subscription types which were not purchased directly through the Azure web - * portal are not supported through this preview API. + * The operation to update a policy. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {object} parameters Parameters supplied to the update policy + * operation. + * + * @param {boolean} [parameters.reservationPurchasesAllowed] The + * reservationPurchasesAllowed flag. + * + * @param {boolean} [parameters.marketplacePurchasesAllowed] The + * marketplacePurchasesAllowed flag. * * @param {object} [options] Optional Parameters. * @@ -644,22 +3029,87 @@ export interface Invoices { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + updateWithHttpOperationResponse(billingAccountId: string, billingProfileId: string, parameters: models.Policy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Lists the available invoices for a subscription in reverse chronological - * order beginning with the most recent invoice. In preview, invoices are - * available via this API only for invoice periods which end December 1, 2016 - * or later. This is only supported for Azure Web-Direct subscriptions. Other - * subscription types which were not purchased directly through the Azure web - * portal are not supported through this preview API. + * The operation to update a policy. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {object} parameters Parameters supplied to the update policy + * operation. + * + * @param {boolean} [parameters.reservationPurchasesAllowed] The + * reservationPurchasesAllowed flag. + * + * @param {boolean} [parameters.marketplacePurchasesAllowed] The + * marketplacePurchasesAllowed flag. + * + * @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 {Policy} - 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. + * + * {Policy} [result] - The deserialized result object if an error did not occur. + * See {@link Policy} 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. + */ + update(billingAccountId: string, billingProfileId: string, parameters: models.Policy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(billingAccountId: string, billingProfileId: string, parameters: models.Policy, callback: ServiceCallback): void; + update(billingAccountId: string, billingProfileId: string, parameters: models.Policy, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * BillingPropertyOperations + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface BillingPropertyOperations { + + + /** + * Get billing property by subscription 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(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get billing property by subscription Id. * * @param {object} [options] Optional Parameters. * @@ -673,7 +3123,7 @@ export interface Invoices { * * {Promise} A promise is returned. * - * @resolve {InvoicesListResult} - The deserialized result object. + * @resolve {BillingProperty} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -681,16 +3131,16 @@ export interface Invoices { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {InvoicesListResult} [result] - The deserialized result object if an error did not occur. - * See {@link InvoicesListResult} for more information. + * {BillingProperty} [result] - The deserialized result object if an error did not occur. + * See {@link BillingProperty} 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; + get(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(callback: ServiceCallback): void; + get(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } /** diff --git a/lib/services/billingManagement/lib/operations/index.js b/lib/services/billingManagement/lib/operations/index.js index ae2c2db552..bb35b2b193 100644 --- a/lib/services/billingManagement/lib/operations/index.js +++ b/lib/services/billingManagement/lib/operations/index.js @@ -14,7 +14,31 @@ 'use strict'; +exports.BillingAccounts = require('./billingAccounts'); +exports.BillingAccountsWithCreateInvoiceSectionPermission = require('./billingAccountsWithCreateInvoiceSectionPermission'); +exports.AvailableBalanceByBillingProfile = require('./availableBalanceByBillingProfile'); +exports.PaymentMethodsByBillingProfile = require('./paymentMethodsByBillingProfile'); +exports.BillingProfilesByBillingAccountId = require('./billingProfilesByBillingAccountId'); +exports.BillingProfiles = require('./billingProfiles'); +exports.InvoiceSectionsByBillingAccountId = require('./invoiceSectionsByBillingAccountId'); +exports.InvoiceSections = require('./invoiceSections'); +exports.InvoiceSectionsWithCreateSubscriptionPermission = require('./invoiceSectionsWithCreateSubscriptionPermission'); +exports.DepartmentsByBillingAccountId = require('./departmentsByBillingAccountId'); +exports.Departments = require('./departments'); +exports.EnrollmentAccountsByBillingAccountId = require('./enrollmentAccountsByBillingAccountId'); exports.EnrollmentAccounts = require('./enrollmentAccounts'); -exports.BillingPeriods = require('./billingPeriods'); -exports.Invoices = require('./invoices'); +exports.InvoicesByBillingAccount = require('./invoicesByBillingAccount'); +exports.InvoicePricesheet = require('./invoicePricesheet'); +exports.InvoicesByBillingProfile = require('./invoicesByBillingProfile'); +exports.Invoice = require('./invoice'); +exports.ProductsByBillingSubscriptions = require('./productsByBillingSubscriptions'); +exports.BillingSubscriptionsByBillingProfile = require('./billingSubscriptionsByBillingProfile'); +exports.BillingSubscriptionsByInvoiceSection = require('./billingSubscriptionsByInvoiceSection'); +exports.BillingSubscription = require('./billingSubscription'); +exports.ProductsByBillingAccount = require('./productsByBillingAccount'); +exports.ProductsByInvoiceSection = require('./productsByInvoiceSection'); +exports.Products = require('./products'); +exports.TransactionsByBillingAccount = require('./transactionsByBillingAccount'); +exports.PolicyOperations = require('./policyOperations'); +exports.BillingPropertyOperations = require('./billingPropertyOperations'); exports.Operations = require('./operations'); diff --git a/lib/services/billingManagement/lib/operations/invoice.js b/lib/services/billingManagement/lib/operations/invoice.js new file mode 100644 index 0000000000..e01bc98eb0 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/invoice.js @@ -0,0 +1,268 @@ +/* + * 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 the invoice by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {string} invoiceName Invoide 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 InvoiceSummary} for more information. + * + * {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, billingProfileId, invoiceName, 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 (billingProfileId === null || billingProfileId === undefined || typeof billingProfileId.valueOf() !== 'string') { + throw new Error('billingProfileId cannot be null or undefined and it must be of type string.'); + } + if (invoiceName === null || invoiceName === undefined || typeof invoiceName.valueOf() !== 'string') { + throw new Error('invoiceName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoices/{invoiceName}'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{billingProfileId}', encodeURIComponent(billingProfileId)); + requestUrl = requestUrl.replace('{invoiceName}', encodeURIComponent(invoiceName)); + 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['InvoiceSummary']().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 Invoice. */ +class Invoice { + /** + * Create a Invoice. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + } + + /** + * Get the invoice by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {string} invoiceName Invoide 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, billingProfileId, invoiceName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountId, billingProfileId, invoiceName, 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 invoice by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {string} invoiceName Invoide 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 {InvoiceSummary} - 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 InvoiceSummary} for more information. + * + * {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, billingProfileId, invoiceName, 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, billingProfileId, invoiceName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountId, billingProfileId, invoiceName, options, optionalCallback); + } + } + +} + +module.exports = Invoice; diff --git a/lib/services/billingManagement/lib/operations/invoicePricesheet.js b/lib/services/billingManagement/lib/operations/invoicePricesheet.js new file mode 100644 index 0000000000..5a4b24a7a6 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/invoicePricesheet.js @@ -0,0 +1,423 @@ +/* + * 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 pricesheet data for invoice id (invoiceName). + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {string} invoiceName The name of an invoice resource. + * + * @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 DownloadUrl} for more information. + * + * {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 _download(billingAccountId, invoiceName, 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.'); + } + + // Send request + this.beginDownload(billingAccountId, invoiceName, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['DownloadUrl']().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 pricesheet data for invoice id (invoiceName). + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {string} invoiceName The name of an invoice resource. + * + * @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 DownloadUrl} for more information. + * + * {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 _beginDownload(billingAccountId, invoiceName, 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 (invoiceName === null || invoiceName === undefined || typeof invoiceName.valueOf() !== 'string') { + throw new Error('invoiceName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoices/{invoiceName}/pricesheet/default/download'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{invoiceName}', encodeURIComponent(invoiceName)); + 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 = 'POST'; + 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 && statusCode !== 202) { + 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['DownloadUrl']().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 InvoicePricesheet. */ +class InvoicePricesheet { + /** + * Create a InvoicePricesheet. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._download = _download; + this._beginDownload = _beginDownload; + } + + /** + * Get pricesheet data for invoice id (invoiceName). + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {string} invoiceName The name of an invoice resource. + * + * @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. + */ + downloadWithHttpOperationResponse(billingAccountId, invoiceName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._download(billingAccountId, invoiceName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get pricesheet data for invoice id (invoiceName). + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {string} invoiceName The name of an invoice resource. + * + * @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 {DownloadUrl} - 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 DownloadUrl} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + download(billingAccountId, invoiceName, 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._download(billingAccountId, invoiceName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._download(billingAccountId, invoiceName, options, optionalCallback); + } + } + + /** + * Get pricesheet data for invoice id (invoiceName). + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {string} invoiceName The name of an invoice resource. + * + * @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. + */ + beginDownloadWithHttpOperationResponse(billingAccountId, invoiceName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginDownload(billingAccountId, invoiceName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get pricesheet data for invoice id (invoiceName). + * + * @param {string} billingAccountId Azure Billing Account ID. + * + * @param {string} invoiceName The name of an invoice resource. + * + * @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 {DownloadUrl} - 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 DownloadUrl} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + beginDownload(billingAccountId, invoiceName, 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._beginDownload(billingAccountId, invoiceName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginDownload(billingAccountId, invoiceName, options, optionalCallback); + } + } + +} + +module.exports = InvoicePricesheet; diff --git a/lib/services/billingManagement/lib/operations/invoiceSections.js b/lib/services/billingManagement/lib/operations/invoiceSections.js new file mode 100644 index 0000000000..a2a5335afd --- /dev/null +++ b/lib/services/billingManagement/lib/operations/invoiceSections.js @@ -0,0 +1,1173 @@ +/* + * 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; + + +/** + * The operation to create a InvoiceSection. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} parameters Parameters supplied to the Create InvoiceSection + * operation. + * + * @param {string} [parameters.displayName] The name of the InvoiceSection. + * + * @param {array} [parameters.billingProfiles] The billing profiles associated + * to the billing account. + * + * @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 InvoiceSection} for more information. + * + * {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 _create(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.'); + } + + // Send request + this.beginCreate(billingAccountId, parameters, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['InvoiceSection']().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 InvoiceSection by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the billingProfiles. + * + * @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 InvoiceSection} for more information. + * + * {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, invoiceSectionId, 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; + // 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 (invoiceSectionId === null || invoiceSectionId === undefined || typeof invoiceSectionId.valueOf() !== 'string') { + throw new Error('invoiceSectionId 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 (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{invoiceSectionId}', encodeURIComponent(invoiceSectionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + 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['InvoiceSection']().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 update a InvoiceSection. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} parameters Parameters supplied to the Create InvoiceSection + * operation. + * + * @param {string} [parameters.displayName] The name of the InvoiceSection. + * + * @param {array} [parameters.billingProfiles] The billing profiles associated + * to the billing account. + * + * @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 InvoiceSection} for more information. + * + * {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 _update(billingAccountId, invoiceSectionId, 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.'); + } + + // Send request + this.beginUpdate(billingAccountId, invoiceSectionId, parameters, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['InvoiceSection']().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 a InvoiceSection. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} parameters Parameters supplied to the Create InvoiceSection + * operation. + * + * @param {string} [parameters.displayName] The name of the InvoiceSection. + * + * @param {array} [parameters.billingProfiles] The billing profiles associated + * to the billing account. + * + * @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 InvoiceSection} for more information. + * + * {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 _beginCreate(billingAccountId, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections'; + 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 = 'POST'; + 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['InvoiceSectionProperties']().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 !== 202) { + 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['InvoiceSection']().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 update a InvoiceSection. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} parameters Parameters supplied to the Create InvoiceSection + * operation. + * + * @param {string} [parameters.displayName] The name of the InvoiceSection. + * + * @param {array} [parameters.billingProfiles] The billing profiles associated + * to the billing account. + * + * @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 InvoiceSection} for more information. + * + * {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 _beginUpdate(billingAccountId, invoiceSectionId, 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 (invoiceSectionId === null || invoiceSectionId === undefined || typeof invoiceSectionId.valueOf() !== 'string') { + throw new Error('invoiceSectionId cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{invoiceSectionId}', encodeURIComponent(invoiceSectionId)); + 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['InvoiceSection']().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 !== 202) { + 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['InvoiceSection']().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 InvoiceSections. */ +class InvoiceSections { + /** + * Create a InvoiceSections. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._create = _create; + this._get = _get; + this._update = _update; + this._beginCreate = _beginCreate; + this._beginUpdate = _beginUpdate; + } + + /** + * The operation to create a InvoiceSection. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} parameters Parameters supplied to the Create InvoiceSection + * operation. + * + * @param {string} [parameters.displayName] The name of the InvoiceSection. + * + * @param {array} [parameters.billingProfiles] The billing profiles associated + * to the billing account. + * + * @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. + */ + createWithHttpOperationResponse(billingAccountId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._create(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 a InvoiceSection. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} parameters Parameters supplied to the Create InvoiceSection + * operation. + * + * @param {string} [parameters.displayName] The name of the InvoiceSection. + * + * @param {array} [parameters.billingProfiles] The billing profiles associated + * to the billing account. + * + * @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 {InvoiceSection} - 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 InvoiceSection} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + create(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._create(billingAccountId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._create(billingAccountId, parameters, options, optionalCallback); + } + } + + /** + * Get the InvoiceSection by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the billingProfiles. + * + * @param {object} [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, invoiceSectionId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountId, invoiceSectionId, 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 InvoiceSection by id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the billingProfiles. + * + * @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 {InvoiceSection} - 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 InvoiceSection} for more information. + * + * {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, invoiceSectionId, 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, invoiceSectionId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountId, invoiceSectionId, options, optionalCallback); + } + } + + /** + * The operation to update a InvoiceSection. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} parameters Parameters supplied to the Create InvoiceSection + * operation. + * + * @param {string} [parameters.displayName] The name of the InvoiceSection. + * + * @param {array} [parameters.billingProfiles] The billing profiles associated + * to the billing account. + * + * @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. + */ + updateWithHttpOperationResponse(billingAccountId, invoiceSectionId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(billingAccountId, invoiceSectionId, 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 update a InvoiceSection. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} parameters Parameters supplied to the Create InvoiceSection + * operation. + * + * @param {string} [parameters.displayName] The name of the InvoiceSection. + * + * @param {array} [parameters.billingProfiles] The billing profiles associated + * to the billing account. + * + * @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 {InvoiceSection} - 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 InvoiceSection} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + update(billingAccountId, invoiceSectionId, 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._update(billingAccountId, invoiceSectionId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(billingAccountId, invoiceSectionId, parameters, options, optionalCallback); + } + } + + /** + * The operation to create a InvoiceSection. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} parameters Parameters supplied to the Create InvoiceSection + * operation. + * + * @param {string} [parameters.displayName] The name of the InvoiceSection. + * + * @param {array} [parameters.billingProfiles] The billing profiles associated + * to the billing account. + * + * @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. + */ + beginCreateWithHttpOperationResponse(billingAccountId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginCreate(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 a InvoiceSection. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} parameters Parameters supplied to the Create InvoiceSection + * operation. + * + * @param {string} [parameters.displayName] The name of the InvoiceSection. + * + * @param {array} [parameters.billingProfiles] The billing profiles associated + * to the billing account. + * + * @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 {InvoiceSection} - 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 InvoiceSection} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + beginCreate(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._beginCreate(billingAccountId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginCreate(billingAccountId, parameters, options, optionalCallback); + } + } + + /** + * The operation to update a InvoiceSection. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} parameters Parameters supplied to the Create InvoiceSection + * operation. + * + * @param {string} [parameters.displayName] The name of the InvoiceSection. + * + * @param {array} [parameters.billingProfiles] The billing profiles associated + * to the billing account. + * + * @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. + */ + beginUpdateWithHttpOperationResponse(billingAccountId, invoiceSectionId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginUpdate(billingAccountId, invoiceSectionId, 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 update a InvoiceSection. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} parameters Parameters supplied to the Create InvoiceSection + * operation. + * + * @param {string} [parameters.displayName] The name of the InvoiceSection. + * + * @param {array} [parameters.billingProfiles] The billing profiles associated + * to the billing account. + * + * @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 {InvoiceSection} - 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 InvoiceSection} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + beginUpdate(billingAccountId, invoiceSectionId, 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._beginUpdate(billingAccountId, invoiceSectionId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginUpdate(billingAccountId, invoiceSectionId, parameters, options, optionalCallback); + } + } + +} + +module.exports = InvoiceSections; diff --git a/lib/services/billingManagement/lib/operations/invoiceSectionsByBillingAccountId.js b/lib/services/billingManagement/lib/operations/invoiceSectionsByBillingAccountId.js new file mode 100644 index 0000000000..19fe44ce0c --- /dev/null +++ b/lib/services/billingManagement/lib/operations/invoiceSectionsByBillingAccountId.js @@ -0,0 +1,263 @@ +/* + * 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 invoice sections for a user which he has access to. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the billingProfiles. + * + * @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 InvoiceSectionListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(billingAccountId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + // 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 (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + 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 && statusCode !== 202) { + 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['InvoiceSectionListResult']().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 InvoiceSectionsByBillingAccountId. */ +class InvoiceSectionsByBillingAccountId { + /** + * Create a InvoiceSectionsByBillingAccountId. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + } + + /** + * Lists all invoice sections for a user which he has access to. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the billingProfiles. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(billingAccountId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all invoice sections for a user which he has access to. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the billingProfiles. + * + * @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 {InvoiceSectionListResult} - 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 InvoiceSectionListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(billingAccountId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(billingAccountId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountId, options, optionalCallback); + } + } + +} + +module.exports = InvoiceSectionsByBillingAccountId; diff --git a/lib/services/billingManagement/lib/operations/invoiceSectionsWithCreateSubscriptionPermission.js b/lib/services/billingManagement/lib/operations/invoiceSectionsWithCreateSubscriptionPermission.js new file mode 100644 index 0000000000..20900e3ca9 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/invoiceSectionsWithCreateSubscriptionPermission.js @@ -0,0 +1,263 @@ +/* + * 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 invoiceSections with create subscription permission for a user. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the billingProfiles. + * + * @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 InvoiceSectionListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(billingAccountId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let expand = (options && options.expand !== undefined) ? options.expand : undefined; + // 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 (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') { + throw new Error('expand must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/listInvoiceSectionsWithCreateSubscriptionPermission'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (expand !== null && expand !== undefined) { + queryParameters.push('$expand=' + encodeURIComponent(expand)); + } + 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 && statusCode !== 202) { + 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['InvoiceSectionListResult']().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 InvoiceSectionsWithCreateSubscriptionPermission. */ +class InvoiceSectionsWithCreateSubscriptionPermission { + /** + * Create a InvoiceSectionsWithCreateSubscriptionPermission. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + } + + /** + * Lists all invoiceSections with create subscription permission for a user. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the billingProfiles. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(billingAccountId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all invoiceSections with create subscription permission for a user. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.expand] May be used to expand the billingProfiles. + * + * @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 {InvoiceSectionListResult} - 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 InvoiceSectionListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(billingAccountId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(billingAccountId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountId, options, optionalCallback); + } + } + +} + +module.exports = InvoiceSectionsWithCreateSubscriptionPermission; diff --git a/lib/services/billingManagement/lib/operations/invoicesByBillingAccount.js b/lib/services/billingManagement/lib/operations/invoicesByBillingAccount.js new file mode 100644 index 0000000000..b634271e4c --- /dev/null +++ b/lib/services/billingManagement/lib/operations/invoicesByBillingAccount.js @@ -0,0 +1,268 @@ +/* + * 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 invoices for a billing account. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} periodStartDate Invoice period start date. + * + * @param {string} periodEndDate Invoice period end date. + * + * @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 InvoiceListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(billingAccountId, periodStartDate, periodEndDate, 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 (periodStartDate === null || periodStartDate === undefined || typeof periodStartDate.valueOf() !== 'string') { + throw new Error('periodStartDate cannot be null or undefined and it must be of type string.'); + } + if (periodEndDate === null || periodEndDate === undefined || typeof periodEndDate.valueOf() !== 'string') { + throw new Error('periodEndDate cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoices'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + queryParameters.push('periodStartDate=' + encodeURIComponent(periodStartDate)); + queryParameters.push('periodEndDate=' + encodeURIComponent(periodEndDate)); + 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['InvoiceListResult']().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 InvoicesByBillingAccount. */ +class InvoicesByBillingAccount { + /** + * Create a InvoicesByBillingAccount. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + } + + /** + * List of invoices for a billing account. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} periodStartDate Invoice period start date. + * + * @param {string} periodEndDate Invoice period end date. + * + * @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(billingAccountId, periodStartDate, periodEndDate, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountId, periodStartDate, periodEndDate, 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 invoices for a billing account. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} periodStartDate Invoice period start date. + * + * @param {string} periodEndDate Invoice period end date. + * + * @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 {InvoiceListResult} - 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 InvoiceListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(billingAccountId, periodStartDate, periodEndDate, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(billingAccountId, periodStartDate, periodEndDate, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountId, periodStartDate, periodEndDate, options, optionalCallback); + } + } + +} + +module.exports = InvoicesByBillingAccount; diff --git a/lib/services/billingManagement/lib/operations/invoicesByBillingProfile.js b/lib/services/billingManagement/lib/operations/invoicesByBillingProfile.js new file mode 100644 index 0000000000..1d912e34ec --- /dev/null +++ b/lib/services/billingManagement/lib/operations/invoicesByBillingProfile.js @@ -0,0 +1,278 @@ +/* + * 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 invoices for a billing profile. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {string} periodStartDate Invoice period start date. + * + * @param {string} periodEndDate Invoice period end date. + * + * @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 InvoiceListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(billingAccountId, billingProfileId, periodStartDate, periodEndDate, 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 (billingProfileId === null || billingProfileId === undefined || typeof billingProfileId.valueOf() !== 'string') { + throw new Error('billingProfileId cannot be null or undefined and it must be of type string.'); + } + if (periodStartDate === null || periodStartDate === undefined || typeof periodStartDate.valueOf() !== 'string') { + throw new Error('periodStartDate cannot be null or undefined and it must be of type string.'); + } + if (periodEndDate === null || periodEndDate === undefined || typeof periodEndDate.valueOf() !== 'string') { + throw new Error('periodEndDate cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoices'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{billingProfileId}', encodeURIComponent(billingProfileId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + queryParameters.push('periodStartDate=' + encodeURIComponent(periodStartDate)); + queryParameters.push('periodEndDate=' + encodeURIComponent(periodEndDate)); + 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['InvoiceListResult']().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 InvoicesByBillingProfile. */ +class InvoicesByBillingProfile { + /** + * Create a InvoicesByBillingProfile. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + } + + /** + * List of invoices for a billing profile. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {string} periodStartDate Invoice period start date. + * + * @param {string} periodEndDate Invoice period end date. + * + * @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(billingAccountId, billingProfileId, periodStartDate, periodEndDate, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountId, billingProfileId, periodStartDate, periodEndDate, 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 invoices for a billing profile. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {string} periodStartDate Invoice period start date. + * + * @param {string} periodEndDate Invoice period end date. + * + * @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 {InvoiceListResult} - 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 InvoiceListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(billingAccountId, billingProfileId, periodStartDate, periodEndDate, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(billingAccountId, billingProfileId, periodStartDate, periodEndDate, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountId, billingProfileId, periodStartDate, periodEndDate, options, optionalCallback); + } + } + +} + +module.exports = InvoicesByBillingProfile; diff --git a/lib/services/billingManagement/lib/operations/paymentMethodsByBillingProfile.js b/lib/services/billingManagement/lib/operations/paymentMethodsByBillingProfile.js new file mode 100644 index 0000000000..1803942da0 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/paymentMethodsByBillingProfile.js @@ -0,0 +1,475 @@ +/* + * 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 Payment Methods by billing profile Id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile 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 PaymentMethodsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(billingAccountId, billingProfileId, 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 (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 (billingProfileId === null || billingProfileId === undefined || typeof billingProfileId.valueOf() !== 'string') { + throw new Error('billingProfileId 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/paymentMethods'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{billingProfileId}', encodeURIComponent(billingProfileId)); + 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['PaymentMethodsListResult']().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 Payment Methods by billing profile Id. + * + * @param {string} nextPageLink The NextLink from 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 PaymentMethodsListResult} for more + * information. + * + * {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['PaymentMethodsListResult']().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 PaymentMethodsByBillingProfile. */ +class PaymentMethodsByBillingProfile { + /** + * Create a PaymentMethodsByBillingProfile. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listNext = _listNext; + } + + /** + * Lists the Payment Methods by billing profile Id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile 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. + */ + listWithHttpOperationResponse(billingAccountId, billingProfileId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountId, billingProfileId, 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 Payment Methods by billing profile Id. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile 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 {PaymentMethodsListResult} - 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 PaymentMethodsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(billingAccountId, billingProfileId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(billingAccountId, billingProfileId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountId, billingProfileId, options, optionalCallback); + } + } + + /** + * Lists the Payment Methods by billing profile Id. + * + * @param {string} nextPageLink The NextLink from 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 Payment Methods by billing profile Id. + * + * @param {string} nextPageLink The NextLink from 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 {PaymentMethodsListResult} - 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 PaymentMethodsListResult} for more + * information. + * + * {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 = PaymentMethodsByBillingProfile; diff --git a/lib/services/billingManagement/lib/operations/policyOperations.js b/lib/services/billingManagement/lib/operations/policyOperations.js new file mode 100644 index 0000000000..ac96d1bc3a --- /dev/null +++ b/lib/services/billingManagement/lib/operations/policyOperations.js @@ -0,0 +1,531 @@ +/* + * 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; + +/** + * The policy for a given billingAccountId and billingProfileId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile 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 Policy} for more information. + * + * {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 _getByBillingProfile(billingAccountId, billingProfileId, 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 (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 (billingProfileId === null || billingProfileId === undefined || typeof billingProfileId.valueOf() !== 'string') { + throw new Error('billingProfileId 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.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/policies/default'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{billingProfileId}', encodeURIComponent(billingProfileId)); + 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['Policy']().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 update a policy. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {object} parameters Parameters supplied to the update policy + * operation. + * + * @param {boolean} [parameters.reservationPurchasesAllowed] The + * reservationPurchasesAllowed flag. + * + * @param {boolean} [parameters.marketplacePurchasesAllowed] The + * marketplacePurchasesAllowed flag. + * + * @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 Policy} for more information. + * + * {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 _update(billingAccountId, billingProfileId, 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 (billingProfileId === null || billingProfileId === undefined || typeof billingProfileId.valueOf() !== 'string') { + throw new Error('billingProfileId cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/policies/default'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{billingProfileId}', encodeURIComponent(billingProfileId)); + 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['Policy']().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) { + 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['Policy']().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 PolicyOperations. */ +class PolicyOperations { + /** + * Create a PolicyOperations. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._getByBillingProfile = _getByBillingProfile; + this._update = _update; + } + + /** + * The policy for a given billingAccountId and billingProfileId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile 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. + */ + getByBillingProfileWithHttpOperationResponse(billingAccountId, billingProfileId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._getByBillingProfile(billingAccountId, billingProfileId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * The policy for a given billingAccountId and billingProfileId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile 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 {Policy} - 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 Policy} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + getByBillingProfile(billingAccountId, billingProfileId, 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._getByBillingProfile(billingAccountId, billingProfileId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._getByBillingProfile(billingAccountId, billingProfileId, options, optionalCallback); + } + } + + /** + * The operation to update a policy. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {object} parameters Parameters supplied to the update policy + * operation. + * + * @param {boolean} [parameters.reservationPurchasesAllowed] The + * reservationPurchasesAllowed flag. + * + * @param {boolean} [parameters.marketplacePurchasesAllowed] The + * marketplacePurchasesAllowed flag. + * + * @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. + */ + updateWithHttpOperationResponse(billingAccountId, billingProfileId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(billingAccountId, billingProfileId, 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 update a policy. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} billingProfileId Billing Profile Id. + * + * @param {object} parameters Parameters supplied to the update policy + * operation. + * + * @param {boolean} [parameters.reservationPurchasesAllowed] The + * reservationPurchasesAllowed flag. + * + * @param {boolean} [parameters.marketplacePurchasesAllowed] The + * marketplacePurchasesAllowed flag. + * + * @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 {Policy} - 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 Policy} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + update(billingAccountId, billingProfileId, 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._update(billingAccountId, billingProfileId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(billingAccountId, billingProfileId, parameters, options, optionalCallback); + } + } + +} + +module.exports = PolicyOperations; diff --git a/lib/services/billingManagement/lib/operations/products.js b/lib/services/billingManagement/lib/operations/products.js new file mode 100644 index 0000000000..a0483dfa8d --- /dev/null +++ b/lib/services/billingManagement/lib/operations/products.js @@ -0,0 +1,539 @@ +/* + * 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 a single product by name. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {string} productName Invoide 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 ProductSummary} for more information. + * + * {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, invoiceSectionId, productName, 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 (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 (invoiceSectionId === null || invoiceSectionId === undefined || typeof invoiceSectionId.valueOf() !== 'string') { + throw new Error('invoiceSectionId cannot be null or undefined and it must be of type string.'); + } + if (productName === null || productName === undefined || typeof productName.valueOf() !== 'string') { + throw new Error('productName 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.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}/products/{productName}'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{invoiceSectionId}', encodeURIComponent(invoiceSectionId)); + requestUrl = requestUrl.replace('{productName}', encodeURIComponent(productName)); + 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['ProductSummary']().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 transfer a Product to another InvoiceSection. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {string} productName Invoide Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionId] Destination invoice + * section id. + * + * @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 ProductSummary} for more information. + * + * {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 _transfer(billingAccountId, invoiceSectionId, productName, 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 destinationInvoiceSectionId = (options && options.destinationInvoiceSectionId !== undefined) ? options.destinationInvoiceSectionId : undefined; + // Validate + try { + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionId === null || invoiceSectionId === undefined || typeof invoiceSectionId.valueOf() !== 'string') { + throw new Error('invoiceSectionId cannot be null or undefined and it must be of type string.'); + } + if (productName === null || productName === undefined || typeof productName.valueOf() !== 'string') { + throw new Error('productName 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 (destinationInvoiceSectionId !== null && destinationInvoiceSectionId !== undefined && typeof destinationInvoiceSectionId.valueOf() !== 'string') { + throw new Error('destinationInvoiceSectionId 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 parameters; + if (destinationInvoiceSectionId !== null && destinationInvoiceSectionId !== undefined) { + parameters = new client.models['TransferProductRequestProperties'](); + parameters.destinationInvoiceSectionId = destinationInvoiceSectionId; + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}/products/{productName}/transfer'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{invoiceSectionId}', encodeURIComponent(invoiceSectionId)); + requestUrl = requestUrl.replace('{productName}', encodeURIComponent(productName)); + 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 = 'POST'; + 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['TransferProductRequestProperties']().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 !== 202) { + 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['ProductSummary']().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 Products. */ +class Products { + /** + * Create a Products. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._transfer = _transfer; + } + + /** + * Get a single product by name. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {string} productName Invoide 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, invoiceSectionId, productName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountId, invoiceSectionId, productName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get a single product by name. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {string} productName Invoide 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 {ProductSummary} - 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 ProductSummary} for more information. + * + * {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, invoiceSectionId, productName, 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, invoiceSectionId, productName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountId, invoiceSectionId, productName, options, optionalCallback); + } + } + + /** + * The operation to transfer a Product to another InvoiceSection. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {string} productName Invoide Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionId] Destination invoice + * section id. + * + * @param {object} [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. + */ + transferWithHttpOperationResponse(billingAccountId, invoiceSectionId, productName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._transfer(billingAccountId, invoiceSectionId, productName, 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 transfer a Product to another InvoiceSection. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {string} productName Invoide Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionId] Destination invoice + * section id. + * + * @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 {ProductSummary} - 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 ProductSummary} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + transfer(billingAccountId, invoiceSectionId, productName, 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._transfer(billingAccountId, invoiceSectionId, productName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._transfer(billingAccountId, invoiceSectionId, productName, options, optionalCallback); + } + } + +} + +module.exports = Products; diff --git a/lib/services/billingManagement/lib/operations/productsByBillingAccount.js b/lib/services/billingManagement/lib/operations/productsByBillingAccount.js new file mode 100644 index 0000000000..6f53fb55aa --- /dev/null +++ b/lib/services/billingManagement/lib/operations/productsByBillingAccount.js @@ -0,0 +1,483 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists products by billingAccountId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter by product type. 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 {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 ProductsListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(billingAccountId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + // Validate + try { + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (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 (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/products'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + 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['ProductsListResult']().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 products by billingAccountId. + * + * @param {string} nextPageLink The NextLink from 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 ProductsListResult} for more information. + * + * {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['ProductsListResult']().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 ProductsByBillingAccount. */ +class ProductsByBillingAccount { + /** + * Create a ProductsByBillingAccount. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listNext = _listNext; + } + + /** + * Lists products by billingAccountId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter by product type. 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(billingAccountId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists products by billingAccountId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter by product type. 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 {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 {ProductsListResult} - 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 ProductsListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(billingAccountId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(billingAccountId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountId, options, optionalCallback); + } + } + + /** + * Lists products by billingAccountId. + * + * @param {string} nextPageLink The NextLink from 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 products by billingAccountId. + * + * @param {string} nextPageLink The NextLink from 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 {ProductsListResult} - 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 ProductsListResult} for more information. + * + * {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 = ProductsByBillingAccount; diff --git a/lib/services/billingManagement/lib/operations/productsByBillingSubscriptions.js b/lib/services/billingManagement/lib/operations/productsByBillingSubscriptions.js new file mode 100644 index 0000000000..01f042e787 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/productsByBillingSubscriptions.js @@ -0,0 +1,465 @@ +/* + * 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 billing subscriptions by billingAccountId. + * + * @param {string} billingAccountId 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 BillingSubscriptionsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(billingAccountId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (billingAccountId === null || billingAccountId === undefined || typeof billingAccountId.valueOf() !== 'string') { + throw new Error('billingAccountId cannot be null or undefined and it must be of type string.'); + } + if (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.Billing/billingAccounts/{billingAccountId}/billingSubscriptions'; + 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['BillingSubscriptionsListResult']().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 billing subscriptions by billingAccountId. + * + * @param {string} nextPageLink The NextLink from 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 BillingSubscriptionsListResult} for more + * information. + * + * {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['BillingSubscriptionsListResult']().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 ProductsByBillingSubscriptions. */ +class ProductsByBillingSubscriptions { + /** + * Create a ProductsByBillingSubscriptions. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listNext = _listNext; + } + + /** + * Lists billing subscriptions by billingAccountId. + * + * @param {string} billingAccountId 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. + */ + listWithHttpOperationResponse(billingAccountId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists billing subscriptions by billingAccountId. + * + * @param {string} billingAccountId 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 {BillingSubscriptionsListResult} - 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 BillingSubscriptionsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(billingAccountId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(billingAccountId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountId, options, optionalCallback); + } + } + + /** + * Lists billing subscriptions by billingAccountId. + * + * @param {string} nextPageLink The NextLink from 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 billing subscriptions by billingAccountId. + * + * @param {string} nextPageLink The NextLink from 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 {BillingSubscriptionsListResult} - 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 BillingSubscriptionsListResult} for more + * information. + * + * {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 = ProductsByBillingSubscriptions; diff --git a/lib/services/billingManagement/lib/operations/productsByInvoiceSection.js b/lib/services/billingManagement/lib/operations/productsByInvoiceSection.js new file mode 100644 index 0000000000..c635bef8a3 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/productsByInvoiceSection.js @@ -0,0 +1,280 @@ +/* + * 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 products by invoiceSectionId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter by product type. 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 {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 ProductsListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(billingAccountId, invoiceSectionId, 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 (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 (invoiceSectionId === null || invoiceSectionId === undefined || typeof invoiceSectionId.valueOf() !== 'string') { + throw new Error('invoiceSectionId 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 (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}/products'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + requestUrl = requestUrl.replace('{invoiceSectionId}', encodeURIComponent(invoiceSectionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + 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['ProductsListResult']().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 ProductsByInvoiceSection. */ +class ProductsByInvoiceSection { + /** + * Create a ProductsByInvoiceSection. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + } + + /** + * Lists products by invoiceSectionId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter by product type. 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(billingAccountId, invoiceSectionId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountId, invoiceSectionId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists products by invoiceSectionId. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} invoiceSectionId InvoiceSection Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter by product type. 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 {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 {ProductsListResult} - 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 ProductsListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(billingAccountId, invoiceSectionId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(billingAccountId, invoiceSectionId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountId, invoiceSectionId, options, optionalCallback); + } + } + +} + +module.exports = ProductsByInvoiceSection; diff --git a/lib/services/billingManagement/lib/operations/transactionsByBillingAccount.js b/lib/services/billingManagement/lib/operations/transactionsByBillingAccount.js new file mode 100644 index 0000000000..22d5b53121 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/transactionsByBillingAccount.js @@ -0,0 +1,507 @@ +/* + * 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 transactions by billingAccountId for given start and end date. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} startDate Start date + * + * @param {string} endDate End date + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter by transaction kind. + * 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 {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 TransactionsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(billingAccountId, startDate, endDate, 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 (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.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 (startDate === null || startDate === undefined || typeof startDate.valueOf() !== 'string') { + throw new Error('startDate cannot be null or undefined and it must be of type string.'); + } + if (endDate === null || endDate === undefined || typeof endDate.valueOf() !== 'string') { + throw new Error('endDate 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.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/transactions'; + requestUrl = requestUrl.replace('{billingAccountId}', encodeURIComponent(billingAccountId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + queryParameters.push('startDate=' + encodeURIComponent(startDate)); + queryParameters.push('endDate=' + encodeURIComponent(endDate)); + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + 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['TransactionsListResult']().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 transactions by billingAccountId for given start and end date. + * + * @param {string} nextPageLink The NextLink from 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 TransactionsListResult} for more + * information. + * + * {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['TransactionsListResult']().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 TransactionsByBillingAccount. */ +class TransactionsByBillingAccount { + /** + * Create a TransactionsByBillingAccount. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listNext = _listNext; + } + + /** + * Lists the transactions by billingAccountId for given start and end date. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} startDate Start date + * + * @param {string} endDate End date + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter by transaction kind. + * 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(billingAccountId, startDate, endDate, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountId, startDate, endDate, 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 transactions by billingAccountId for given start and end date. + * + * @param {string} billingAccountId billing Account Id. + * + * @param {string} startDate Start date + * + * @param {string} endDate End date + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] May be used to filter by transaction kind. + * 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 {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 {TransactionsListResult} - 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 TransactionsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(billingAccountId, startDate, endDate, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(billingAccountId, startDate, endDate, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountId, startDate, endDate, options, optionalCallback); + } + } + + /** + * Lists the transactions by billingAccountId for given start and end date. + * + * @param {string} nextPageLink The NextLink from 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 transactions by billingAccountId for given start and end date. + * + * @param {string} nextPageLink The NextLink from 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 {TransactionsListResult} - 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 TransactionsListResult} for more + * information. + * + * {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 = TransactionsByBillingAccount; diff --git a/lib/services/billingManagement/package.json b/lib/services/billingManagement/package.json index 02e1b2b259..98ba7160b0 100644 --- a/lib/services/billingManagement/package.json +++ b/lib/services/billingManagement/package.json @@ -4,7 +4,7 @@ "description": "BillingManagementClient Library with typescript type definitions for node", "version": "2.2.0", "dependencies": { - "ms-rest": "^2.3.2", + "ms-rest": "^2.3.3", "ms-rest-azure": "^2.5.5" }, "keywords": [ @@ -14,12 +14,12 @@ "license": "MIT", "main": "./lib/billingManagementClient.js", "types": "./lib/billingManagementClient.d.ts", - "homepage": "http://github.com/azure/azure-sdk-for-node", + "homepage": "https://github.com/azure/azure-sdk-for-node/tree/master/lib/services/billingManagement", "repository": { "type": "git", "url": "https://github.com/azure/azure-sdk-for-node.git" }, "bugs": { - "url": "http://github.com/Azure/azure-sdk-for-node/issues" + "url": "https://github.com/azure/azure-sdk-for-node/issues" } -} \ No newline at end of file +}