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..a7160bd148 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,262 @@ export default class BillingManagementClient extends AzureServiceClient { generateClientRequestId: boolean; // Operation groups + billingAccounts: operations.BillingAccounts; + billingAccountsWithCreateInvoiceSectionPermission: operations.BillingAccountsWithCreateInvoiceSectionPermission; + availableBalanceByBillingProfile: operations.AvailableBalanceByBillingProfile; + paymentMethodsByBillingProfile: operations.PaymentMethodsByBillingProfile; + billingProfilesByBillingAccountName: operations.BillingProfilesByBillingAccountName; + billingProfiles: operations.BillingProfiles; + invoiceSectionsByBillingAccountName: operations.InvoiceSectionsByBillingAccountName; + invoiceSections: operations.InvoiceSections; + invoiceSectionsWithCreateSubscriptionPermission: operations.InvoiceSectionsWithCreateSubscriptionPermission; + departmentsByBillingAccountName: operations.DepartmentsByBillingAccountName; + departments: operations.Departments; + enrollmentAccountsByBillingAccountName: operations.EnrollmentAccountsByBillingAccountName; 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; + transfer: operations.Transfer; + transfers: operations.Transfers; + recipientTransfer: operations.RecipientTransfer; operations: operations.Operations; + billingAccountBillingPermissions: operations.BillingAccountBillingPermissions; + invoiceSectionsBillingPermissions: operations.InvoiceSectionsBillingPermissions; + billingProfileBillingPermissions: operations.BillingProfileBillingPermissions; + billingAccountBillingRoleDefinition: operations.BillingAccountBillingRoleDefinition; + invoiceSectionBillingRoleDefinition: operations.InvoiceSectionBillingRoleDefinition; + billingProfileBillingRoleDefinition: operations.BillingProfileBillingRoleDefinition; + billingAccountBillingRoleAssignment: operations.BillingAccountBillingRoleAssignment; + invoiceSectionBillingRoleAssignment: operations.InvoiceSectionBillingRoleAssignment; + billingProfileBillingRoleAssignment: operations.BillingProfileBillingRoleAssignment; + + + /** + * Lists the transactions by billingProfileName for given start date and end + * date. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName: string, billingProfileName: string, startDate: string, endDate: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the transactions by billingProfileName for given start date and end + * date. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName: string, billingProfileName: string, startDate: string, endDate: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + transactionsByBillingProfile(billingAccountName: string, billingProfileName: string, startDate: string, endDate: string, callback: ServiceCallback): void; + transactionsByBillingProfile(billingAccountName: string, billingProfileName: string, startDate: string, endDate: string, options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Cancel product by product id + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} productName Invoice 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(billingAccountName: string, productName: string, options?: { autoRenew? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Cancel product by product id + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} productName Invoice 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(billingAccountName: string, productName: string, options?: { autoRenew? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + updateAutoRenewForBillingAccount(billingAccountName: string, productName: string, callback: ServiceCallback): void; + updateAutoRenewForBillingAccount(billingAccountName: string, productName: string, options: { autoRenew? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Cancel auto renew for product by product id + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} productName Invoice 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(billingAccountName: string, invoiceSectionName: string, productName: string, options?: { autoRenew? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Cancel auto renew for product by product id + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} productName Invoice 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(billingAccountName: string, invoiceSectionName: string, productName: string, options?: { autoRenew? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + updateAutoRenewForInvoiceSection(billingAccountName: string, invoiceSectionName: string, productName: string, callback: ServiceCallback): void; + updateAutoRenewForInvoiceSection(billingAccountName: string, invoiceSectionName: 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..a3acfd77cf 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 billingProfileName for given start date and end + * date. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (billingProfileName === null || billingProfileName === undefined || typeof billingProfileName.valueOf() !== 'string') { + throw new Error('billingProfileName 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/{billingAccountName}/billingProfiles/{billingProfileName}/transactions'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{billingProfileName}', encodeURIComponent(billingProfileName)); + 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} billingAccountName billing Account Id. + * + * @param {string} productName Invoice 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(billingAccountName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName 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/{billingAccountName}/products/{productName}/updateAutoRenew'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + 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} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} productName Invoice 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(billingAccountName, invoiceSectionName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionName === null || invoiceSectionName === undefined || typeof invoiceSectionName.valueOf() !== 'string') { + throw new Error('invoiceSectionName 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/{billingAccountName}/invoiceSections/{invoiceSectionName}/products/{productName}/updateAutoRenew'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{invoiceSectionName}', encodeURIComponent(invoiceSectionName)); + 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,350 @@ 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.billingProfilesByBillingAccountName = new operations.BillingProfilesByBillingAccountName(this); + this.billingProfiles = new operations.BillingProfiles(this); + this.invoiceSectionsByBillingAccountName = new operations.InvoiceSectionsByBillingAccountName(this); + this.invoiceSections = new operations.InvoiceSections(this); + this.invoiceSectionsWithCreateSubscriptionPermission = new operations.InvoiceSectionsWithCreateSubscriptionPermission(this); + this.departmentsByBillingAccountName = new operations.DepartmentsByBillingAccountName(this); + this.departments = new operations.Departments(this); + this.enrollmentAccountsByBillingAccountName = new operations.EnrollmentAccountsByBillingAccountName(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.transfer = new operations.Transfer(this); + this.transfers = new operations.Transfers(this); + this.recipientTransfer = new operations.RecipientTransfer(this); this.operations = new operations.Operations(this); + this.billingAccountBillingPermissions = new operations.BillingAccountBillingPermissions(this); + this.invoiceSectionsBillingPermissions = new operations.InvoiceSectionsBillingPermissions(this); + this.billingProfileBillingPermissions = new operations.BillingProfileBillingPermissions(this); + this.billingAccountBillingRoleDefinition = new operations.BillingAccountBillingRoleDefinition(this); + this.invoiceSectionBillingRoleDefinition = new operations.InvoiceSectionBillingRoleDefinition(this); + this.billingProfileBillingRoleDefinition = new operations.BillingProfileBillingRoleDefinition(this); + this.billingAccountBillingRoleAssignment = new operations.BillingAccountBillingRoleAssignment(this); + this.invoiceSectionBillingRoleAssignment = new operations.InvoiceSectionBillingRoleAssignment(this); + this.billingProfileBillingRoleAssignment = new operations.BillingProfileBillingRoleAssignment(this); this.models = models; + this._transactionsByBillingProfile = _transactionsByBillingProfile; + this._updateAutoRenewForBillingAccount = _updateAutoRenewForBillingAccount; + this._updateAutoRenewForInvoiceSection = _updateAutoRenewForInvoiceSection; msRest.addSerializationMixin(this); } + /** + * Lists the transactions by billingProfileName for given start date and end + * date. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, startDate, endDate, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._transactionsByBillingProfile(billingAccountName, billingProfileName, 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 billingProfileName for given start date and end + * date. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, 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(billingAccountName, billingProfileName, startDate, endDate, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._transactionsByBillingProfile(billingAccountName, billingProfileName, startDate, endDate, options, optionalCallback); + } + } + + /** + * Cancel product by product id + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} productName Invoice 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(billingAccountName, productName, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._updateAutoRenewForBillingAccount(billingAccountName, 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} billingAccountName billing Account Id. + * + * @param {string} productName Invoice 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(billingAccountName, 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(billingAccountName, productName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._updateAutoRenewForBillingAccount(billingAccountName, productName, options, optionalCallback); + } + } + + /** + * Cancel auto renew for product by product id + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} productName Invoice 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(billingAccountName, invoiceSectionName, productName, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._updateAutoRenewForInvoiceSection(billingAccountName, invoiceSectionName, 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} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} productName Invoice 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(billingAccountName, invoiceSectionName, 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(billingAccountName, invoiceSectionName, productName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._updateAutoRenewForInvoiceSection(billingAccountName, invoiceSectionName, productName, options, optionalCallback); + } + } + } module.exports = BillingManagementClient; diff --git a/lib/services/billingManagement/lib/models/acceptTransferRequest.js b/lib/services/billingManagement/lib/models/acceptTransferRequest.js new file mode 100644 index 0000000000..b07a1db22d --- /dev/null +++ b/lib/services/billingManagement/lib/models/acceptTransferRequest.js @@ -0,0 +1,60 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Request parameters to accept transfer. + * + */ +class AcceptTransferRequest { + /** + * Create a AcceptTransferRequest. + * @property {array} [productDetails] Request parameters to accept transfer. + */ + constructor() { + } + + /** + * Defines the metadata of AcceptTransferRequest + * + * @returns {object} metadata of AcceptTransferRequest + * + */ + mapper() { + return { + required: false, + serializedName: 'AcceptTransferRequest', + type: { + name: 'Composite', + className: 'AcceptTransferRequest', + modelProperties: { + productDetails: { + required: false, + serializedName: 'properties.productDetails', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ProductDetailsElementType', + type: { + name: 'Composite', + className: 'ProductDetails' + } + } + } + } + } + } + }; + } +} + +module.exports = AcceptTransferRequest; 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..7b5ad0ac64 --- /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.billingCycle] 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/billingPermissions.js b/lib/services/billingManagement/lib/models/billingPermissions.js new file mode 100644 index 0000000000..9ab6f99454 --- /dev/null +++ b/lib/services/billingManagement/lib/models/billingPermissions.js @@ -0,0 +1,79 @@ +/* + * 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 set of allowed action and not allowed actions a caller has on a billing + * account + * + */ +class BillingPermissions { + /** + * Create a BillingPermissions. + * @property {array} [actions] The set of actions that the caller is allowed + * to do + * @property {array} [notActions] The set of actions the caller is not + * allowed to do + */ + constructor() { + } + + /** + * Defines the metadata of BillingPermissions + * + * @returns {object} metadata of BillingPermissions + * + */ + mapper() { + return { + required: false, + serializedName: 'BillingPermissions', + type: { + name: 'Composite', + className: 'BillingPermissions', + modelProperties: { + actions: { + required: false, + readOnly: true, + serializedName: 'actions', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + notActions: { + required: false, + readOnly: true, + serializedName: 'notActions', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = BillingPermissions; diff --git a/lib/services/billingManagement/lib/models/billingPermissionsListResult.js b/lib/services/billingManagement/lib/models/billingPermissionsListResult.js new file mode 100644 index 0000000000..df97e26c7a --- /dev/null +++ b/lib/services/billingManagement/lib/models/billingPermissionsListResult.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'; + +/** + * Result of list billingPermissions a caller has on a billing account. + * + */ +class BillingPermissionsListResult { + /** + * Create a BillingPermissionsListResult. + * @property {array} [value] The list OF billingPermissions a caller has on a + * billing account. + */ + constructor() { + } + + /** + * Defines the metadata of BillingPermissionsListResult + * + * @returns {object} metadata of BillingPermissionsListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'BillingPermissionsListResult', + type: { + name: 'Composite', + className: 'BillingPermissionsListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: 'value', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'BillingPermissionsElementType', + type: { + name: 'Composite', + className: 'BillingPermissions' + } + } + } + } + } + } + }; + } +} + +module.exports = BillingPermissionsListResult; diff --git a/lib/services/billingManagement/lib/models/billingProfile.js b/lib/services/billingManagement/lib/models/billingProfile.js new file mode 100644 index 0000000000..ce0d306a55 --- /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 receive 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..16a29c4857 --- /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} [billingProfileName] 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' + } + }, + billingProfileName: { + required: false, + readOnly: true, + serializedName: 'billingProfileName', + 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/billingRoleAssignment.js b/lib/services/billingManagement/lib/models/billingRoleAssignment.js new file mode 100644 index 0000000000..ac40f46d83 --- /dev/null +++ b/lib/services/billingManagement/lib/models/billingRoleAssignment.js @@ -0,0 +1,137 @@ +/* + * 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 role assignment + * + * @extends models['Resource'] + */ +class BillingRoleAssignment extends models['Resource'] { + /** + * Create a BillingRoleAssignment. + * @property {string} [createdOn] the date the role assignment is created + * @property {string} [createdByPrincipalTenantId] the creator's tenant Id + * @property {string} [createdByPrincipalId] the creator's principal Id + * @property {string} [billingRoleAssignmentName] the name of the role + * assignment + * @property {string} [principalId] The user's principal id that the role + * gets assigned to + * @property {string} [roleDefinitionName] The role definition id + * @property {string} [scope] The scope the role get assigned to + */ + constructor() { + super(); + } + + /** + * Defines the metadata of BillingRoleAssignment + * + * @returns {object} metadata of BillingRoleAssignment + * + */ + mapper() { + return { + required: false, + serializedName: 'BillingRoleAssignment', + type: { + name: 'Composite', + className: 'BillingRoleAssignment', + 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' + } + }, + createdOn: { + required: false, + readOnly: true, + serializedName: 'properties.createdOn', + type: { + name: 'String' + } + }, + createdByPrincipalTenantId: { + required: false, + readOnly: true, + serializedName: 'properties.createdByPrincipalTenantId', + type: { + name: 'String' + } + }, + createdByPrincipalId: { + required: false, + readOnly: true, + serializedName: 'properties.createdByPrincipalId', + type: { + name: 'String' + } + }, + billingRoleAssignmentName: { + required: false, + readOnly: true, + serializedName: 'properties.name', + type: { + name: 'String' + } + }, + principalId: { + required: false, + readOnly: true, + serializedName: 'properties.principalId', + type: { + name: 'String' + } + }, + roleDefinitionName: { + required: false, + readOnly: true, + serializedName: 'properties.roleDefinitionName', + type: { + name: 'String' + } + }, + scope: { + required: false, + readOnly: true, + serializedName: 'properties.scope', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = BillingRoleAssignment; diff --git a/lib/services/billingManagement/lib/models/billingRoleAssignmentListResult.js b/lib/services/billingManagement/lib/models/billingRoleAssignmentListResult.js new file mode 100644 index 0000000000..f6ac6edae6 --- /dev/null +++ b/lib/services/billingManagement/lib/models/billingRoleAssignmentListResult.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'; + +/** + * Result of get list of role assignments + * + */ +class BillingRoleAssignmentListResult { + /** + * Create a BillingRoleAssignmentListResult. + * @property {array} [value] The list role assignments + */ + constructor() { + } + + /** + * Defines the metadata of BillingRoleAssignmentListResult + * + * @returns {object} metadata of BillingRoleAssignmentListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'BillingRoleAssignmentListResult', + type: { + name: 'Composite', + className: 'BillingRoleAssignmentListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: 'value', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'BillingRoleAssignmentElementType', + type: { + name: 'Composite', + className: 'BillingRoleAssignment' + } + } + } + } + } + } + }; + } +} + +module.exports = BillingRoleAssignmentListResult; diff --git a/lib/services/billingManagement/lib/models/billingRoleAssignmentPayload.js b/lib/services/billingManagement/lib/models/billingRoleAssignmentPayload.js new file mode 100644 index 0000000000..c06f0642a2 --- /dev/null +++ b/lib/services/billingManagement/lib/models/billingRoleAssignmentPayload.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 payload use to update role assignment on a scope + * + */ +class BillingRoleAssignmentPayload { + /** + * Create a BillingRoleAssignmentPayload. + * @property {string} [principalId] The user's principal id that the role + * gets assigned to + * @property {string} [billingRoleDefinitionName] The role definition id + */ + constructor() { + } + + /** + * Defines the metadata of BillingRoleAssignmentPayload + * + * @returns {object} metadata of BillingRoleAssignmentPayload + * + */ + mapper() { + return { + required: false, + serializedName: 'BillingRoleAssignmentPayload', + type: { + name: 'Composite', + className: 'BillingRoleAssignmentPayload', + modelProperties: { + principalId: { + required: false, + readOnly: true, + serializedName: 'principalId', + type: { + name: 'String' + } + }, + billingRoleDefinitionName: { + required: false, + readOnly: true, + serializedName: 'billingRoleDefinitionName', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = BillingRoleAssignmentPayload; diff --git a/lib/services/billingManagement/lib/models/billingRoleDefinition.js b/lib/services/billingManagement/lib/models/billingRoleDefinition.js new file mode 100644 index 0000000000..6aa918962a --- /dev/null +++ b/lib/services/billingManagement/lib/models/billingRoleDefinition.js @@ -0,0 +1,108 @@ +/* + * 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'); + +/** + * Result of get role definition for a role. + * + * @extends models['Resource'] + */ +class BillingRoleDefinition extends models['Resource'] { + /** + * Create a BillingRoleDefinition. + * @property {string} [description] The role description + * @property {array} [value] The list OF billingPermissions a caller has on a + * billing account. + * @property {string} [roleName] The name of the role + */ + constructor() { + super(); + } + + /** + * Defines the metadata of BillingRoleDefinition + * + * @returns {object} metadata of BillingRoleDefinition + * + */ + mapper() { + return { + required: false, + serializedName: 'BillingRoleDefinition', + type: { + name: 'Composite', + className: 'BillingRoleDefinition', + 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' + } + }, + description: { + required: false, + readOnly: true, + serializedName: 'properties.description', + type: { + name: 'String' + } + }, + value: { + required: false, + readOnly: true, + serializedName: 'properties.permissions.value', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'BillingPermissionsElementType', + type: { + name: 'Composite', + className: 'BillingPermissions' + } + } + } + }, + roleName: { + required: false, + readOnly: true, + serializedName: 'properties.roleName', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = BillingRoleDefinition; diff --git a/lib/services/billingManagement/lib/models/billingRoleDefinitionListResult.js b/lib/services/billingManagement/lib/models/billingRoleDefinitionListResult.js new file mode 100644 index 0000000000..1714a1e297 --- /dev/null +++ b/lib/services/billingManagement/lib/models/billingRoleDefinitionListResult.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'; + +/** + * list the role definitions. + * + */ +class BillingRoleDefinitionListResult { + /** + * Create a BillingRoleDefinitionListResult. + * @property {array} [value] The list of role definitions. + */ + constructor() { + } + + /** + * Defines the metadata of BillingRoleDefinitionListResult + * + * @returns {object} metadata of BillingRoleDefinitionListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'BillingRoleDefinitionListResult', + type: { + name: 'Composite', + className: 'BillingRoleDefinitionListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: 'value', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'BillingRoleDefinitionElementType', + type: { + name: 'Composite', + className: 'BillingRoleDefinition' + } + } + } + } + } + } + }; + } +} + +module.exports = BillingRoleDefinitionListResult; diff --git a/lib/services/billingManagement/lib/models/billingSubscriptionSummary.js b/lib/services/billingManagement/lib/models/billingSubscriptionSummary.js new file mode 100644 index 0000000000..22be48817e --- /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.enrollmentAccountName] 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/detailedTransferStatus.js b/lib/services/billingManagement/lib/models/detailedTransferStatus.js new file mode 100644 index 0000000000..915d783875 --- /dev/null +++ b/lib/services/billingManagement/lib/models/detailedTransferStatus.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'; + +/** + * Detailed transfer status. + * + */ +class DetailedTransferStatus { + /** + * Create a DetailedTransferStatus. + * @property {string} [productType] Type of product being transferred. + * Possible values include: 'AzureSubscription', 'AzureReservation' + * @property {string} [productId] Id of product being transferred. + * @property {string} [transferStatus] Transfer status. Possible values + * include: 'NotStarted', 'InProgress', 'Completed', 'Failed' + * @property {object} [errorDetails] Error details for transfer execution. + * @property {string} [errorDetails.errorCode] Error code. + * @property {string} [errorDetails.errorMessage] Error message. + */ + constructor() { + } + + /** + * Defines the metadata of DetailedTransferStatus + * + * @returns {object} metadata of DetailedTransferStatus + * + */ + mapper() { + return { + required: false, + serializedName: 'DetailedTransferStatus', + type: { + name: 'Composite', + className: 'DetailedTransferStatus', + modelProperties: { + productType: { + required: false, + readOnly: true, + serializedName: 'productType', + type: { + name: 'String' + } + }, + productId: { + required: false, + readOnly: true, + serializedName: 'productId', + type: { + name: 'String' + } + }, + transferStatus: { + required: false, + readOnly: true, + serializedName: 'transferStatus', + type: { + name: 'String' + } + }, + errorDetails: { + required: false, + serializedName: 'errorDetails', + type: { + name: 'Composite', + className: 'ErrorModel' + } + } + } + } + }; + } +} + +module.exports = DetailedTransferStatus; 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..fff8f3d556 --- /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} [billingCycle] 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' + } + }, + billingCycle: { + required: false, + readOnly: true, + serializedName: 'billingCycle', + 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..336a70d861 --- /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} [enrollmentAccountName] 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' + } + }, + enrollmentAccountName: { + required: false, + serializedName: 'enrollmentAccountName', + 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/errorModel.js b/lib/services/billingManagement/lib/models/errorModel.js new file mode 100644 index 0000000000..99e92e0c1a --- /dev/null +++ b/lib/services/billingManagement/lib/models/errorModel.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'; + +/** + * Error details for transfer execution. + * + */ +class ErrorModel { + /** + * Create a ErrorModel. + * @property {string} [errorCode] Error code. + * @property {string} [errorMessage] Error message. + */ + constructor() { + } + + /** + * Defines the metadata of ErrorModel + * + * @returns {object} metadata of ErrorModel + * + */ + mapper() { + return { + required: false, + serializedName: 'Error', + type: { + name: 'Composite', + className: 'ErrorModel', + modelProperties: { + errorCode: { + required: false, + readOnly: true, + serializedName: 'errorCode', + type: { + name: 'String' + } + }, + errorMessage: { + required: false, + readOnly: true, + serializedName: 'errorMessage', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ErrorModel; 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..60fffd1b7d 100644 --- a/lib/services/billingManagement/lib/models/index.d.ts +++ b/lib/services/billingManagement/lib/models/index.d.ts @@ -1,227 +1,1333 @@ /* * 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 +}; + +/** + * Request parameters to initiate transfer. + */ +export interface InitiateTransferRequest { + /** + * Target Usage context for devTest subscriptions. + */ + billingProfileId?: string; + /** + * Email Id of recipient for transfer. + */ + recipientEmailId?: string; +} + +/** + * Details of the product to be transferred. + */ +export interface ProductDetails { + /** + * Type of the prouct to be transferred. Possible values include: 'AzureSubscription', + * 'AzureReservation' + */ + productType?: string; + /** + * Id of product to be transferred. + */ + productId?: string; +} + +/** + * Request parameters to accept transfer. + */ +export interface AcceptTransferRequest { + /** + * Request parameters to accept transfer. + */ + productDetails?: ProductDetails[]; +} + +/** + * Error details for transfer execution. + */ +export interface ErrorModel { + /** + * Error code. + */ + readonly errorCode?: string; + /** + * Error message. + */ + readonly errorMessage?: string; +} + +/** + * Detailed transfer status. + */ +export interface DetailedTransferStatus { + /** + * Type of product being transferred. Possible values include: 'AzureSubscription', + * 'AzureReservation' + */ + readonly productType?: string; + /** + * Id of product being transferred. + */ + readonly productId?: string; + /** + * Transfer status. Possible values include: 'NotStarted', 'InProgress', 'Completed', 'Failed' + */ + readonly transferStatus?: string; + /** + * Error details for transfer execution. + */ + errorDetails?: ErrorModel; +} + +/** + * Details of the transfer. + */ +export interface TransferDetails { + /** + * Transfer creation time. + */ + readonly creationTime?: Date; + /** + * Transfer expiration time. + */ + readonly expirationTime?: Date; + /** + * Target invoice setion Id. + */ + readonly invoiceSectionId?: string; + /** + * Target billing account Id. + */ + readonly billingAccountId?: string; + /** + * Overall transfer status. Possible values include: 'Pending', 'InProgress', 'Completed', + * 'CompletedWithErrors', 'Failed', 'Canceled', 'Declined' + */ + readonly transferStatus?: string; + /** + * Email Id of recipient of transfer. + */ + readonly recipientEmailId?: string; + /** + * Email Id of initiator of transfer. + */ + readonly initiatorEmailId?: string; + /** + * Email Id who user canceled the transfer. + */ + readonly canceledBy?: string; + /** + * Transfer last modification time. + */ + readonly lastModifiedTime?: Date; + /** + * Detailed transfer status. + */ + readonly detailedTransferStatus?: DetailedTransferStatus[]; +} + +/** + * Details of the transfer. + */ +export interface RecipientTransferDetails { + /** + * Transfer creation time. + */ + readonly creationTime?: Date; + /** + * Transfer expiration time. + */ + readonly expirationTime?: Date; + /** + * Type of subscriptions that can be transferred. + */ + readonly allowedProductType?: string[]; + /** + * Overall transfer status. Possible values include: 'Pending', 'InProgress', 'Completed', + * 'CompletedWithErrors', 'Failed', 'Canceled', 'Declined' + */ + readonly transferStatus?: string; + /** + * Email Id of recipient of transfer. + */ + readonly recipientEmailId?: string; + /** + * Email Id of initiator of transfer. + */ + readonly initiatorEmailId?: string; + /** + * Email Id who user canceled the transfer. + */ + readonly canceledBy?: string; + /** + * Transfer last modification time. + */ + readonly lastModifiedTime?: Date; + /** + * Detailed transfer status. + */ + readonly detailedTransferStatus?: DetailedTransferStatus[]; +} + +/** + * The properties of the product to initiate a transfer. + */ +export interface TransferProductRequestProperties { + /** + * Destination invoice section id. + */ + destinationInvoiceSectionName?: string; +} + +/** + * Request parameters to transfer billing subscription. + */ +export interface TransferBillingSubscriptionResult { + /** + * The destination billing subscription id. + */ + billingSubscriptionName?: string; +} + +/** + * Request parameters to transfer billing subscription. + */ +export interface TransferBillingSubscriptionRequestProperties { + /** + * The destination invoiceSectionName. + */ + destinationInvoiceSectionName?: string; +} + +/** + * Request parameters to transfer billing subscription. + */ +export interface TransferBillingSubscriptionRequest { + /** + * The destination invoiceSectionName. + */ + destinationInvoiceSectionName?: 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 receive 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 billingCycle?: 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 billingProfileName?: 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. + */ + enrollmentAccountName?: 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 product. + */ +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; } +/** + * The payload use to update role assignment on a scope + */ +export interface BillingRoleAssignmentPayload { + /** + * The user's principal id that the role gets assigned to + */ + readonly principalId?: string; + /** + * The role definition id + */ + readonly billingRoleDefinitionName?: 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. + * a role assignment + */ +export interface BillingRoleAssignment extends Resource { + /** + * the date the role assignment is created + */ + readonly createdOn?: string; + /** + * the creator's tenant Id + */ + readonly createdByPrincipalTenantId?: string; + /** + * the creator's principal Id + */ + readonly createdByPrincipalId?: string; + /** + * the name of the role assignment + */ + readonly billingRoleAssignmentName?: string; + /** + * The user's principal id that the role gets assigned to + */ + readonly principalId?: string; + /** + * The role definition id + */ + readonly roleDefinitionName?: string; + /** + * The scope the role get assigned to + */ + readonly scope?: string; +} + +/** + * Result of get list of role assignments + */ +export interface BillingRoleAssignmentListResult { + /** + * The list role assignments + */ + readonly value?: BillingRoleAssignment[]; +} + +/** + * The set of allowed action and not allowed actions a caller has on a billing account */ -export interface EnrollmentAccountListResult extends Array { +export interface BillingPermissions { + /** + * The set of actions that the caller is allowed to do + */ + readonly actions?: string[]; + /** + * The set of actions the caller is not allowed to do + */ + readonly notActions?: string[]; +} + +/** + * Result of list billingPermissions a caller has on a billing account. + */ +export interface BillingPermissionsListResult { + /** + * The list OF billingPermissions a caller has on a billing account. + */ + readonly value?: BillingPermissions[]; +} + +/** + * Result of get role definition for a role. + */ +export interface BillingRoleDefinition extends Resource { + /** + * The role description + */ + readonly description?: string; + /** + * The list OF billingPermissions a caller has on a billing account. + */ + readonly value?: BillingPermissions[]; + /** + * The name of the role + */ + readonly roleName?: string; +} + +/** + * list the role definitions. + */ +export interface BillingRoleDefinitionListResult { + /** + * The list of role definitions. + */ + readonly value?: BillingRoleDefinition[]; +} + +/** + * 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 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 billing subscriptions summary. */ -export interface BillingPeriodsListResult 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 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 products summary. It contains a list of available products summaries in + * reverse chronological order by purchase date. */ -export interface InvoicesListResult 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 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 of listing reservation transactions summary. + */ +export interface TransactionsListResult extends Array { + /** + * The link (url) to the next page of results. + */ + readonly nextLink?: string; +} + +/** + * Result of listing details of the transfer initiated by caller. + */ +export interface TransferDetailsListResult extends Array { + /** + * The link (url) to the next page of results. + */ + readonly nextLink?: string; +} + +/** + * Result of listing details of the transfer received by caller. + */ +export interface RecipientTransferDetailsListResult extends Array { + /** + * The link (url) to the next page of results. + */ + readonly nextLink?: string; +} + +/** + * 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..398b3e64e2 100644 --- a/lib/services/billingManagement/lib/models/index.js +++ b/lib/services/billingManagement/lib/models/index.js @@ -18,16 +18,65 @@ var msRestAzure = require('ms-rest-azure'); exports.BaseResource = msRestAzure.BaseResource; exports.CloudError = msRestAzure.CloudError; +exports.InitiateTransferRequest = require('./initiateTransferRequest'); +exports.ProductDetails = require('./productDetails'); +exports.AcceptTransferRequest = require('./acceptTransferRequest'); +exports.ErrorModel = require('./errorModel'); +exports.DetailedTransferStatus = require('./detailedTransferStatus'); +exports.TransferDetails = require('./transferDetails'); +exports.RecipientTransferDetails = require('./recipientTransferDetails'); +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.BillingRoleAssignmentPayload = require('./billingRoleAssignmentPayload'); +exports.BillingRoleAssignment = require('./billingRoleAssignment'); +exports.BillingRoleAssignmentListResult = require('./billingRoleAssignmentListResult'); +exports.BillingPermissions = require('./billingPermissions'); +exports.BillingPermissionsListResult = require('./billingPermissionsListResult'); +exports.BillingRoleDefinition = require('./billingRoleDefinition'); +exports.BillingRoleDefinitionListResult = require('./billingRoleDefinitionListResult'); +exports.PaymentMethodsListResult = require('./paymentMethodsListResult'); +exports.BillingSubscriptionsListResult = require('./billingSubscriptionsListResult'); +exports.ProductsListResult = require('./productsListResult'); +exports.TransactionsListResult = require('./transactionsListResult'); +exports.TransferDetailsListResult = require('./transferDetailsListResult'); +exports.RecipientTransferDetailsListResult = require('./recipientTransferDetailsListResult'); exports.OperationListResult = require('./operationListResult'); diff --git a/lib/services/billingManagement/lib/models/initiateTransferRequest.js b/lib/services/billingManagement/lib/models/initiateTransferRequest.js new file mode 100644 index 0000000000..e0304d277a --- /dev/null +++ b/lib/services/billingManagement/lib/models/initiateTransferRequest.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'; + +/** + * Request parameters to initiate transfer. + * + */ +class InitiateTransferRequest { + /** + * Create a InitiateTransferRequest. + * @property {string} [billingProfileId] Target Usage context for devTest + * subscriptions. + * @property {string} [recipientEmailId] Email Id of recipient for transfer. + */ + constructor() { + } + + /** + * Defines the metadata of InitiateTransferRequest + * + * @returns {object} metadata of InitiateTransferRequest + * + */ + mapper() { + return { + required: false, + serializedName: 'InitiateTransferRequest', + type: { + name: 'Composite', + className: 'InitiateTransferRequest', + modelProperties: { + billingProfileId: { + required: false, + serializedName: 'properties.billingProfileId', + type: { + name: 'String' + } + }, + recipientEmailId: { + required: false, + serializedName: 'properties.recipientEmailId', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = InitiateTransferRequest; 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/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/productDetails.js b/lib/services/billingManagement/lib/models/productDetails.js new file mode 100644 index 0000000000..11bdc906f2 --- /dev/null +++ b/lib/services/billingManagement/lib/models/productDetails.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 of the product to be transferred. + * + */ +class ProductDetails { + /** + * Create a ProductDetails. + * @property {string} [productType] Type of the prouct to be transferred. + * Possible values include: 'AzureSubscription', 'AzureReservation' + * @property {string} [productId] Id of product to be transferred. + */ + constructor() { + } + + /** + * Defines the metadata of ProductDetails + * + * @returns {object} metadata of ProductDetails + * + */ + mapper() { + return { + required: false, + serializedName: 'ProductDetails', + type: { + name: 'Composite', + className: 'ProductDetails', + modelProperties: { + productType: { + required: false, + serializedName: 'productType', + type: { + name: 'String' + } + }, + productId: { + required: false, + serializedName: 'productId', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ProductDetails; 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/recipientTransferDetails.js b/lib/services/billingManagement/lib/models/recipientTransferDetails.js new file mode 100644 index 0000000000..4ad64045cc --- /dev/null +++ b/lib/services/billingManagement/lib/models/recipientTransferDetails.js @@ -0,0 +1,143 @@ +/* + * 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 of the transfer. + * + */ +class RecipientTransferDetails { + /** + * Create a RecipientTransferDetails. + * @property {date} [creationTime] Transfer creation time. + * @property {date} [expirationTime] Transfer expiration time. + * @property {array} [allowedProductType] Type of subscriptions that can be + * transferred. + * @property {string} [transferStatus] Overall transfer status. Possible + * values include: 'Pending', 'InProgress', 'Completed', + * 'CompletedWithErrors', 'Failed', 'Canceled', 'Declined' + * @property {string} [recipientEmailId] Email Id of recipient of transfer. + * @property {string} [initiatorEmailId] Email Id of initiator of transfer. + * @property {string} [canceledBy] Email Id who user canceled the transfer. + * @property {date} [lastModifiedTime] Transfer last modification time. + * @property {array} [detailedTransferStatus] Detailed transfer status. + */ + constructor() { + } + + /** + * Defines the metadata of RecipientTransferDetails + * + * @returns {object} metadata of RecipientTransferDetails + * + */ + mapper() { + return { + required: false, + serializedName: 'RecipientTransferDetails', + type: { + name: 'Composite', + className: 'RecipientTransferDetails', + modelProperties: { + creationTime: { + required: false, + readOnly: true, + serializedName: 'properties.creationTime', + type: { + name: 'DateTime' + } + }, + expirationTime: { + required: false, + readOnly: true, + serializedName: 'properties.expirationTime', + type: { + name: 'DateTime' + } + }, + allowedProductType: { + required: false, + readOnly: true, + serializedName: 'properties.allowedProductType', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'EligibleProductTypeElementType', + type: { + name: 'String' + } + } + } + }, + transferStatus: { + required: false, + readOnly: true, + serializedName: 'properties.transferStatus', + type: { + name: 'String' + } + }, + recipientEmailId: { + required: false, + readOnly: true, + serializedName: 'properties.recipientEmailId', + type: { + name: 'String' + } + }, + initiatorEmailId: { + required: false, + readOnly: true, + serializedName: 'properties.initiatorEmailId', + type: { + name: 'String' + } + }, + canceledBy: { + required: false, + readOnly: true, + serializedName: 'properties.canceledBy', + type: { + name: 'String' + } + }, + lastModifiedTime: { + required: false, + readOnly: true, + serializedName: 'properties.lastModifiedTime', + type: { + name: 'DateTime' + } + }, + detailedTransferStatus: { + required: false, + readOnly: true, + serializedName: 'properties.detailedTransferStatus', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'DetailedTransferStatusElementType', + type: { + name: 'Composite', + className: 'DetailedTransferStatus' + } + } + } + } + } + } + }; + } +} + +module.exports = RecipientTransferDetails; diff --git a/lib/services/billingManagement/lib/models/recipientTransferDetailsListResult.js b/lib/services/billingManagement/lib/models/recipientTransferDetailsListResult.js new file mode 100644 index 0000000000..67a1a8f7a4 --- /dev/null +++ b/lib/services/billingManagement/lib/models/recipientTransferDetailsListResult.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 details of the transfer received by caller. + */ +class RecipientTransferDetailsListResult extends Array { + /** + * Create a RecipientTransferDetailsListResult. + * @property {string} [nextLink] The link (url) to the next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of RecipientTransferDetailsListResult + * + * @returns {object} metadata of RecipientTransferDetailsListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'RecipientTransferDetailsListResult', + type: { + name: 'Composite', + className: 'RecipientTransferDetailsListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'RecipientTransferDetailsElementType', + type: { + name: 'Composite', + className: 'RecipientTransferDetails' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = RecipientTransferDetailsListResult; 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..56864aaa49 --- /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} [destinationInvoiceSectionName] The destination + * invoiceSectionName. + */ + constructor() { + } + + /** + * Defines the metadata of TransferBillingSubscriptionRequest + * + * @returns {object} metadata of TransferBillingSubscriptionRequest + * + */ + mapper() { + return { + required: false, + serializedName: 'TransferBillingSubscriptionRequest', + type: { + name: 'Composite', + className: 'TransferBillingSubscriptionRequest', + modelProperties: { + destinationInvoiceSectionName: { + required: false, + serializedName: 'properties.destinationInvoiceSectionName', + 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..e8805170c1 --- /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} [destinationInvoiceSectionName] The destination + * invoiceSectionName. + */ + constructor() { + } + + /** + * Defines the metadata of TransferBillingSubscriptionRequestProperties + * + * @returns {object} metadata of TransferBillingSubscriptionRequestProperties + * + */ + mapper() { + return { + required: false, + serializedName: 'TransferBillingSubscriptionRequestProperties', + type: { + name: 'Composite', + className: 'TransferBillingSubscriptionRequestProperties', + modelProperties: { + destinationInvoiceSectionName: { + required: false, + serializedName: 'destinationInvoiceSectionName', + 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..66ae52ae07 --- /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} [billingSubscriptionName] 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: { + billingSubscriptionName: { + required: false, + serializedName: 'properties.billingSubscriptionName', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = TransferBillingSubscriptionResult; diff --git a/lib/services/billingManagement/lib/models/transferDetails.js b/lib/services/billingManagement/lib/models/transferDetails.js new file mode 100644 index 0000000000..f4a5e70722 --- /dev/null +++ b/lib/services/billingManagement/lib/models/transferDetails.js @@ -0,0 +1,144 @@ +/* + * 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 of the transfer. + * + */ +class TransferDetails { + /** + * Create a TransferDetails. + * @property {date} [creationTime] Transfer creation time. + * @property {date} [expirationTime] Transfer expiration time. + * @property {string} [invoiceSectionId] Target invoice setion Id. + * @property {string} [billingAccountId] Target billing account Id. + * @property {string} [transferStatus] Overall transfer status. Possible + * values include: 'Pending', 'InProgress', 'Completed', + * 'CompletedWithErrors', 'Failed', 'Canceled', 'Declined' + * @property {string} [recipientEmailId] Email Id of recipient of transfer. + * @property {string} [initiatorEmailId] Email Id of initiator of transfer. + * @property {string} [canceledBy] Email Id who user canceled the transfer. + * @property {date} [lastModifiedTime] Transfer last modification time. + * @property {array} [detailedTransferStatus] Detailed transfer status. + */ + constructor() { + } + + /** + * Defines the metadata of TransferDetails + * + * @returns {object} metadata of TransferDetails + * + */ + mapper() { + return { + required: false, + serializedName: 'TransferDetails', + type: { + name: 'Composite', + className: 'TransferDetails', + modelProperties: { + creationTime: { + required: false, + readOnly: true, + serializedName: 'properties.creationTime', + type: { + name: 'DateTime' + } + }, + expirationTime: { + required: false, + readOnly: true, + serializedName: 'properties.expirationTime', + type: { + name: 'DateTime' + } + }, + invoiceSectionId: { + required: false, + readOnly: true, + serializedName: 'properties.invoiceSectionId', + type: { + name: 'String' + } + }, + billingAccountId: { + required: false, + readOnly: true, + serializedName: 'properties.billingAccountId', + type: { + name: 'String' + } + }, + transferStatus: { + required: false, + readOnly: true, + serializedName: 'properties.transferStatus', + type: { + name: 'String' + } + }, + recipientEmailId: { + required: false, + readOnly: true, + serializedName: 'properties.recipientEmailId', + type: { + name: 'String' + } + }, + initiatorEmailId: { + required: false, + readOnly: true, + serializedName: 'properties.initiatorEmailId', + type: { + name: 'String' + } + }, + canceledBy: { + required: false, + readOnly: true, + serializedName: 'properties.canceledBy', + type: { + name: 'String' + } + }, + lastModifiedTime: { + required: false, + readOnly: true, + serializedName: 'properties.lastModifiedTime', + type: { + name: 'DateTime' + } + }, + detailedTransferStatus: { + required: false, + readOnly: true, + serializedName: 'properties.detailedTransferStatus', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'DetailedTransferStatusElementType', + type: { + name: 'Composite', + className: 'DetailedTransferStatus' + } + } + } + } + } + } + }; + } +} + +module.exports = TransferDetails; diff --git a/lib/services/billingManagement/lib/models/transferDetailsListResult.js b/lib/services/billingManagement/lib/models/transferDetailsListResult.js new file mode 100644 index 0000000000..2297602f97 --- /dev/null +++ b/lib/services/billingManagement/lib/models/transferDetailsListResult.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 details of the transfer initiated by caller. + */ +class TransferDetailsListResult extends Array { + /** + * Create a TransferDetailsListResult. + * @property {string} [nextLink] The link (url) to the next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of TransferDetailsListResult + * + * @returns {object} metadata of TransferDetailsListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'TransferDetailsListResult', + type: { + name: 'Composite', + className: 'TransferDetailsListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'TransferDetailsElementType', + type: { + name: 'Composite', + className: 'TransferDetails' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = TransferDetailsListResult; diff --git a/lib/services/billingManagement/lib/models/transferProductRequestProperties.js b/lib/services/billingManagement/lib/models/transferProductRequestProperties.js new file mode 100644 index 0000000000..873c51dc64 --- /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} [destinationInvoiceSectionName] 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: { + destinationInvoiceSectionName: { + required: false, + serializedName: 'destinationInvoiceSectionName', + 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..cc2c108098 --- /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 product. + * + */ +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..89b84cf277 --- /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 billingAccountName and + * billingProfileName. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (billingProfileName === null || billingProfileName === undefined || typeof billingProfileName.valueOf() !== 'string') { + throw new Error('billingProfileName 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/{billingAccountName}/billingProfiles/{billingProfileName}/availableBalance/default'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{billingProfileName}', encodeURIComponent(billingProfileName)); + 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 billingAccountName and + * billingProfileName. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountName, billingProfileName, 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 billingAccountName and + * billingProfileName. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, 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(billingAccountName, billingProfileName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountName, billingProfileName, options, optionalCallback); + } + } + +} + +module.exports = AvailableBalanceByBillingProfile; diff --git a/lib/services/billingManagement/lib/operations/billingAccountBillingPermissions.js b/lib/services/billingManagement/lib/operations/billingAccountBillingPermissions.js new file mode 100644 index 0000000000..71c2ba9716 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/billingAccountBillingPermissions.js @@ -0,0 +1,250 @@ +/* + * 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 billingPermissions for the caller has for a billing account. + * + * @param {string} billingAccountName 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 BillingPermissionsListResult} for more + * information. + * + * {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(billingAccountName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName 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/{billingAccountName}/providers/Microsoft.Billing/billingPermissions'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + 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['BillingPermissionsListResult']().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 BillingAccountBillingPermissions. */ +class BillingAccountBillingPermissions { + /** + * Create a BillingAccountBillingPermissions. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + } + + /** + * Lists all billingPermissions for the caller has for a billing account. + * + * @param {string} billingAccountName 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(billingAccountName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, 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 billingPermissions for the caller has for a billing account. + * + * @param {string} billingAccountName 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 {BillingPermissionsListResult} - 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 BillingPermissionsListResult} for more + * information. + * + * {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(billingAccountName, 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(billingAccountName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, options, optionalCallback); + } + } + +} + +module.exports = BillingAccountBillingPermissions; diff --git a/lib/services/billingManagement/lib/operations/billingAccountBillingRoleAssignment.js b/lib/services/billingManagement/lib/operations/billingAccountBillingRoleAssignment.js new file mode 100644 index 0000000000..02a5c6715c --- /dev/null +++ b/lib/services/billingManagement/lib/operations/billingAccountBillingRoleAssignment.js @@ -0,0 +1,944 @@ +/* + * 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 role assignment for the caller + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingRoleAssignmentName role assignment 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 BillingRoleAssignment} for more information. + * + * {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(billingAccountName, billingRoleAssignmentName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (billingRoleAssignmentName === null || billingRoleAssignmentName === undefined || typeof billingRoleAssignmentName.valueOf() !== 'string') { + throw new Error('billingRoleAssignmentName 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/{billingAccountName}/providers/Microsoft.Billing/billingRoleAssignments/{billingRoleAssignmentName}'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{billingRoleAssignmentName}', encodeURIComponent(billingRoleAssignmentName)); + 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['BillingRoleAssignment']().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); + }); +} + +/** + * Delete the role assignment on this billing account + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingRoleAssignmentName role assignment 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 BillingRoleAssignment} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(billingAccountName, billingRoleAssignmentName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (billingRoleAssignmentName === null || billingRoleAssignmentName === undefined || typeof billingRoleAssignmentName.valueOf() !== 'string') { + throw new Error('billingRoleAssignmentName 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/{billingAccountName}/providers/Microsoft.Billing/billingRoleAssignments/{billingRoleAssignmentName}'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{billingRoleAssignmentName}', encodeURIComponent(billingRoleAssignmentName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // 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['BillingRoleAssignment']().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 role assignments on the Billing Account + * + * @param {string} billingAccountName 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 BillingRoleAssignmentListResult} for more + * information. + * + * {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(billingAccountName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName 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/{billingAccountName}/providers/Microsoft.Billing/billingRoleAssignments'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + 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['BillingRoleAssignmentListResult']().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 add a role assignment to a billing account. + * + * @param {string} billingAccountName 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 BillingRoleAssignmentListResult} for more + * information. + * + * {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 _add(billingAccountName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + let parameters = new client.models['BillingRoleAssignmentPayload'](); + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountName}/providers/Microsoft.Billing/createBillingRoleAssignment'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + 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['BillingRoleAssignmentPayload']().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 !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['BillingRoleAssignmentListResult']().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 BillingAccountBillingRoleAssignment. */ +class BillingAccountBillingRoleAssignment { + /** + * Create a BillingAccountBillingRoleAssignment. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._deleteMethod = _deleteMethod; + this._list = _list; + this._add = _add; + } + + /** + * Get the role assignment for the caller + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingRoleAssignmentName role assignment 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(billingAccountName, billingRoleAssignmentName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountName, billingRoleAssignmentName, 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 role assignment for the caller + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingRoleAssignmentName role assignment 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 {BillingRoleAssignment} - 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 BillingRoleAssignment} for more information. + * + * {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(billingAccountName, billingRoleAssignmentName, 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(billingAccountName, billingRoleAssignmentName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountName, billingRoleAssignmentName, options, optionalCallback); + } + } + + /** + * Delete the role assignment on this billing account + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingRoleAssignmentName role assignment 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. + */ + deleteMethodWithHttpOperationResponse(billingAccountName, billingRoleAssignmentName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(billingAccountName, billingRoleAssignmentName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Delete the role assignment on this billing account + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingRoleAssignmentName role assignment 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 {BillingRoleAssignment} - 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 BillingRoleAssignment} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(billingAccountName, billingRoleAssignmentName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(billingAccountName, billingRoleAssignmentName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(billingAccountName, billingRoleAssignmentName, options, optionalCallback); + } + } + + /** + * Get the role assignments on the Billing Account + * + * @param {string} billingAccountName 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(billingAccountName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, 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 role assignments on the Billing Account + * + * @param {string} billingAccountName 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 {BillingRoleAssignmentListResult} - 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 BillingRoleAssignmentListResult} for more + * information. + * + * {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(billingAccountName, 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(billingAccountName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, options, optionalCallback); + } + } + + /** + * The operation to add a role assignment to a billing account. + * + * @param {string} billingAccountName 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. + */ + addWithHttpOperationResponse(billingAccountName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._add(billingAccountName, 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 add a role assignment to a billing account. + * + * @param {string} billingAccountName 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 {BillingRoleAssignmentListResult} - 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 BillingRoleAssignmentListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + add(billingAccountName, 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._add(billingAccountName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._add(billingAccountName, options, optionalCallback); + } + } + +} + +module.exports = BillingAccountBillingRoleAssignment; diff --git a/lib/services/billingManagement/lib/operations/billingAccountBillingRoleDefinition.js b/lib/services/billingManagement/lib/operations/billingAccountBillingRoleDefinition.js new file mode 100644 index 0000000000..9dc889824e --- /dev/null +++ b/lib/services/billingManagement/lib/operations/billingAccountBillingRoleDefinition.js @@ -0,0 +1,479 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets the role definition for a role + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingRoleDefinitionName role definition 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 BillingRoleDefinition} for more information. + * + * {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(billingAccountName, billingRoleDefinitionName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (billingRoleDefinitionName === null || billingRoleDefinitionName === undefined || typeof billingRoleDefinitionName.valueOf() !== 'string') { + throw new Error('billingRoleDefinitionName 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/{billingAccountName}/providers/Microsoft.Billing/billingRoleDefinitions/{billingRoleDefinitionName}'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{billingRoleDefinitionName}', encodeURIComponent(billingRoleDefinitionName)); + 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['BillingRoleDefinition']().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 role definition for a billing account + * + * @param {string} billingAccountName 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 BillingRoleDefinitionListResult} for more + * information. + * + * {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(billingAccountName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName 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/{billingAccountName}/providers/Microsoft.Billing/billingRoleDefinitions'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + 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['BillingRoleDefinitionListResult']().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 BillingAccountBillingRoleDefinition. */ +class BillingAccountBillingRoleDefinition { + /** + * Create a BillingAccountBillingRoleDefinition. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._list = _list; + } + + /** + * Gets the role definition for a role + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingRoleDefinitionName role definition 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(billingAccountName, billingRoleDefinitionName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountName, billingRoleDefinitionName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the role definition for a role + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingRoleDefinitionName role definition 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 {BillingRoleDefinition} - 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 BillingRoleDefinition} for more information. + * + * {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(billingAccountName, billingRoleDefinitionName, 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(billingAccountName, billingRoleDefinitionName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountName, billingRoleDefinitionName, options, optionalCallback); + } + } + + /** + * Lists the role definition for a billing account + * + * @param {string} billingAccountName 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(billingAccountName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, 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 role definition for a billing account + * + * @param {string} billingAccountName 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 {BillingRoleDefinitionListResult} - 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 BillingRoleDefinitionListResult} for more + * information. + * + * {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(billingAccountName, 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(billingAccountName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, options, optionalCallback); + } + } + +} + +module.exports = BillingAccountBillingRoleDefinition; diff --git a/lib/services/billingManagement/lib/operations/billingAccounts.js b/lib/services/billingManagement/lib/operations/billingAccounts.js new file mode 100644 index 0000000000..8d56829929 --- /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} billingAccountName 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(billingAccountName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName 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/{billingAccountName}'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + 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} billingAccountName 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(billingAccountName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountName, 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} billingAccountName 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(billingAccountName, 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(billingAccountName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountName, 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/billingProfileBillingPermissions.js b/lib/services/billingManagement/lib/operations/billingProfileBillingPermissions.js new file mode 100644 index 0000000000..f968f1e972 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/billingProfileBillingPermissions.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 all billingPermissions for the caller has for a billing account. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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 BillingPermissionsListResult} for more + * information. + * + * {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(billingAccountName, billingProfileName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (billingProfileName === null || billingProfileName === undefined || typeof billingProfileName.valueOf() !== 'string') { + throw new Error('billingProfileName 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/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Billing/billingPermissions'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{billingProfileName}', encodeURIComponent(billingProfileName)); + 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['BillingPermissionsListResult']().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 BillingProfileBillingPermissions. */ +class BillingProfileBillingPermissions { + /** + * Create a BillingProfileBillingPermissions. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + } + + /** + * Lists all billingPermissions for the caller has for a billing account. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, billingProfileName, 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 billingPermissions for the caller has for a billing account. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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 {BillingPermissionsListResult} - 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 BillingPermissionsListResult} for more + * information. + * + * {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(billingAccountName, billingProfileName, 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(billingAccountName, billingProfileName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, billingProfileName, options, optionalCallback); + } + } + +} + +module.exports = BillingProfileBillingPermissions; diff --git a/lib/services/billingManagement/lib/operations/billingProfileBillingRoleAssignment.js b/lib/services/billingManagement/lib/operations/billingProfileBillingRoleAssignment.js new file mode 100644 index 0000000000..7a67246a1f --- /dev/null +++ b/lib/services/billingManagement/lib/operations/billingProfileBillingRoleAssignment.js @@ -0,0 +1,984 @@ +/* + * 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 role assignment for the caller on the Billing Profile + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName Billing Profile Id. + * + * @param {string} billingRoleAssignmentName role assignment 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 BillingRoleAssignment} for more information. + * + * {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(billingAccountName, billingProfileName, billingRoleAssignmentName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (billingProfileName === null || billingProfileName === undefined || typeof billingProfileName.valueOf() !== 'string') { + throw new Error('billingProfileName cannot be null or undefined and it must be of type string.'); + } + if (billingRoleAssignmentName === null || billingRoleAssignmentName === undefined || typeof billingRoleAssignmentName.valueOf() !== 'string') { + throw new Error('billingRoleAssignmentName 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/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Billing/billingRoleAssignments/{billingRoleAssignmentName}'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{billingProfileName}', encodeURIComponent(billingProfileName)); + requestUrl = requestUrl.replace('{billingRoleAssignmentName}', encodeURIComponent(billingRoleAssignmentName)); + 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['BillingRoleAssignment']().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); + }); +} + +/** + * Delete the role assignment on this Billing Profile + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName Billing Profile Id. + * + * @param {string} billingRoleAssignmentName role assignment 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 BillingRoleAssignment} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(billingAccountName, billingProfileName, billingRoleAssignmentName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (billingProfileName === null || billingProfileName === undefined || typeof billingProfileName.valueOf() !== 'string') { + throw new Error('billingProfileName cannot be null or undefined and it must be of type string.'); + } + if (billingRoleAssignmentName === null || billingRoleAssignmentName === undefined || typeof billingRoleAssignmentName.valueOf() !== 'string') { + throw new Error('billingRoleAssignmentName 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/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Billing/billingRoleAssignments/{billingRoleAssignmentName}'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{billingProfileName}', encodeURIComponent(billingProfileName)); + requestUrl = requestUrl.replace('{billingRoleAssignmentName}', encodeURIComponent(billingRoleAssignmentName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // 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['BillingRoleAssignment']().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 role assignments on the Billing Profile + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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 BillingRoleAssignmentListResult} for more + * information. + * + * {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(billingAccountName, billingProfileName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (billingProfileName === null || billingProfileName === undefined || typeof billingProfileName.valueOf() !== 'string') { + throw new Error('billingProfileName 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/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Billing/billingRoleAssignments'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{billingProfileName}', encodeURIComponent(billingProfileName)); + 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['BillingRoleAssignmentListResult']().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 add a role assignment to a billing profile. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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 BillingRoleAssignmentListResult} for more + * information. + * + * {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 _add(billingAccountName, billingProfileName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (billingProfileName === null || billingProfileName === undefined || typeof billingProfileName.valueOf() !== 'string') { + throw new Error('billingProfileName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + let parameters = new client.models['BillingRoleAssignmentPayload'](); + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Billing/createBillingRoleAssignment'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{billingProfileName}', encodeURIComponent(billingProfileName)); + 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['BillingRoleAssignmentPayload']().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 !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['BillingRoleAssignmentListResult']().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 BillingProfileBillingRoleAssignment. */ +class BillingProfileBillingRoleAssignment { + /** + * Create a BillingProfileBillingRoleAssignment. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._deleteMethod = _deleteMethod; + this._list = _list; + this._add = _add; + } + + /** + * Get the role assignment for the caller on the Billing Profile + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName Billing Profile Id. + * + * @param {string} billingRoleAssignmentName role assignment 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(billingAccountName, billingProfileName, billingRoleAssignmentName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountName, billingProfileName, billingRoleAssignmentName, 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 role assignment for the caller on the Billing Profile + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName Billing Profile Id. + * + * @param {string} billingRoleAssignmentName role assignment 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 {BillingRoleAssignment} - 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 BillingRoleAssignment} for more information. + * + * {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(billingAccountName, billingProfileName, billingRoleAssignmentName, 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(billingAccountName, billingProfileName, billingRoleAssignmentName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountName, billingProfileName, billingRoleAssignmentName, options, optionalCallback); + } + } + + /** + * Delete the role assignment on this Billing Profile + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName Billing Profile Id. + * + * @param {string} billingRoleAssignmentName role assignment 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. + */ + deleteMethodWithHttpOperationResponse(billingAccountName, billingProfileName, billingRoleAssignmentName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(billingAccountName, billingProfileName, billingRoleAssignmentName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Delete the role assignment on this Billing Profile + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName Billing Profile Id. + * + * @param {string} billingRoleAssignmentName role assignment 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 {BillingRoleAssignment} - 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 BillingRoleAssignment} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(billingAccountName, billingProfileName, billingRoleAssignmentName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(billingAccountName, billingProfileName, billingRoleAssignmentName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(billingAccountName, billingProfileName, billingRoleAssignmentName, options, optionalCallback); + } + } + + /** + * Get the role assignments on the Billing Profile + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, billingProfileName, 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 role assignments on the Billing Profile + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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 {BillingRoleAssignmentListResult} - 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 BillingRoleAssignmentListResult} for more + * information. + * + * {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(billingAccountName, billingProfileName, 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(billingAccountName, billingProfileName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, billingProfileName, options, optionalCallback); + } + } + + /** + * The operation to add a role assignment to a billing profile. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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. + */ + addWithHttpOperationResponse(billingAccountName, billingProfileName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._add(billingAccountName, billingProfileName, 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 add a role assignment to a billing profile. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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 {BillingRoleAssignmentListResult} - 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 BillingRoleAssignmentListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + add(billingAccountName, billingProfileName, 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._add(billingAccountName, billingProfileName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._add(billingAccountName, billingProfileName, options, optionalCallback); + } + } + +} + +module.exports = BillingProfileBillingRoleAssignment; diff --git a/lib/services/billingManagement/lib/operations/billingProfileBillingRoleDefinition.js b/lib/services/billingManagement/lib/operations/billingProfileBillingRoleDefinition.js new file mode 100644 index 0000000000..799136ea5a --- /dev/null +++ b/lib/services/billingManagement/lib/operations/billingProfileBillingRoleDefinition.js @@ -0,0 +1,499 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets the role definition for a role + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName Billing Profile Id. + * + * @param {string} billingRoleDefinitionName role definition 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 BillingRoleDefinition} for more information. + * + * {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(billingAccountName, billingProfileName, billingRoleDefinitionName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (billingProfileName === null || billingProfileName === undefined || typeof billingProfileName.valueOf() !== 'string') { + throw new Error('billingProfileName cannot be null or undefined and it must be of type string.'); + } + if (billingRoleDefinitionName === null || billingRoleDefinitionName === undefined || typeof billingRoleDefinitionName.valueOf() !== 'string') { + throw new Error('billingRoleDefinitionName 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/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Billing/billingRoleDefinitions/{billingRoleDefinitionName}'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{billingProfileName}', encodeURIComponent(billingProfileName)); + requestUrl = requestUrl.replace('{billingRoleDefinitionName}', encodeURIComponent(billingRoleDefinitionName)); + 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['BillingRoleDefinition']().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 role definition for a Billing Profile + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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 BillingRoleDefinitionListResult} for more + * information. + * + * {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(billingAccountName, billingProfileName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (billingProfileName === null || billingProfileName === undefined || typeof billingProfileName.valueOf() !== 'string') { + throw new Error('billingProfileName 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/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Billing/billingRoleDefinitions'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{billingProfileName}', encodeURIComponent(billingProfileName)); + 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['BillingRoleDefinitionListResult']().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 BillingProfileBillingRoleDefinition. */ +class BillingProfileBillingRoleDefinition { + /** + * Create a BillingProfileBillingRoleDefinition. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._list = _list; + } + + /** + * Gets the role definition for a role + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName Billing Profile Id. + * + * @param {string} billingRoleDefinitionName role definition 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(billingAccountName, billingProfileName, billingRoleDefinitionName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountName, billingProfileName, billingRoleDefinitionName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the role definition for a role + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName Billing Profile Id. + * + * @param {string} billingRoleDefinitionName role definition 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 {BillingRoleDefinition} - 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 BillingRoleDefinition} for more information. + * + * {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(billingAccountName, billingProfileName, billingRoleDefinitionName, 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(billingAccountName, billingProfileName, billingRoleDefinitionName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountName, billingProfileName, billingRoleDefinitionName, options, optionalCallback); + } + } + + /** + * Lists the role definition for a Billing Profile + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, billingProfileName, 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 role definition for a Billing Profile + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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 {BillingRoleDefinitionListResult} - 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 BillingRoleDefinitionListResult} for more + * information. + * + * {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(billingAccountName, billingProfileName, 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(billingAccountName, billingProfileName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, billingProfileName, options, optionalCallback); + } + } + +} + +module.exports = BillingProfileBillingRoleDefinition; diff --git a/lib/services/billingManagement/lib/operations/billingProfiles.js b/lib/services/billingManagement/lib/operations/billingProfiles.js new file mode 100644 index 0000000000..62ffb5e7b6 --- /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} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (billingProfileName === null || billingProfileName === undefined || typeof billingProfileName.valueOf() !== 'string') { + throw new Error('billingProfileName 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/{billingAccountName}/billingProfiles/{billingProfileName}'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{billingProfileName}', encodeURIComponent(billingProfileName)); + 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} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, 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(billingAccountName, billingProfileName, 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} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (billingProfileName === null || billingProfileName === undefined || typeof billingProfileName.valueOf() !== 'string') { + throw new Error('billingProfileName 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/{billingAccountName}/billingProfiles/{billingProfileName}'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{billingProfileName}', encodeURIComponent(billingProfileName)); + 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} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountName, billingProfileName, 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} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, 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(billingAccountName, billingProfileName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountName, billingProfileName, options, optionalCallback); + } + } + + /** + * The operation to update a billing profile. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(billingAccountName, billingProfileName, 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} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, 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(billingAccountName, billingProfileName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(billingAccountName, billingProfileName, parameters, options, optionalCallback); + } + } + + /** + * The operation to update a billing profile. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginUpdate(billingAccountName, billingProfileName, 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} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, 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(billingAccountName, billingProfileName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginUpdate(billingAccountName, billingProfileName, parameters, options, optionalCallback); + } + } + +} + +module.exports = BillingProfiles; diff --git a/lib/services/billingManagement/lib/operations/billingProfilesByBillingAccountName.js b/lib/services/billingManagement/lib/operations/billingProfilesByBillingAccountName.js new file mode 100644 index 0000000000..27e0babf40 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/billingProfilesByBillingAccountName.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} billingAccountName 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(billingAccountName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName 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/{billingAccountName}/billingProfiles'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + 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 BillingProfilesByBillingAccountName. */ +class BillingProfilesByBillingAccountName { + /** + * Create a BillingProfilesByBillingAccountName. + * @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} billingAccountName 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(billingAccountName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, 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} billingAccountName 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(billingAccountName, 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(billingAccountName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, options, optionalCallback); + } + } + +} + +module.exports = BillingProfilesByBillingAccountName; 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..9822f2fc08 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/billingSubscription.js @@ -0,0 +1,727 @@ +/* + * 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} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingSubscriptionName 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(billingAccountName, invoiceSectionName, billingSubscriptionName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionName === null || invoiceSectionName === undefined || typeof invoiceSectionName.valueOf() !== 'string') { + throw new Error('invoiceSectionName cannot be null or undefined and it must be of type string.'); + } + if (billingSubscriptionName === null || billingSubscriptionName === undefined || typeof billingSubscriptionName.valueOf() !== 'string') { + throw new Error('billingSubscriptionName 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/{billingAccountName}/invoiceSections/{invoiceSectionName}/billingSubscriptions/{billingSubscriptionName}'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{invoiceSectionName}', encodeURIComponent(invoiceSectionName)); + requestUrl = requestUrl.replace('{billingSubscriptionName}', encodeURIComponent(billingSubscriptionName)); + 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} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingSubscriptionName Billing Subscription Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionName] The destination + * invoiceSectionName. + * + * @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(billingAccountName, invoiceSectionName, billingSubscriptionName, 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(billingAccountName, invoiceSectionName, billingSubscriptionName, 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} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingSubscriptionName Billing Subscription Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionName] The destination + * invoiceSectionName. + * + * @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(billingAccountName, invoiceSectionName, billingSubscriptionName, 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 destinationInvoiceSectionName = (options && options.destinationInvoiceSectionName !== undefined) ? options.destinationInvoiceSectionName : undefined; + // Validate + try { + if (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionName === null || invoiceSectionName === undefined || typeof invoiceSectionName.valueOf() !== 'string') { + throw new Error('invoiceSectionName cannot be null or undefined and it must be of type string.'); + } + if (billingSubscriptionName === null || billingSubscriptionName === undefined || typeof billingSubscriptionName.valueOf() !== 'string') { + throw new Error('billingSubscriptionName cannot be null or undefined and it must be of type string.'); + } + if (destinationInvoiceSectionName !== null && destinationInvoiceSectionName !== undefined && typeof destinationInvoiceSectionName.valueOf() !== 'string') { + throw new Error('destinationInvoiceSectionName 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 (destinationInvoiceSectionName !== null && destinationInvoiceSectionName !== undefined) { + parameters = new client.models['TransferBillingSubscriptionRequestProperties'](); + parameters.destinationInvoiceSectionName = destinationInvoiceSectionName; + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/billingSubscriptions/{billingSubscriptionName}/transfer'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{invoiceSectionName}', encodeURIComponent(invoiceSectionName)); + requestUrl = requestUrl.replace('{billingSubscriptionName}', encodeURIComponent(billingSubscriptionName)); + 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} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingSubscriptionName 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(billingAccountName, invoiceSectionName, billingSubscriptionName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountName, invoiceSectionName, billingSubscriptionName, 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} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingSubscriptionName 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(billingAccountName, invoiceSectionName, billingSubscriptionName, 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(billingAccountName, invoiceSectionName, billingSubscriptionName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountName, invoiceSectionName, billingSubscriptionName, options, optionalCallback); + } + } + + /** + * Transfers the GTM subscription from one invoice section to another within a + * billing account. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingSubscriptionName Billing Subscription Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionName] The destination + * invoiceSectionName. + * + * @param {object} [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(billingAccountName, invoiceSectionName, billingSubscriptionName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._transfer(billingAccountName, invoiceSectionName, billingSubscriptionName, 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} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingSubscriptionName Billing Subscription Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionName] The destination + * invoiceSectionName. + * + * @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(billingAccountName, invoiceSectionName, billingSubscriptionName, 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(billingAccountName, invoiceSectionName, billingSubscriptionName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._transfer(billingAccountName, invoiceSectionName, billingSubscriptionName, options, optionalCallback); + } + } + + /** + * Transfers the GTM subscription from one invoice section to another within a + * billing account. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingSubscriptionName Billing Subscription Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionName] The destination + * invoiceSectionName. + * + * @param {object} [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(billingAccountName, invoiceSectionName, billingSubscriptionName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginTransfer(billingAccountName, invoiceSectionName, billingSubscriptionName, 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} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingSubscriptionName Billing Subscription Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionName] The destination + * invoiceSectionName. + * + * @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(billingAccountName, invoiceSectionName, billingSubscriptionName, 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(billingAccountName, invoiceSectionName, billingSubscriptionName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginTransfer(billingAccountName, invoiceSectionName, billingSubscriptionName, 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..1c70e4ee97 --- /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 billingProfileName. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (billingProfileName === null || billingProfileName === undefined || typeof billingProfileName.valueOf() !== 'string') { + throw new Error('billingProfileName 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/{billingAccountName}/billingProfile/{billingProfileName}/billingSubscriptions'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{billingProfileName}', encodeURIComponent(billingProfileName)); + 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 billingProfileName. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, billingProfileName, 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 billingProfileName. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, 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(billingAccountName, billingProfileName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, billingProfileName, 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..6dc4d8da41 --- /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 invoiceSectionName. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName, invoiceSectionName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionName === null || invoiceSectionName === undefined || typeof invoiceSectionName.valueOf() !== 'string') { + throw new Error('invoiceSectionName 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/{billingAccountName}/invoiceSections/{invoiceSectionName}/billingSubscriptions'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{invoiceSectionName}', encodeURIComponent(invoiceSectionName)); + 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 invoiceSectionName. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName, invoiceSectionName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, invoiceSectionName, 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 invoiceSectionName. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName, invoiceSectionName, 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(billingAccountName, invoiceSectionName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, invoiceSectionName, 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..b87794b79e --- /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} billingAccountName billing Account Id. + * + * @param {string} departmentName 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(billingAccountName, departmentName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (departmentName === null || departmentName === undefined || typeof departmentName.valueOf() !== 'string') { + throw new Error('departmentName 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/{billingAccountName}/departments/{departmentName}'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{departmentName}', encodeURIComponent(departmentName)); + 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} billingAccountName billing Account Id. + * + * @param {string} departmentName 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(billingAccountName, departmentName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountName, departmentName, 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} billingAccountName billing Account Id. + * + * @param {string} departmentName 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(billingAccountName, departmentName, 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(billingAccountName, departmentName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountName, departmentName, options, optionalCallback); + } + } + +} + +module.exports = Departments; diff --git a/lib/services/billingManagement/lib/operations/departmentsByBillingAccountName.js b/lib/services/billingManagement/lib/operations/departmentsByBillingAccountName.js new file mode 100644 index 0000000000..160fe03f35 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/departmentsByBillingAccountName.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} billingAccountName 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(billingAccountName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName 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/{billingAccountName}/departments'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + 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 DepartmentsByBillingAccountName. */ +class DepartmentsByBillingAccountName { + /** + * Create a DepartmentsByBillingAccountName. + * @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} billingAccountName 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(billingAccountName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, 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} billingAccountName 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(billingAccountName, 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(billingAccountName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, options, optionalCallback); + } + } + +} + +module.exports = DepartmentsByBillingAccountName; diff --git a/lib/services/billingManagement/lib/operations/enrollmentAccounts.js b/lib/services/billingManagement/lib/operations/enrollmentAccounts.js index d616f11d45..9a538d27d3 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} billingAccountName 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} enrollmentAccountName 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(billingAccountName, enrollmentAccountName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (enrollmentAccountName === null || enrollmentAccountName === undefined || typeof enrollmentAccountName.valueOf() !== 'string') { + throw new Error('enrollmentAccountName 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/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{enrollmentAccountName}', encodeURIComponent(enrollmentAccountName)); 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} billingAccountName 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} enrollmentAccountName 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(billingAccountName, enrollmentAccountName, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._get(name, options, (err, result, request, response) => { + self._getByEnrollmentAccountAccountId(billingAccountName, enrollmentAccountName, 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} billingAccountName billing Account Id. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} enrollmentAccountName 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(billingAccountName, enrollmentAccountName, 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(billingAccountName, enrollmentAccountName, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._listNext(nextPageLink, options, optionalCallback); + return self._getByEnrollmentAccountAccountId(billingAccountName, enrollmentAccountName, options, optionalCallback); } } diff --git a/lib/services/billingManagement/lib/operations/enrollmentAccountsByBillingAccountName.js b/lib/services/billingManagement/lib/operations/enrollmentAccountsByBillingAccountName.js new file mode 100644 index 0000000000..6a9b44751f --- /dev/null +++ b/lib/services/billingManagement/lib/operations/enrollmentAccountsByBillingAccountName.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} billingAccountName 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(billingAccountName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName 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/{billingAccountName}/enrollmentAccounts'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + 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 EnrollmentAccountsByBillingAccountName. */ +class EnrollmentAccountsByBillingAccountName { + /** + * Create a EnrollmentAccountsByBillingAccountName. + * @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} billingAccountName 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(billingAccountName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, 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} billingAccountName 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(billingAccountName, 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(billingAccountName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, options, optionalCallback); + } + } + +} + +module.exports = EnrollmentAccountsByBillingAccountName; diff --git a/lib/services/billingManagement/lib/operations/index.d.ts b/lib/services/billingManagement/lib/operations/index.d.ts index 3131b77c2e..e2215021b4 100644 --- a/lib/services/billingManagement/lib/operations/index.d.ts +++ b/lib/services/billingManagement/lib/operations/index.d.ts @@ -14,34 +14,40 @@ import * as models from '../models'; /** * @class - * EnrollmentAccounts + * BillingAccounts * __NOTE__: An instance of this class is automatically created for an * instance of the BillingManagementClient. */ -export interface EnrollmentAccounts { +export interface BillingAccounts { /** - * Lists the enrollment accounts the caller has access to. + * 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. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listWithHttpOperationResponse(options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Lists the enrollment accounts the caller has access to. + * 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 * @@ -52,7 +58,7 @@ export interface EnrollmentAccounts { * * {Promise} A promise is returned. * - * @resolve {EnrollmentAccountListResult} - The deserialized result object. + * @resolve {BillingAccountListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -60,44 +66,50 @@ 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 + * {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?: { customHeaders? : { [headerName: string]: string; } }): Promise; - list(callback: ServiceCallback): void; - list(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + list(options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { expand? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Gets a enrollment account by name. + * Get the billing account by id. * - * @param {string} name Enrollment Account name. + * @param {string} billingAccountName 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. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - getWithHttpOperationResponse(name: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + getWithHttpOperationResponse(billingAccountName: string, options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets a enrollment account by name. + * Get the billing account by id. * - * @param {string} name Enrollment Account name. + * @param {string} billingAccountName 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 * @@ -108,7 +120,7 @@ export interface EnrollmentAccounts { * * {Promise} A promise is returned. * - * @resolve {EnrollmentAccount} - The deserialized result object. + * @resolve {BillingAccount} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -116,45 +128,54 @@ 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. + * {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(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; + get(billingAccountName: string, options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountName: string, callback: ServiceCallback): void; + get(billingAccountName: 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 the enrollment accounts the caller has access to. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * 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. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listWithHttpOperationResponse(options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Lists the enrollment accounts the caller has access to. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * 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 * @@ -165,7 +186,7 @@ export interface EnrollmentAccounts { * * {Promise} A promise is returned. * - * @resolve {EnrollmentAccountListResult} - The deserialized result object. + * @resolve {BillingAccountListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -173,78 +194,58 @@ 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 + * {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. */ - 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; + 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 - * BillingPeriods + * AvailableBalanceByBillingProfile * __NOTE__: An instance of this class is automatically created for an * instance of the BillingManagementClient. */ -export interface BillingPeriods { +export interface AvailableBalanceByBillingProfile { /** - * 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. - * - * @param {object} [options] Optional Parameters. + * The latest available credit balance for a given billingAccountName and + * billingProfileName. * - * @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} billingAccountName billing Account 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 {string} billingProfileName Billing Profile Id. * - * @param {number} [options.top] May be used to limit the number of results to - * the most recent N billing periods. + * @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. + * @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>; + getWithHttpOperationResponse(billingAccountName: string, billingProfileName: string, options?: { 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 latest available credit balance for a given billingAccountName and + * billingProfileName. * - * @param {object} [options] Optional Parameters. - * - * @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} billingAccountName billing Account 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 {string} billingProfileName Billing Profile Id. * - * @param {number} [options.top] May be used to limit the number of results to - * the most recent N billing periods. + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -256,7 +257,7 @@ export interface BillingPeriods { * * {Promise} A promise is returned. * - * @resolve {BillingPeriodsListResult} - The deserialized result object. + * @resolve {AvailableBalance} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -264,25 +265,33 @@ 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. + * {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. */ - 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; + get(billingAccountName: string, billingProfileName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountName: string, billingProfileName: string, callback: ServiceCallback): void; + get(billingAccountName: string, billingProfileName: 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 { /** - * 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. + * Lists the Payment Methods by billing profile Id. + * + * @param {string} billingAccountName billing Account Id. * - * @param {string} billingPeriodName The name of a BillingPeriod resource. + * @param {string} billingProfileName Billing Profile Id. * * @param {object} [options] Optional Parameters. * @@ -291,18 +300,18 @@ 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>; + listWithHttpOperationResponse(billingAccountName: string, billingProfileName: 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. + * Lists the Payment Methods by billing profile Id. * - * @param {string} billingPeriodName The name of a BillingPeriod resource. + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName Billing Profile Id. * * @param {object} [options] Optional Parameters. * @@ -316,7 +325,7 @@ export interface BillingPeriods { * * {Promise} A promise is returned. * - * @resolve {BillingPeriod} - The deserialized result object. + * @resolve {PaymentMethodsListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -324,23 +333,21 @@ 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. + * {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. */ - 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; + list(billingAccountName: string, billingProfileName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, billingProfileName: string, callback: ServiceCallback): void; + list(billingAccountName: string, billingProfileName: 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. + * Lists the Payment Methods by billing profile Id. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -352,17 +359,14 @@ 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. */ - listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listNextWithHttpOperationResponse(nextPageLink: string, options?: { 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 the Payment Methods by billing profile Id. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -379,7 +383,7 @@ export interface BillingPeriods { * * {Promise} A promise is returned. * - * @resolve {BillingPeriodsListResult} - The deserialized result object. + * @resolve {PaymentMethodsListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -387,92 +391,129 @@ 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 + * {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; + 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 - * Invoices + * BillingProfilesByBillingAccountName * __NOTE__: An instance of this class is automatically created for an * instance of the BillingManagementClient. */ -export interface Invoices { +export interface BillingProfilesByBillingAccountName { /** - * 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 all billing profiles for a user which that user has access to. + * + * @param {string} billingAccountName billing Account Id. * * @param {object} [options] Optional Parameters. * - * @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} [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(billingAccountName: string, options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all billing profiles for a user which that user has access to. * - * @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} billingAccountName billing Account 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 invoices. + * @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 + * @param {ServiceCallback} [optionalCallback] - The optional callback. * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. * - * @reject {Error|ServiceError} - The error object. + * {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. */ - listWithHttpOperationResponse(options?: { expand? : string, filter? : string, skiptoken? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + list(billingAccountName: string, options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, callback: ServiceCallback): void; + list(billingAccountName: 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 { + /** - * 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. + * Get the billing profile by id. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName Billing Profile Id. * * @param {object} [options] Optional Parameters. * - * @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} [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(billingAccountName: string, billingProfileName: string, options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the billing profile by id. + * + * @param {string} billingAccountName billing Account Id. * - * @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} billingProfileName Billing Profile 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 invoices. + * @param {string} [options.expand] May be used to expand the invoiceSections. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -484,7 +525,7 @@ export interface Invoices { * * {Promise} A promise is returned. * - * @resolve {InvoicesListResult} - The deserialized result object. + * @resolve {BillingProfile} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -492,26 +533,59 @@ 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. + * {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. */ - 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; + get(billingAccountName: string, billingProfileName: string, options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountName: string, billingProfileName: string, callback: ServiceCallback): void; + get(billingAccountName: string, billingProfileName: string, options: { expand? : 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. + * The operation to update a billing profile. * - * @param {string} invoiceName The name of an invoice resource. + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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. * @@ -520,20 +594,53 @@ 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>; + updateWithHttpOperationResponse(billingAccountName: string, billingProfileName: string, parameters: models.BillingProfile, 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. + * The operation to update a billing profile. * - * @param {string} invoiceName The name of an invoice resource. + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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. * @@ -547,7 +654,7 @@ export interface Invoices { * * {Promise} A promise is returned. * - * @resolve {Invoice} - The deserialized result object. + * @resolve {BillingProfile} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -555,24 +662,59 @@ 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. + * {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(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; + update(billingAccountName: string, billingProfileName: string, parameters: models.BillingProfile, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(billingAccountName: string, billingProfileName: string, parameters: models.BillingProfile, callback: ServiceCallback): void; + update(billingAccountName: string, billingProfileName: string, parameters: models.BillingProfile, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * 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 operation to update a billing profile. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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. * @@ -581,18 +723,53 @@ 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>; + beginUpdateWithHttpOperationResponse(billingAccountName: string, billingProfileName: string, parameters: models.BillingProfile, 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 operation to update a billing profile. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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. * @@ -606,7 +783,7 @@ export interface Invoices { * * {Promise} A promise is returned. * - * @resolve {Invoice} - The deserialized result object. + * @resolve {BillingProfile} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -614,55 +791,56 @@ 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. + * {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. */ - getLatest(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - getLatest(callback: ServiceCallback): void; - getLatest(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + beginUpdate(billingAccountName: string, billingProfileName: string, parameters: models.BillingProfile, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginUpdate(billingAccountName: string, billingProfileName: string, parameters: models.BillingProfile, callback: ServiceCallback): void; + beginUpdate(billingAccountName: string, billingProfileName: string, parameters: models.BillingProfile, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * InvoiceSectionsByBillingAccountName + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface InvoiceSectionsByBillingAccountName { /** - * 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 all invoice sections for a user which he has access to. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} billingAccountName 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. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listWithHttpOperationResponse(billingAccountName: string, options?: { expand? : 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 all invoice sections for a user which he has access to. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} billingAccountName 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 * @@ -673,7 +851,7 @@ export interface Invoices { * * {Promise} A promise is returned. * - * @resolve {InvoicesListResult} - The deserialized result object. + * @resolve {InvoiceSectionListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -681,29 +859,40 @@ 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. + * {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. */ - 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; + list(billingAccountName: string, options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, callback: ServiceCallback): void; + list(billingAccountName: string, options: { expand? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } /** * @class - * Operations + * InvoiceSections * __NOTE__: An instance of this class is automatically created for an * instance of the BillingManagementClient. */ -export interface Operations { +export interface InvoiceSections { /** - * Lists all of the available billing REST API operations. + * The operation to create a InvoiceSection. + * + * @param {string} billingAccountName 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. * @@ -712,14 +901,24 @@ export interface Operations { * * @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>; + createWithHttpOperationResponse(billingAccountName: string, parameters: models.InvoiceSectionProperties, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Lists all of the available billing REST API operations. + * The operation to create a InvoiceSection. + * + * @param {string} billingAccountName 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. * @@ -733,7 +932,7 @@ export interface Operations { * * {Promise} A promise is returned. * - * @resolve {OperationListResult} - The deserialized result object. + * @resolve {InvoiceSection} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -741,45 +940,51 @@ export interface Operations { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {OperationListResult} [result] - The deserialized result object if an error did not occur. - * See {@link OperationListResult} for more information. + * {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. */ - list(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - list(callback: ServiceCallback): void; - list(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + create(billingAccountName: string, parameters: models.InvoiceSectionProperties, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + create(billingAccountName: string, parameters: models.InvoiceSectionProperties, callback: ServiceCallback): void; + create(billingAccountName: string, parameters: models.InvoiceSectionProperties, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Lists all of the available billing REST API operations. + * Get the InvoiceSection by id. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + getWithHttpOperationResponse(billingAccountName: string, invoiceSectionName: string, options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Lists all of the available billing REST API operations. + * Get the InvoiceSection by id. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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 * @@ -790,7 +995,7 @@ export interface Operations { * * {Promise} A promise is returned. * - * @resolve {OperationListResult} - The deserialized result object. + * @resolve {InvoiceSection} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -798,14 +1003,4237 @@ export interface Operations { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {OperationListResult} [result] - The deserialized result object if an error did not occur. - * See {@link OperationListResult} for more information. + * {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. */ - 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(billingAccountName: string, invoiceSectionName: string, options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountName: string, invoiceSectionName: string, callback: ServiceCallback): void; + get(billingAccountName: string, invoiceSectionName: string, options: { expand? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to update a InvoiceSection. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName: string, invoiceSectionName: string, parameters: models.InvoiceSection, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to update a InvoiceSection. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName: string, invoiceSectionName: string, parameters: models.InvoiceSection, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(billingAccountName: string, invoiceSectionName: string, parameters: models.InvoiceSection, callback: ServiceCallback): void; + update(billingAccountName: string, invoiceSectionName: string, parameters: models.InvoiceSection, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to create a InvoiceSection. + * + * @param {string} billingAccountName 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(billingAccountName: string, parameters: models.InvoiceSectionProperties, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to create a InvoiceSection. + * + * @param {string} billingAccountName 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(billingAccountName: string, parameters: models.InvoiceSectionProperties, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginCreate(billingAccountName: string, parameters: models.InvoiceSectionProperties, callback: ServiceCallback): void; + beginCreate(billingAccountName: string, parameters: models.InvoiceSectionProperties, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to update a InvoiceSection. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName: string, invoiceSectionName: string, parameters: models.InvoiceSection, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to update a InvoiceSection. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName: string, invoiceSectionName: string, parameters: models.InvoiceSection, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginUpdate(billingAccountName: string, invoiceSectionName: string, parameters: models.InvoiceSection, callback: ServiceCallback): void; + beginUpdate(billingAccountName: string, invoiceSectionName: 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} billingAccountName 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(billingAccountName: string, options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all invoiceSections with create subscription permission for a user. + * + * @param {string} billingAccountName 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(billingAccountName: string, options?: { expand? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, callback: ServiceCallback): void; + list(billingAccountName: string, options: { expand? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * DepartmentsByBillingAccountName + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface DepartmentsByBillingAccountName { + + + /** + * Lists all departments for a user which he has access to. + * + * @param {string} billingAccountName 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(billingAccountName: string, options?: { expand? : string, filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all departments for a user which he has access to. + * + * @param {string} billingAccountName 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(billingAccountName: string, options?: { expand? : string, filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, callback: ServiceCallback): void; + list(billingAccountName: 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} billingAccountName billing Account Id. + * + * @param {string} departmentName 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(billingAccountName: string, departmentName: string, options?: { expand? : string, filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the department by id. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} departmentName 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(billingAccountName: string, departmentName: string, options?: { expand? : string, filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountName: string, departmentName: string, callback: ServiceCallback): void; + get(billingAccountName: string, departmentName: string, options: { expand? : string, filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * EnrollmentAccountsByBillingAccountName + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface EnrollmentAccountsByBillingAccountName { + + + /** + * Lists all Enrollment Accounts for a user which he has access to. + * + * @param {string} billingAccountName 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(billingAccountName: 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} billingAccountName 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(billingAccountName: string, options?: { expand? : string, filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, callback: ServiceCallback): void; + list(billingAccountName: 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 { + + + /** + * Get the enrollment account by id. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} enrollmentAccountName 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(billingAccountName: string, enrollmentAccountName: string, options?: { expand? : string, filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the enrollment account by id. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} enrollmentAccountName 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(billingAccountName: string, enrollmentAccountName: string, options?: { expand? : string, filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + getByEnrollmentAccountAccountId(billingAccountName: string, enrollmentAccountName: string, callback: ServiceCallback): void; + getByEnrollmentAccountAccountId(billingAccountName: string, enrollmentAccountName: 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} billingAccountName 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(billingAccountName: string, periodStartDate: string, periodEndDate: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * List of invoices for a billing account. + * + * @param {string} billingAccountName 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(billingAccountName: string, periodStartDate: string, periodEndDate: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, periodStartDate: string, periodEndDate: string, callback: ServiceCallback): void; + list(billingAccountName: 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} billingAccountName 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(billingAccountName: string, invoiceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get pricesheet data for invoice id (invoiceName). + * + * @param {string} billingAccountName 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(billingAccountName: string, invoiceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + download(billingAccountName: string, invoiceName: string, callback: ServiceCallback): void; + download(billingAccountName: string, invoiceName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get pricesheet data for invoice id (invoiceName). + * + * @param {string} billingAccountName 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(billingAccountName: string, invoiceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get pricesheet data for invoice id (invoiceName). + * + * @param {string} billingAccountName 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(billingAccountName: string, invoiceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginDownload(billingAccountName: string, invoiceName: string, callback: ServiceCallback): void; + beginDownload(billingAccountName: 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} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName: string, billingProfileName: string, periodStartDate: string, periodEndDate: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * List of invoices for a billing profile. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName: string, billingProfileName: string, periodStartDate: string, periodEndDate: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, billingProfileName: string, periodStartDate: string, periodEndDate: string, callback: ServiceCallback): void; + list(billingAccountName: string, billingProfileName: 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} billingAccountName billing Account Id. + * + * @param {string} billingProfileName Billing Profile Id. + * + * @param {string} invoiceName Invoice 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(billingAccountName: string, billingProfileName: string, invoiceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the invoice by id. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName Billing Profile Id. + * + * @param {string} invoiceName Invoice 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(billingAccountName: string, billingProfileName: string, invoiceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountName: string, billingProfileName: string, invoiceName: string, callback: ServiceCallback): void; + get(billingAccountName: string, billingProfileName: 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 billingAccountName. + * + * @param {string} billingAccountName 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(billingAccountName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists billing subscriptions by billingAccountName. + * + * @param {string} billingAccountName 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(billingAccountName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, callback: ServiceCallback): void; + list(billingAccountName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists billing subscriptions by billingAccountName. + * + * @param {string} nextPageLink The NextLink from 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 billingAccountName. + * + * @param {string} nextPageLink The NextLink from 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 billingProfileName. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName: string, billingProfileName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists billing subscriptions by billingProfileName. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName: string, billingProfileName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, billingProfileName: string, callback: ServiceCallback): void; + list(billingAccountName: string, billingProfileName: 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 invoiceSectionName. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName: string, invoiceSectionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists billing subscription by invoiceSectionName. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName: string, invoiceSectionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, invoiceSectionName: string, callback: ServiceCallback): void; + list(billingAccountName: string, invoiceSectionName: 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 { + + + /** + * Get a single billing subscription by name. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingSubscriptionName 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|ServiceError} - The error object. + */ + getWithHttpOperationResponse(billingAccountName: string, invoiceSectionName: string, billingSubscriptionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get a single billing subscription by name. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingSubscriptionName Billing Subscription 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 {BillingSubscriptionSummary} - 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. + * + * {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. + */ + get(billingAccountName: string, invoiceSectionName: string, billingSubscriptionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountName: string, invoiceSectionName: string, billingSubscriptionName: string, callback: ServiceCallback): void; + get(billingAccountName: string, invoiceSectionName: string, billingSubscriptionName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Transfers the GTM subscription from one invoice section to another within a + * billing account. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingSubscriptionName Billing Subscription Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionName] The destination + * invoiceSectionName. + * + * @param {object} [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. + */ + transferWithHttpOperationResponse(billingAccountName: string, invoiceSectionName: string, billingSubscriptionName: string, options?: { destinationInvoiceSectionName? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Transfers the GTM subscription from one invoice section to another within a + * billing account. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingSubscriptionName Billing Subscription Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionName] The destination + * invoiceSectionName. + * + * @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. + */ + transfer(billingAccountName: string, invoiceSectionName: string, billingSubscriptionName: string, options?: { destinationInvoiceSectionName? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + transfer(billingAccountName: string, invoiceSectionName: string, billingSubscriptionName: string, callback: ServiceCallback): void; + transfer(billingAccountName: string, invoiceSectionName: string, billingSubscriptionName: string, options: { destinationInvoiceSectionName? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Transfers the GTM subscription from one invoice section to another within a + * billing account. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingSubscriptionName Billing Subscription Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionName] The destination + * invoiceSectionName. + * + * @param {object} [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(billingAccountName: string, invoiceSectionName: string, billingSubscriptionName: string, options?: { destinationInvoiceSectionName? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Transfers the GTM subscription from one invoice section to another within a + * billing account. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingSubscriptionName Billing Subscription Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionName] The destination + * invoiceSectionName. + * + * @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(billingAccountName: string, invoiceSectionName: string, billingSubscriptionName: string, options?: { destinationInvoiceSectionName? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + beginTransfer(billingAccountName: string, invoiceSectionName: string, billingSubscriptionName: string, callback: ServiceCallback): void; + beginTransfer(billingAccountName: string, invoiceSectionName: string, billingSubscriptionName: string, options: { destinationInvoiceSectionName? : 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 billingAccountName. + * + * @param {string} billingAccountName 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(billingAccountName: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists products by billingAccountName. + * + * @param {string} billingAccountName 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. + */ + list(billingAccountName: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, callback: ServiceCallback): void; + list(billingAccountName: string, options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists products by billingAccountName. + * + * @param {string} nextPageLink The NextLink from 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 products by billingAccountName. + * + * @param {string} nextPageLink The NextLink from 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 {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. + */ + 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 + * ProductsByInvoiceSection + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface ProductsByInvoiceSection { + + + /** + * Lists products by invoiceSectionName. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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|ServiceError} - The error object. + */ + listWithHttpOperationResponse(billingAccountName: string, invoiceSectionName: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists products by invoiceSectionName. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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 {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. + */ + list(billingAccountName: string, invoiceSectionName: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, invoiceSectionName: string, callback: ServiceCallback): void; + list(billingAccountName: string, invoiceSectionName: 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 { + + + /** + * Get a single product by name. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} productName Invoice 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(billingAccountName: string, invoiceSectionName: string, productName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get a single product by name. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} productName Invoice 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 {ProductSummary} - 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. + * + * {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(billingAccountName: string, invoiceSectionName: string, productName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountName: string, invoiceSectionName: string, productName: string, callback: ServiceCallback): void; + get(billingAccountName: string, invoiceSectionName: string, productName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to transfer a Product to another InvoiceSection. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} productName Invoice Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionName] 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|ServiceError} - The error object. + */ + transferWithHttpOperationResponse(billingAccountName: string, invoiceSectionName: string, productName: string, options?: { destinationInvoiceSectionName? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to transfer a Product to another InvoiceSection. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} productName Invoice Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionName] Destination invoice + * section id. + * + * @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 {ProductSummary} - 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. + * + * {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. + */ + transfer(billingAccountName: string, invoiceSectionName: string, productName: string, options?: { destinationInvoiceSectionName? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + transfer(billingAccountName: string, invoiceSectionName: string, productName: string, callback: ServiceCallback): void; + transfer(billingAccountName: string, invoiceSectionName: string, productName: string, options: { destinationInvoiceSectionName? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * TransactionsByBillingAccount + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface TransactionsByBillingAccount { + + + /** + * Lists the transactions by billingAccountName for given start and end date. + * + * @param {string} billingAccountName 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|ServiceError} - The error object. + */ + listWithHttpOperationResponse(billingAccountName: string, startDate: string, endDate: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the transactions by billingAccountName for given start and end date. + * + * @param {string} billingAccountName 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 {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. + */ + list(billingAccountName: string, startDate: string, endDate: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, startDate: string, endDate: string, callback: ServiceCallback): void; + list(billingAccountName: string, startDate: string, endDate: string, options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the transactions by billingAccountName 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|ServiceError} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the transactions by billingAccountName 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 {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. + */ + 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 { + + + /** + * The policy for a given billingAccountName and billingProfileName. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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. + */ + getByBillingProfileWithHttpOperationResponse(billingAccountName: string, billingProfileName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The policy for a given billingAccountName and billingProfileName. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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 {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. + */ + getByBillingProfile(billingAccountName: string, billingProfileName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getByBillingProfile(billingAccountName: string, billingProfileName: string, callback: ServiceCallback): void; + getByBillingProfile(billingAccountName: string, billingProfileName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to update a policy. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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|ServiceError} - The error object. + */ + updateWithHttpOperationResponse(billingAccountName: string, billingProfileName: string, parameters: models.Policy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to update a policy. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName: string, billingProfileName: string, parameters: models.Policy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(billingAccountName: string, billingProfileName: string, parameters: models.Policy, callback: ServiceCallback): void; + update(billingAccountName: string, billingProfileName: 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. + * + * @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 {BillingProperty} - 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. + * + * {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. + */ + get(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(callback: ServiceCallback): void; + get(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * Transfer + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface Transfer { + + + /** + * Initiates the request to transfer the GTM or legacy subscriptions or RIs to + * GTM. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {object} body Initiate transfer parameters. + * + * @param {string} [body.billingProfileId] Target Usage context for devTest + * subscriptions. + * + * @param {string} [body.recipientEmailId] Email Id of recipient for transfer. + * + * @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. + */ + initiateWithHttpOperationResponse(billingAccountName: string, invoiceSectionName: string, body: models.InitiateTransferRequest, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Initiates the request to transfer the GTM or legacy subscriptions or RIs to + * GTM. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {object} body Initiate transfer parameters. + * + * @param {string} [body.billingProfileId] Target Usage context for devTest + * subscriptions. + * + * @param {string} [body.recipientEmailId] Email Id of recipient for transfer. + * + * @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 {TransferDetails} - 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. + * + * {TransferDetails} [result] - The deserialized result object if an error did not occur. + * See {@link TransferDetails} 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. + */ + initiate(billingAccountName: string, invoiceSectionName: string, body: models.InitiateTransferRequest, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + initiate(billingAccountName: string, invoiceSectionName: string, body: models.InitiateTransferRequest, callback: ServiceCallback): void; + initiate(billingAccountName: string, invoiceSectionName: string, body: models.InitiateTransferRequest, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets the transfer details for given transfer Id. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} transferName Transfer Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(billingAccountName: string, invoiceSectionName: string, transferName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the transfer details for given transfer Id. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} transferName Transfer Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {TransferDetails} - 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. + * + * {TransferDetails} [result] - The deserialized result object if an error did not occur. + * See {@link TransferDetails} 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(billingAccountName: string, invoiceSectionName: string, transferName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountName: string, invoiceSectionName: string, transferName: string, callback: ServiceCallback): void; + get(billingAccountName: string, invoiceSectionName: string, transferName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Cancels the transfer for given transfer Id. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} transferName Transfer Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + cancelWithHttpOperationResponse(billingAccountName: string, invoiceSectionName: string, transferName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Cancels the transfer for given transfer Id. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} transferName Transfer Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {TransferDetails} - 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. + * + * {TransferDetails} [result] - The deserialized result object if an error did not occur. + * See {@link TransferDetails} 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. + */ + cancel(billingAccountName: string, invoiceSectionName: string, transferName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + cancel(billingAccountName: string, invoiceSectionName: string, transferName: string, callback: ServiceCallback): void; + cancel(billingAccountName: string, invoiceSectionName: string, transferName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * @summary Accepts the transfer with given transfer Id. + * + * @param {string} transferName Transfer Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.productDetails] Request parameters to accept + * transfer. + * + * @param {object} [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. + */ + acceptWithHttpOperationResponse(transferName: string, options?: { productDetails? : models.ProductDetails[], customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary Accepts the transfer with given transfer Id. + * + * @param {string} transferName Transfer Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.productDetails] Request parameters to accept + * transfer. + * + * @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 {RecipientTransferDetails} - 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. + * + * {RecipientTransferDetails} [result] - The deserialized result object if an error did not occur. + * See {@link RecipientTransferDetails} 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. + */ + accept(transferName: string, options?: { productDetails? : models.ProductDetails[], customHeaders? : { [headerName: string]: string; } }): Promise; + accept(transferName: string, callback: ServiceCallback): void; + accept(transferName: string, options: { productDetails? : models.ProductDetails[], customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * @summary Declines the transfer with given transfer Id. + * + * @param {string} transferName Transfer Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + declineWithHttpOperationResponse(transferName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary Declines the transfer with given transfer Id. + * + * @param {string} transferName Transfer Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {RecipientTransferDetails} - 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. + * + * {RecipientTransferDetails} [result] - The deserialized result object if an error did not occur. + * See {@link RecipientTransferDetails} 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. + */ + decline(transferName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + decline(transferName: string, callback: ServiceCallback): void; + decline(transferName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * Transfers + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface Transfers { + + + /** + * Lists all transfer's details initiated from given invoice section. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName: string, invoiceSectionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all transfer's details initiated from given invoice section. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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 {TransferDetailsListResult} - 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. + * + * {TransferDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link TransferDetailsListResult} 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(billingAccountName: string, invoiceSectionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, invoiceSectionName: string, callback: ServiceCallback): void; + list(billingAccountName: string, invoiceSectionName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all transfer's details initiated from given invoice section. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all transfer's details initiated from given invoice section. + * + * @param {string} nextPageLink The NextLink from 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 {TransferDetailsListResult} - 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. + * + * {TransferDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link TransferDetailsListResult} 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 + * RecipientTransfer + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface RecipientTransfer { + + + /** + * @summary Gets the transfer with given transfer Id. + * + * @param {string} transferName Transfer Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(transferName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary Gets the transfer with given transfer Id. + * + * @param {string} transferName Transfer Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {RecipientTransferDetails} - 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. + * + * {RecipientTransferDetails} [result] - The deserialized result object if an error did not occur. + * See {@link RecipientTransferDetails} 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(transferName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(transferName: string, callback: ServiceCallback): void; + get(transferName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * @summary Lists the transfers received by caller. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary Lists the transfers received by caller. + * + * @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 {RecipientTransferDetailsListResult} - 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. + * + * {RecipientTransferDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link RecipientTransferDetailsListResult} 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; + + + /** + * @summary Lists the transfers received by caller. + * + * @param {string} nextPageLink The NextLink from 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>; + + /** + * @summary Lists the transfers received by caller. + * + * @param {string} nextPageLink The NextLink from 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 {RecipientTransferDetailsListResult} - 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. + * + * {RecipientTransferDetailsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link RecipientTransferDetailsListResult} 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 + * Operations + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface Operations { + + + /** + * Lists all of the available billing REST API operations. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all of the available billing REST API operations. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {OperationListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {OperationListResult} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all of the available billing REST API operations. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all of the available billing REST API operations. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {OperationListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {OperationListResult} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextPageLink: string, callback: ServiceCallback): void; + listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * BillingAccountBillingPermissions + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface BillingAccountBillingPermissions { + + + /** + * Lists all billingPermissions for the caller has for a billing account. + * + * @param {string} billingAccountName 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(billingAccountName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all billingPermissions for the caller has for a billing account. + * + * @param {string} billingAccountName 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 {BillingPermissionsListResult} - 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. + * + * {BillingPermissionsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BillingPermissionsListResult} 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(billingAccountName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, callback: ServiceCallback): void; + list(billingAccountName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * InvoiceSectionsBillingPermissions + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface InvoiceSectionsBillingPermissions { + + + /** + * Lists all billingPermissions for the caller has for a Invoice Section. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName: string, invoiceSectionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all billingPermissions for the caller has for a Invoice Section. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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 {BillingPermissionsListResult} - 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. + * + * {BillingPermissionsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BillingPermissionsListResult} 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(billingAccountName: string, invoiceSectionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, invoiceSectionName: string, callback: ServiceCallback): void; + list(billingAccountName: string, invoiceSectionName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * BillingProfileBillingPermissions + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface BillingProfileBillingPermissions { + + + /** + * Lists all billingPermissions for the caller has for a billing account. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName: string, billingProfileName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all billingPermissions for the caller has for a billing account. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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 {BillingPermissionsListResult} - 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. + * + * {BillingPermissionsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BillingPermissionsListResult} 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(billingAccountName: string, billingProfileName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, billingProfileName: string, callback: ServiceCallback): void; + list(billingAccountName: string, billingProfileName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * BillingAccountBillingRoleDefinition + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface BillingAccountBillingRoleDefinition { + + + /** + * Gets the role definition for a role + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingRoleDefinitionName role definition 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(billingAccountName: string, billingRoleDefinitionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the role definition for a role + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingRoleDefinitionName role definition 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 {BillingRoleDefinition} - 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. + * + * {BillingRoleDefinition} [result] - The deserialized result object if an error did not occur. + * See {@link BillingRoleDefinition} 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(billingAccountName: string, billingRoleDefinitionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountName: string, billingRoleDefinitionName: string, callback: ServiceCallback): void; + get(billingAccountName: string, billingRoleDefinitionName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the role definition for a billing account + * + * @param {string} billingAccountName 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(billingAccountName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the role definition for a billing account + * + * @param {string} billingAccountName 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 {BillingRoleDefinitionListResult} - 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. + * + * {BillingRoleDefinitionListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BillingRoleDefinitionListResult} 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(billingAccountName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, callback: ServiceCallback): void; + list(billingAccountName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * InvoiceSectionBillingRoleDefinition + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface InvoiceSectionBillingRoleDefinition { + + + /** + * Gets the role definition for a role + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingRoleDefinitionName role definition 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(billingAccountName: string, invoiceSectionName: string, billingRoleDefinitionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the role definition for a role + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingRoleDefinitionName role definition 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 {BillingRoleDefinition} - 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. + * + * {BillingRoleDefinition} [result] - The deserialized result object if an error did not occur. + * See {@link BillingRoleDefinition} 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(billingAccountName: string, invoiceSectionName: string, billingRoleDefinitionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountName: string, invoiceSectionName: string, billingRoleDefinitionName: string, callback: ServiceCallback): void; + get(billingAccountName: string, invoiceSectionName: string, billingRoleDefinitionName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the role definition for a invoice Section + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName: string, invoiceSectionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the role definition for a invoice Section + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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 {BillingRoleDefinitionListResult} - 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. + * + * {BillingRoleDefinitionListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BillingRoleDefinitionListResult} 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(billingAccountName: string, invoiceSectionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, invoiceSectionName: string, callback: ServiceCallback): void; + list(billingAccountName: string, invoiceSectionName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * BillingProfileBillingRoleDefinition + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface BillingProfileBillingRoleDefinition { + + + /** + * Gets the role definition for a role + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName Billing Profile Id. + * + * @param {string} billingRoleDefinitionName role definition 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(billingAccountName: string, billingProfileName: string, billingRoleDefinitionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the role definition for a role + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName Billing Profile Id. + * + * @param {string} billingRoleDefinitionName role definition 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 {BillingRoleDefinition} - 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. + * + * {BillingRoleDefinition} [result] - The deserialized result object if an error did not occur. + * See {@link BillingRoleDefinition} 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(billingAccountName: string, billingProfileName: string, billingRoleDefinitionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountName: string, billingProfileName: string, billingRoleDefinitionName: string, callback: ServiceCallback): void; + get(billingAccountName: string, billingProfileName: string, billingRoleDefinitionName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the role definition for a Billing Profile + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName: string, billingProfileName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the role definition for a Billing Profile + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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 {BillingRoleDefinitionListResult} - 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. + * + * {BillingRoleDefinitionListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BillingRoleDefinitionListResult} 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(billingAccountName: string, billingProfileName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, billingProfileName: string, callback: ServiceCallback): void; + list(billingAccountName: string, billingProfileName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * BillingAccountBillingRoleAssignment + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface BillingAccountBillingRoleAssignment { + + + /** + * Get the role assignment for the caller + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingRoleAssignmentName role assignment 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(billingAccountName: string, billingRoleAssignmentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the role assignment for the caller + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingRoleAssignmentName role assignment 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 {BillingRoleAssignment} - 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. + * + * {BillingRoleAssignment} [result] - The deserialized result object if an error did not occur. + * See {@link BillingRoleAssignment} 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(billingAccountName: string, billingRoleAssignmentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountName: string, billingRoleAssignmentName: string, callback: ServiceCallback): void; + get(billingAccountName: string, billingRoleAssignmentName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Delete the role assignment on this billing account + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingRoleAssignmentName role assignment 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. + */ + deleteMethodWithHttpOperationResponse(billingAccountName: string, billingRoleAssignmentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Delete the role assignment on this billing account + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingRoleAssignmentName role assignment 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 {BillingRoleAssignment} - 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. + * + * {BillingRoleAssignment} [result] - The deserialized result object if an error did not occur. + * See {@link BillingRoleAssignment} 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. + */ + deleteMethod(billingAccountName: string, billingRoleAssignmentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(billingAccountName: string, billingRoleAssignmentName: string, callback: ServiceCallback): void; + deleteMethod(billingAccountName: string, billingRoleAssignmentName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get the role assignments on the Billing Account + * + * @param {string} billingAccountName 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(billingAccountName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the role assignments on the Billing Account + * + * @param {string} billingAccountName 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 {BillingRoleAssignmentListResult} - 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. + * + * {BillingRoleAssignmentListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BillingRoleAssignmentListResult} 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(billingAccountName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, callback: ServiceCallback): void; + list(billingAccountName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to add a role assignment to a billing account. + * + * @param {string} billingAccountName 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. + */ + addWithHttpOperationResponse(billingAccountName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to add a role assignment to a billing account. + * + * @param {string} billingAccountName 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 {BillingRoleAssignmentListResult} - 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. + * + * {BillingRoleAssignmentListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BillingRoleAssignmentListResult} 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. + */ + add(billingAccountName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + add(billingAccountName: string, callback: ServiceCallback): void; + add(billingAccountName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * InvoiceSectionBillingRoleAssignment + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface InvoiceSectionBillingRoleAssignment { + + + /** + * Get the role assignment for the caller on the invoice Section + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingRoleAssignmentName role assignment 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(billingAccountName: string, invoiceSectionName: string, billingRoleAssignmentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the role assignment for the caller on the invoice Section + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingRoleAssignmentName role assignment 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 {BillingRoleAssignment} - 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. + * + * {BillingRoleAssignment} [result] - The deserialized result object if an error did not occur. + * See {@link BillingRoleAssignment} 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(billingAccountName: string, invoiceSectionName: string, billingRoleAssignmentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountName: string, invoiceSectionName: string, billingRoleAssignmentName: string, callback: ServiceCallback): void; + get(billingAccountName: string, invoiceSectionName: string, billingRoleAssignmentName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Delete the role assignment on this invoice Section + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingRoleAssignmentName role assignment 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. + */ + deleteMethodWithHttpOperationResponse(billingAccountName: string, invoiceSectionName: string, billingRoleAssignmentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Delete the role assignment on this invoice Section + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingRoleAssignmentName role assignment 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 {BillingRoleAssignment} - 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. + * + * {BillingRoleAssignment} [result] - The deserialized result object if an error did not occur. + * See {@link BillingRoleAssignment} 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. + */ + deleteMethod(billingAccountName: string, invoiceSectionName: string, billingRoleAssignmentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(billingAccountName: string, invoiceSectionName: string, billingRoleAssignmentName: string, callback: ServiceCallback): void; + deleteMethod(billingAccountName: string, invoiceSectionName: string, billingRoleAssignmentName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get the role assignments on the invoice Section + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName: string, invoiceSectionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the role assignments on the invoice Section + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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 {BillingRoleAssignmentListResult} - 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. + * + * {BillingRoleAssignmentListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BillingRoleAssignmentListResult} 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(billingAccountName: string, invoiceSectionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, invoiceSectionName: string, callback: ServiceCallback): void; + list(billingAccountName: string, invoiceSectionName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to add a role assignment to a invoice Section. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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. + */ + addWithHttpOperationResponse(billingAccountName: string, invoiceSectionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to add a role assignment to a invoice Section. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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 {BillingRoleAssignmentListResult} - 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. + * + * {BillingRoleAssignmentListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BillingRoleAssignmentListResult} 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. + */ + add(billingAccountName: string, invoiceSectionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + add(billingAccountName: string, invoiceSectionName: string, callback: ServiceCallback): void; + add(billingAccountName: string, invoiceSectionName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * BillingProfileBillingRoleAssignment + * __NOTE__: An instance of this class is automatically created for an + * instance of the BillingManagementClient. + */ +export interface BillingProfileBillingRoleAssignment { + + + /** + * Get the role assignment for the caller on the Billing Profile + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName Billing Profile Id. + * + * @param {string} billingRoleAssignmentName role assignment 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(billingAccountName: string, billingProfileName: string, billingRoleAssignmentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the role assignment for the caller on the Billing Profile + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName Billing Profile Id. + * + * @param {string} billingRoleAssignmentName role assignment 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 {BillingRoleAssignment} - 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. + * + * {BillingRoleAssignment} [result] - The deserialized result object if an error did not occur. + * See {@link BillingRoleAssignment} 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(billingAccountName: string, billingProfileName: string, billingRoleAssignmentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(billingAccountName: string, billingProfileName: string, billingRoleAssignmentName: string, callback: ServiceCallback): void; + get(billingAccountName: string, billingProfileName: string, billingRoleAssignmentName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Delete the role assignment on this Billing Profile + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName Billing Profile Id. + * + * @param {string} billingRoleAssignmentName role assignment 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. + */ + deleteMethodWithHttpOperationResponse(billingAccountName: string, billingProfileName: string, billingRoleAssignmentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Delete the role assignment on this Billing Profile + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName Billing Profile Id. + * + * @param {string} billingRoleAssignmentName role assignment 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 {BillingRoleAssignment} - 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. + * + * {BillingRoleAssignment} [result] - The deserialized result object if an error did not occur. + * See {@link BillingRoleAssignment} 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. + */ + deleteMethod(billingAccountName: string, billingProfileName: string, billingRoleAssignmentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(billingAccountName: string, billingProfileName: string, billingRoleAssignmentName: string, callback: ServiceCallback): void; + deleteMethod(billingAccountName: string, billingProfileName: string, billingRoleAssignmentName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get the role assignments on the Billing Profile + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName: string, billingProfileName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the role assignments on the Billing Profile + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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 {BillingRoleAssignmentListResult} - 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. + * + * {BillingRoleAssignmentListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BillingRoleAssignmentListResult} 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(billingAccountName: string, billingProfileName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(billingAccountName: string, billingProfileName: string, callback: ServiceCallback): void; + list(billingAccountName: string, billingProfileName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * The operation to add a role assignment to a billing profile. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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. + */ + addWithHttpOperationResponse(billingAccountName: string, billingProfileName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The operation to add a role assignment to a billing profile. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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 {BillingRoleAssignmentListResult} - 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. + * + * {BillingRoleAssignmentListResult} [result] - The deserialized result object if an error did not occur. + * See {@link BillingRoleAssignmentListResult} 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. + */ + add(billingAccountName: string, billingProfileName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + add(billingAccountName: string, billingProfileName: string, callback: ServiceCallback): void; + add(billingAccountName: string, billingProfileName: string, 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..71e995377b 100644 --- a/lib/services/billingManagement/lib/operations/index.js +++ b/lib/services/billingManagement/lib/operations/index.js @@ -14,7 +14,43 @@ 'use strict'; +exports.BillingAccounts = require('./billingAccounts'); +exports.BillingAccountsWithCreateInvoiceSectionPermission = require('./billingAccountsWithCreateInvoiceSectionPermission'); +exports.AvailableBalanceByBillingProfile = require('./availableBalanceByBillingProfile'); +exports.PaymentMethodsByBillingProfile = require('./paymentMethodsByBillingProfile'); +exports.BillingProfilesByBillingAccountName = require('./billingProfilesByBillingAccountName'); +exports.BillingProfiles = require('./billingProfiles'); +exports.InvoiceSectionsByBillingAccountName = require('./invoiceSectionsByBillingAccountName'); +exports.InvoiceSections = require('./invoiceSections'); +exports.InvoiceSectionsWithCreateSubscriptionPermission = require('./invoiceSectionsWithCreateSubscriptionPermission'); +exports.DepartmentsByBillingAccountName = require('./departmentsByBillingAccountName'); +exports.Departments = require('./departments'); +exports.EnrollmentAccountsByBillingAccountName = require('./enrollmentAccountsByBillingAccountName'); 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.Transfer = require('./transfer'); +exports.Transfers = require('./transfers'); +exports.RecipientTransfer = require('./recipientTransfer'); exports.Operations = require('./operations'); +exports.BillingAccountBillingPermissions = require('./billingAccountBillingPermissions'); +exports.InvoiceSectionsBillingPermissions = require('./invoiceSectionsBillingPermissions'); +exports.BillingProfileBillingPermissions = require('./billingProfileBillingPermissions'); +exports.BillingAccountBillingRoleDefinition = require('./billingAccountBillingRoleDefinition'); +exports.InvoiceSectionBillingRoleDefinition = require('./invoiceSectionBillingRoleDefinition'); +exports.BillingProfileBillingRoleDefinition = require('./billingProfileBillingRoleDefinition'); +exports.BillingAccountBillingRoleAssignment = require('./billingAccountBillingRoleAssignment'); +exports.InvoiceSectionBillingRoleAssignment = require('./invoiceSectionBillingRoleAssignment'); +exports.BillingProfileBillingRoleAssignment = require('./billingProfileBillingRoleAssignment'); diff --git a/lib/services/billingManagement/lib/operations/invoice.js b/lib/services/billingManagement/lib/operations/invoice.js new file mode 100644 index 0000000000..10e11578b3 --- /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} billingAccountName billing Account Id. + * + * @param {string} billingProfileName Billing Profile Id. + * + * @param {string} invoiceName Invoice 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(billingAccountName, billingProfileName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (billingProfileName === null || billingProfileName === undefined || typeof billingProfileName.valueOf() !== 'string') { + throw new Error('billingProfileName 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/{billingAccountName}/billingProfiles/{billingProfileName}/invoices/{invoiceName}'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{billingProfileName}', encodeURIComponent(billingProfileName)); + 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} billingAccountName billing Account Id. + * + * @param {string} billingProfileName Billing Profile Id. + * + * @param {string} invoiceName Invoice 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(billingAccountName, billingProfileName, invoiceName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountName, billingProfileName, 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} billingAccountName billing Account Id. + * + * @param {string} billingProfileName Billing Profile Id. + * + * @param {string} invoiceName Invoice 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(billingAccountName, billingProfileName, 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(billingAccountName, billingProfileName, invoiceName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountName, billingProfileName, 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..8ae1c468c9 --- /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} billingAccountName 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(billingAccountName, 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(billingAccountName, 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} billingAccountName 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(billingAccountName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName 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/{billingAccountName}/invoices/{invoiceName}/pricesheet/default/download'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + 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} billingAccountName 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(billingAccountName, invoiceName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._download(billingAccountName, 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} billingAccountName 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(billingAccountName, 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(billingAccountName, invoiceName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._download(billingAccountName, invoiceName, options, optionalCallback); + } + } + + /** + * Get pricesheet data for invoice id (invoiceName). + * + * @param {string} billingAccountName 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(billingAccountName, invoiceName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginDownload(billingAccountName, 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} billingAccountName 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(billingAccountName, 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(billingAccountName, invoiceName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginDownload(billingAccountName, invoiceName, options, optionalCallback); + } + } + +} + +module.exports = InvoicePricesheet; diff --git a/lib/services/billingManagement/lib/operations/invoiceSectionBillingRoleAssignment.js b/lib/services/billingManagement/lib/operations/invoiceSectionBillingRoleAssignment.js new file mode 100644 index 0000000000..cf82e98fea --- /dev/null +++ b/lib/services/billingManagement/lib/operations/invoiceSectionBillingRoleAssignment.js @@ -0,0 +1,984 @@ +/* + * 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 role assignment for the caller on the invoice Section + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingRoleAssignmentName role assignment 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 BillingRoleAssignment} for more information. + * + * {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(billingAccountName, invoiceSectionName, billingRoleAssignmentName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionName === null || invoiceSectionName === undefined || typeof invoiceSectionName.valueOf() !== 'string') { + throw new Error('invoiceSectionName cannot be null or undefined and it must be of type string.'); + } + if (billingRoleAssignmentName === null || billingRoleAssignmentName === undefined || typeof billingRoleAssignmentName.valueOf() !== 'string') { + throw new Error('billingRoleAssignmentName 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/{billingAccountName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Billing/billingRoleAssignments/{billingRoleAssignmentName}'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{invoiceSectionName}', encodeURIComponent(invoiceSectionName)); + requestUrl = requestUrl.replace('{billingRoleAssignmentName}', encodeURIComponent(billingRoleAssignmentName)); + 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['BillingRoleAssignment']().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); + }); +} + +/** + * Delete the role assignment on this invoice Section + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingRoleAssignmentName role assignment 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 BillingRoleAssignment} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(billingAccountName, invoiceSectionName, billingRoleAssignmentName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionName === null || invoiceSectionName === undefined || typeof invoiceSectionName.valueOf() !== 'string') { + throw new Error('invoiceSectionName cannot be null or undefined and it must be of type string.'); + } + if (billingRoleAssignmentName === null || billingRoleAssignmentName === undefined || typeof billingRoleAssignmentName.valueOf() !== 'string') { + throw new Error('billingRoleAssignmentName 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/{billingAccountName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Billing/billingRoleAssignments/{billingRoleAssignmentName}'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{invoiceSectionName}', encodeURIComponent(invoiceSectionName)); + requestUrl = requestUrl.replace('{billingRoleAssignmentName}', encodeURIComponent(billingRoleAssignmentName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // 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['BillingRoleAssignment']().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 role assignments on the invoice Section + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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 BillingRoleAssignmentListResult} for more + * information. + * + * {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(billingAccountName, invoiceSectionName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionName === null || invoiceSectionName === undefined || typeof invoiceSectionName.valueOf() !== 'string') { + throw new Error('invoiceSectionName 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/{billingAccountName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Billing/billingRoleAssignments'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{invoiceSectionName}', encodeURIComponent(invoiceSectionName)); + 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['BillingRoleAssignmentListResult']().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 add a role assignment to a invoice Section. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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 BillingRoleAssignmentListResult} for more + * information. + * + * {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 _add(billingAccountName, invoiceSectionName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionName === null || invoiceSectionName === undefined || typeof invoiceSectionName.valueOf() !== 'string') { + throw new Error('invoiceSectionName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + let parameters = new client.models['BillingRoleAssignmentPayload'](); + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Billing/createBillingRoleAssignment'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{invoiceSectionName}', encodeURIComponent(invoiceSectionName)); + 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['BillingRoleAssignmentPayload']().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 !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['BillingRoleAssignmentListResult']().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 InvoiceSectionBillingRoleAssignment. */ +class InvoiceSectionBillingRoleAssignment { + /** + * Create a InvoiceSectionBillingRoleAssignment. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._deleteMethod = _deleteMethod; + this._list = _list; + this._add = _add; + } + + /** + * Get the role assignment for the caller on the invoice Section + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingRoleAssignmentName role assignment 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(billingAccountName, invoiceSectionName, billingRoleAssignmentName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountName, invoiceSectionName, billingRoleAssignmentName, 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 role assignment for the caller on the invoice Section + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingRoleAssignmentName role assignment 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 {BillingRoleAssignment} - 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 BillingRoleAssignment} for more information. + * + * {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(billingAccountName, invoiceSectionName, billingRoleAssignmentName, 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(billingAccountName, invoiceSectionName, billingRoleAssignmentName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountName, invoiceSectionName, billingRoleAssignmentName, options, optionalCallback); + } + } + + /** + * Delete the role assignment on this invoice Section + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingRoleAssignmentName role assignment 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. + */ + deleteMethodWithHttpOperationResponse(billingAccountName, invoiceSectionName, billingRoleAssignmentName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(billingAccountName, invoiceSectionName, billingRoleAssignmentName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Delete the role assignment on this invoice Section + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingRoleAssignmentName role assignment 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 {BillingRoleAssignment} - 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 BillingRoleAssignment} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(billingAccountName, invoiceSectionName, billingRoleAssignmentName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(billingAccountName, invoiceSectionName, billingRoleAssignmentName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(billingAccountName, invoiceSectionName, billingRoleAssignmentName, options, optionalCallback); + } + } + + /** + * Get the role assignments on the invoice Section + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName, invoiceSectionName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, invoiceSectionName, 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 role assignments on the invoice Section + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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 {BillingRoleAssignmentListResult} - 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 BillingRoleAssignmentListResult} for more + * information. + * + * {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(billingAccountName, invoiceSectionName, 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(billingAccountName, invoiceSectionName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, invoiceSectionName, options, optionalCallback); + } + } + + /** + * The operation to add a role assignment to a invoice Section. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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. + */ + addWithHttpOperationResponse(billingAccountName, invoiceSectionName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._add(billingAccountName, invoiceSectionName, 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 add a role assignment to a invoice Section. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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 {BillingRoleAssignmentListResult} - 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 BillingRoleAssignmentListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + add(billingAccountName, invoiceSectionName, 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._add(billingAccountName, invoiceSectionName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._add(billingAccountName, invoiceSectionName, options, optionalCallback); + } + } + +} + +module.exports = InvoiceSectionBillingRoleAssignment; diff --git a/lib/services/billingManagement/lib/operations/invoiceSectionBillingRoleDefinition.js b/lib/services/billingManagement/lib/operations/invoiceSectionBillingRoleDefinition.js new file mode 100644 index 0000000000..a27a9830d9 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/invoiceSectionBillingRoleDefinition.js @@ -0,0 +1,499 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets the role definition for a role + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingRoleDefinitionName role definition 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 BillingRoleDefinition} for more information. + * + * {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(billingAccountName, invoiceSectionName, billingRoleDefinitionName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionName === null || invoiceSectionName === undefined || typeof invoiceSectionName.valueOf() !== 'string') { + throw new Error('invoiceSectionName cannot be null or undefined and it must be of type string.'); + } + if (billingRoleDefinitionName === null || billingRoleDefinitionName === undefined || typeof billingRoleDefinitionName.valueOf() !== 'string') { + throw new Error('billingRoleDefinitionName 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/{billingAccountName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Billing/billingRoleDefinitions/{billingRoleDefinitionName}'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{invoiceSectionName}', encodeURIComponent(invoiceSectionName)); + requestUrl = requestUrl.replace('{billingRoleDefinitionName}', encodeURIComponent(billingRoleDefinitionName)); + 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['BillingRoleDefinition']().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 role definition for a invoice Section + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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 BillingRoleDefinitionListResult} for more + * information. + * + * {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(billingAccountName, invoiceSectionName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionName === null || invoiceSectionName === undefined || typeof invoiceSectionName.valueOf() !== 'string') { + throw new Error('invoiceSectionName 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/{billingAccountName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Billing/billingRoleDefinitions'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{invoiceSectionName}', encodeURIComponent(invoiceSectionName)); + 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['BillingRoleDefinitionListResult']().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 InvoiceSectionBillingRoleDefinition. */ +class InvoiceSectionBillingRoleDefinition { + /** + * Create a InvoiceSectionBillingRoleDefinition. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._list = _list; + } + + /** + * Gets the role definition for a role + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingRoleDefinitionName role definition 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(billingAccountName, invoiceSectionName, billingRoleDefinitionName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountName, invoiceSectionName, billingRoleDefinitionName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the role definition for a role + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} billingRoleDefinitionName role definition 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 {BillingRoleDefinition} - 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 BillingRoleDefinition} for more information. + * + * {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(billingAccountName, invoiceSectionName, billingRoleDefinitionName, 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(billingAccountName, invoiceSectionName, billingRoleDefinitionName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountName, invoiceSectionName, billingRoleDefinitionName, options, optionalCallback); + } + } + + /** + * Lists the role definition for a invoice Section + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName, invoiceSectionName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, invoiceSectionName, 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 role definition for a invoice Section + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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 {BillingRoleDefinitionListResult} - 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 BillingRoleDefinitionListResult} for more + * information. + * + * {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(billingAccountName, invoiceSectionName, 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(billingAccountName, invoiceSectionName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, invoiceSectionName, options, optionalCallback); + } + } + +} + +module.exports = InvoiceSectionBillingRoleDefinition; diff --git a/lib/services/billingManagement/lib/operations/invoiceSections.js b/lib/services/billingManagement/lib/operations/invoiceSections.js new file mode 100644 index 0000000000..9308d013fd --- /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} billingAccountName 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(billingAccountName, 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(billingAccountName, 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} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName, invoiceSectionName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionName === null || invoiceSectionName === undefined || typeof invoiceSectionName.valueOf() !== 'string') { + throw new Error('invoiceSectionName 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/{billingAccountName}/invoiceSections/{invoiceSectionName}'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{invoiceSectionName}', encodeURIComponent(invoiceSectionName)); + 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} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName, invoiceSectionName, 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(billingAccountName, invoiceSectionName, 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} billingAccountName 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(billingAccountName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName 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/{billingAccountName}/invoiceSections'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + 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} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName, invoiceSectionName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionName === null || invoiceSectionName === undefined || typeof invoiceSectionName.valueOf() !== 'string') { + throw new Error('invoiceSectionName 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/{billingAccountName}/invoiceSections/{invoiceSectionName}'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{invoiceSectionName}', encodeURIComponent(invoiceSectionName)); + 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} billingAccountName 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(billingAccountName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._create(billingAccountName, 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} billingAccountName 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(billingAccountName, 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(billingAccountName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._create(billingAccountName, parameters, options, optionalCallback); + } + } + + /** + * Get the InvoiceSection by id. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName, invoiceSectionName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountName, invoiceSectionName, 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} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName, invoiceSectionName, 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(billingAccountName, invoiceSectionName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountName, invoiceSectionName, options, optionalCallback); + } + } + + /** + * The operation to update a InvoiceSection. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName, invoiceSectionName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(billingAccountName, invoiceSectionName, 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} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName, invoiceSectionName, 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(billingAccountName, invoiceSectionName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(billingAccountName, invoiceSectionName, parameters, options, optionalCallback); + } + } + + /** + * The operation to create a InvoiceSection. + * + * @param {string} billingAccountName 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(billingAccountName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginCreate(billingAccountName, 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} billingAccountName 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(billingAccountName, 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(billingAccountName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginCreate(billingAccountName, parameters, options, optionalCallback); + } + } + + /** + * The operation to update a InvoiceSection. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName, invoiceSectionName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginUpdate(billingAccountName, invoiceSectionName, 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} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName, invoiceSectionName, 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(billingAccountName, invoiceSectionName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginUpdate(billingAccountName, invoiceSectionName, parameters, options, optionalCallback); + } + } + +} + +module.exports = InvoiceSections; diff --git a/lib/services/billingManagement/lib/operations/invoiceSectionsBillingPermissions.js b/lib/services/billingManagement/lib/operations/invoiceSectionsBillingPermissions.js new file mode 100644 index 0000000000..05fd4dd97e --- /dev/null +++ b/lib/services/billingManagement/lib/operations/invoiceSectionsBillingPermissions.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 all billingPermissions for the caller has for a Invoice Section. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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 BillingPermissionsListResult} for more + * information. + * + * {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(billingAccountName, invoiceSectionName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionName === null || invoiceSectionName === undefined || typeof invoiceSectionName.valueOf() !== 'string') { + throw new Error('invoiceSectionName 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/{billingAccountName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Billing/billingPermissions'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{invoiceSectionName}', encodeURIComponent(invoiceSectionName)); + 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['BillingPermissionsListResult']().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 InvoiceSectionsBillingPermissions. */ +class InvoiceSectionsBillingPermissions { + /** + * Create a InvoiceSectionsBillingPermissions. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + } + + /** + * Lists all billingPermissions for the caller has for a Invoice Section. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName, invoiceSectionName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, invoiceSectionName, 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 billingPermissions for the caller has for a Invoice Section. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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 {BillingPermissionsListResult} - 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 BillingPermissionsListResult} for more + * information. + * + * {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(billingAccountName, invoiceSectionName, 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(billingAccountName, invoiceSectionName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, invoiceSectionName, options, optionalCallback); + } + } + +} + +module.exports = InvoiceSectionsBillingPermissions; diff --git a/lib/services/billingManagement/lib/operations/invoiceSectionsByBillingAccountName.js b/lib/services/billingManagement/lib/operations/invoiceSectionsByBillingAccountName.js new file mode 100644 index 0000000000..5f1840b211 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/invoiceSectionsByBillingAccountName.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} billingAccountName 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(billingAccountName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName 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/{billingAccountName}/invoiceSections'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + 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 InvoiceSectionsByBillingAccountName. */ +class InvoiceSectionsByBillingAccountName { + /** + * Create a InvoiceSectionsByBillingAccountName. + * @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} billingAccountName 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(billingAccountName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, 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} billingAccountName 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(billingAccountName, 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(billingAccountName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, options, optionalCallback); + } + } + +} + +module.exports = InvoiceSectionsByBillingAccountName; diff --git a/lib/services/billingManagement/lib/operations/invoiceSectionsWithCreateSubscriptionPermission.js b/lib/services/billingManagement/lib/operations/invoiceSectionsWithCreateSubscriptionPermission.js new file mode 100644 index 0000000000..70f6083102 --- /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} billingAccountName 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(billingAccountName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName 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/{billingAccountName}/listInvoiceSectionsWithCreateSubscriptionPermission'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + 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} billingAccountName 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(billingAccountName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, 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} billingAccountName 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(billingAccountName, 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(billingAccountName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, options, optionalCallback); + } + } + +} + +module.exports = InvoiceSectionsWithCreateSubscriptionPermission; diff --git a/lib/services/billingManagement/lib/operations/invoiceSectionsbillingPermissions.js b/lib/services/billingManagement/lib/operations/invoiceSectionsbillingPermissions.js new file mode 100644 index 0000000000..b8d5742196 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/invoiceSectionsbillingPermissions.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 all billingPermissions for the caller has for a Invoice Section. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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 BillingPermissionsListResult} for more + * information. + * + * {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(billingAccountName, invoiceSectionName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionName === null || invoiceSectionName === undefined || typeof invoiceSectionName.valueOf() !== 'string') { + throw new Error('invoiceSectionName 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/{billingAccountName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Billing/billingPermissions'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{invoiceSectionName}', encodeURIComponent(invoiceSectionName)); + 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['BillingPermissionsListResult']().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 InvoiceSectionsbillingPermissions. */ +class InvoiceSectionsbillingPermissions { + /** + * Create a InvoiceSectionsbillingPermissions. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + } + + /** + * Lists all billingPermissions for the caller has for a Invoice Section. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName, invoiceSectionName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, invoiceSectionName, 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 billingPermissions for the caller has for a Invoice Section. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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 {BillingPermissionsListResult} - 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 BillingPermissionsListResult} for more + * information. + * + * {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(billingAccountName, invoiceSectionName, 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(billingAccountName, invoiceSectionName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, invoiceSectionName, options, optionalCallback); + } + } + +} + +module.exports = InvoiceSectionsbillingPermissions; diff --git a/lib/services/billingManagement/lib/operations/invoicesByBillingAccount.js b/lib/services/billingManagement/lib/operations/invoicesByBillingAccount.js new file mode 100644 index 0000000000..fe14f3d8a5 --- /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} billingAccountName 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(billingAccountName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName 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/{billingAccountName}/invoices'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + 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} billingAccountName 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(billingAccountName, periodStartDate, periodEndDate, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, 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} billingAccountName 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(billingAccountName, 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(billingAccountName, periodStartDate, periodEndDate, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, 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..f238a30e53 --- /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} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (billingProfileName === null || billingProfileName === undefined || typeof billingProfileName.valueOf() !== 'string') { + throw new Error('billingProfileName 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/{billingAccountName}/billingProfiles/{billingProfileName}/invoices'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{billingProfileName}', encodeURIComponent(billingProfileName)); + 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} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, periodStartDate, periodEndDate, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, billingProfileName, 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} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, 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(billingAccountName, billingProfileName, periodStartDate, periodEndDate, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, billingProfileName, 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..00f090759b --- /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} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (billingProfileName === null || billingProfileName === undefined || typeof billingProfileName.valueOf() !== 'string') { + throw new Error('billingProfileName 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/{billingAccountName}/billingProfiles/{billingProfileName}/paymentMethods'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{billingProfileName}', encodeURIComponent(billingProfileName)); + 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} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, billingProfileName, 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} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, 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(billingAccountName, billingProfileName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, billingProfileName, 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..66187c0b28 --- /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 billingAccountName and billingProfileName. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (billingProfileName === null || billingProfileName === undefined || typeof billingProfileName.valueOf() !== 'string') { + throw new Error('billingProfileName 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/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{billingProfileName}', encodeURIComponent(billingProfileName)); + 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} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (billingProfileName === null || billingProfileName === undefined || typeof billingProfileName.valueOf() !== 'string') { + throw new Error('billingProfileName 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/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{billingProfileName}', encodeURIComponent(billingProfileName)); + 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 billingAccountName and billingProfileName. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._getByBillingProfile(billingAccountName, billingProfileName, 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 billingAccountName and billingProfileName. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, 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(billingAccountName, billingProfileName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._getByBillingProfile(billingAccountName, billingProfileName, options, optionalCallback); + } + } + + /** + * The operation to update a policy. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(billingAccountName, billingProfileName, 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} billingAccountName billing Account Id. + * + * @param {string} billingProfileName 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(billingAccountName, billingProfileName, 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(billingAccountName, billingProfileName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(billingAccountName, billingProfileName, 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..d11f16f2bb --- /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} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} productName Invoice 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(billingAccountName, invoiceSectionName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionName === null || invoiceSectionName === undefined || typeof invoiceSectionName.valueOf() !== 'string') { + throw new Error('invoiceSectionName 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/{billingAccountName}/invoiceSections/{invoiceSectionName}/products/{productName}'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{invoiceSectionName}', encodeURIComponent(invoiceSectionName)); + 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} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} productName Invoice Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionName] 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(billingAccountName, invoiceSectionName, 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 destinationInvoiceSectionName = (options && options.destinationInvoiceSectionName !== undefined) ? options.destinationInvoiceSectionName : undefined; + // Validate + try { + if (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionName === null || invoiceSectionName === undefined || typeof invoiceSectionName.valueOf() !== 'string') { + throw new Error('invoiceSectionName 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 (destinationInvoiceSectionName !== null && destinationInvoiceSectionName !== undefined && typeof destinationInvoiceSectionName.valueOf() !== 'string') { + throw new Error('destinationInvoiceSectionName 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 (destinationInvoiceSectionName !== null && destinationInvoiceSectionName !== undefined) { + parameters = new client.models['TransferProductRequestProperties'](); + parameters.destinationInvoiceSectionName = destinationInvoiceSectionName; + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/products/{productName}/transfer'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{invoiceSectionName}', encodeURIComponent(invoiceSectionName)); + 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} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} productName Invoice 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(billingAccountName, invoiceSectionName, productName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountName, invoiceSectionName, 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} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} productName Invoice 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(billingAccountName, invoiceSectionName, 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(billingAccountName, invoiceSectionName, productName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountName, invoiceSectionName, productName, options, optionalCallback); + } + } + + /** + * The operation to transfer a Product to another InvoiceSection. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} productName Invoice Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionName] 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(billingAccountName, invoiceSectionName, productName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._transfer(billingAccountName, invoiceSectionName, 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} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} productName Invoice Id. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.destinationInvoiceSectionName] 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(billingAccountName, invoiceSectionName, 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(billingAccountName, invoiceSectionName, productName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._transfer(billingAccountName, invoiceSectionName, 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..aef7166382 --- /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 billingAccountName. + * + * @param {string} billingAccountName 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(billingAccountName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName 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/{billingAccountName}/products'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + 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 billingAccountName. + * + * @param {string} nextPageLink The NextLink from 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 billingAccountName. + * + * @param {string} billingAccountName 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(billingAccountName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, 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 billingAccountName. + * + * @param {string} billingAccountName 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(billingAccountName, 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(billingAccountName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, options, optionalCallback); + } + } + + /** + * Lists products by billingAccountName. + * + * @param {string} nextPageLink The NextLink from 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 billingAccountName. + * + * @param {string} nextPageLink The NextLink from 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..9d7ab4bec7 --- /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 billingAccountName. + * + * @param {string} billingAccountName 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(billingAccountName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName 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/{billingAccountName}/billingSubscriptions'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + 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 billingAccountName. + * + * @param {string} nextPageLink The NextLink from 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 billingAccountName. + * + * @param {string} billingAccountName 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(billingAccountName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, 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 billingAccountName. + * + * @param {string} billingAccountName 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(billingAccountName, 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(billingAccountName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, options, optionalCallback); + } + } + + /** + * Lists billing subscriptions by billingAccountName. + * + * @param {string} nextPageLink The NextLink from 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 billingAccountName. + * + * @param {string} nextPageLink The NextLink from 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..2ffb655de5 --- /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 invoiceSectionName. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName, invoiceSectionName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionName === null || invoiceSectionName === undefined || typeof invoiceSectionName.valueOf() !== 'string') { + throw new Error('invoiceSectionName 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/{billingAccountName}/invoiceSections/{invoiceSectionName}/products'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{invoiceSectionName}', encodeURIComponent(invoiceSectionName)); + 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 invoiceSectionName. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName, invoiceSectionName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, invoiceSectionName, 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 invoiceSectionName. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName, invoiceSectionName, 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(billingAccountName, invoiceSectionName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, invoiceSectionName, options, optionalCallback); + } + } + +} + +module.exports = ProductsByInvoiceSection; diff --git a/lib/services/billingManagement/lib/operations/recipientTransfer.js b/lib/services/billingManagement/lib/operations/recipientTransfer.js new file mode 100644 index 0000000000..8a7a925129 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/recipientTransfer.js @@ -0,0 +1,668 @@ +/* + * 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; + +/** + * @summary Gets the transfer with given transfer Id. + * + * @param {string} transferName Transfer Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link RecipientTransferDetails} for more + * information. + * + * {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(transferName, 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 (transferName === null || transferName === undefined || typeof transferName.valueOf() !== 'string') { + throw new Error('transferName 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/transfers/{transferName}/'; + requestUrl = requestUrl.replace('{transferName}', encodeURIComponent(transferName)); + let queryParameters = []; + 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['RecipientTransferDetails']().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); + }); +} + +/** + * @summary Lists the transfers received by caller. + * + * @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 RecipientTransferDetailsListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.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/transfers'; + let queryParameters = []; + 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['RecipientTransferDetailsListResult']().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); + }); +} + +/** + * @summary Lists the transfers received by caller. + * + * @param {string} nextPageLink The NextLink from 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 RecipientTransferDetailsListResult} for more + * information. + * + * {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['RecipientTransferDetailsListResult']().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 RecipientTransfer. */ +class RecipientTransfer { + /** + * Create a RecipientTransfer. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._list = _list; + this._listNext = _listNext; + } + + /** + * @summary Gets the transfer with given transfer Id. + * + * @param {string} transferName Transfer Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(transferName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(transferName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary Gets the transfer with given transfer Id. + * + * @param {string} transferName Transfer 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 {RecipientTransferDetails} - 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 RecipientTransferDetails} for more + * information. + * + * {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(transferName, 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(transferName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(transferName, options, optionalCallback); + } + } + + /** + * @summary Lists the transfers received by caller. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary Lists the transfers received by caller. + * + * @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 {RecipientTransferDetailsListResult} - 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 RecipientTransferDetailsListResult} for more + * information. + * + * {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); + } + } + + /** + * @summary Lists the transfers received by caller. + * + * @param {string} nextPageLink The NextLink from 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; + }); + }); + } + + /** + * @summary Lists the transfers received by caller. + * + * @param {string} nextPageLink The NextLink from 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 {RecipientTransferDetailsListResult} - 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 RecipientTransferDetailsListResult} for more + * information. + * + * {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 = RecipientTransfer; diff --git a/lib/services/billingManagement/lib/operations/transactionsByBillingAccount.js b/lib/services/billingManagement/lib/operations/transactionsByBillingAccount.js new file mode 100644 index 0000000000..d43cf4b8b2 --- /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 billingAccountName for given start and end date. + * + * @param {string} billingAccountName 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(billingAccountName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName 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/{billingAccountName}/transactions'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + 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 billingAccountName 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 billingAccountName for given start and end date. + * + * @param {string} billingAccountName 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(billingAccountName, startDate, endDate, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, 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 billingAccountName for given start and end date. + * + * @param {string} billingAccountName 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(billingAccountName, 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(billingAccountName, startDate, endDate, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, startDate, endDate, options, optionalCallback); + } + } + + /** + * Lists the transactions by billingAccountName 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 billingAccountName 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/lib/operations/transfer.js b/lib/services/billingManagement/lib/operations/transfer.js new file mode 100644 index 0000000000..042199066e --- /dev/null +++ b/lib/services/billingManagement/lib/operations/transfer.js @@ -0,0 +1,1228 @@ +/* + * 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; + +/** + * Initiates the request to transfer the GTM or legacy subscriptions or RIs to + * GTM. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {object} body Initiate transfer parameters. + * + * @param {string} [body.billingProfileId] Target Usage context for devTest + * subscriptions. + * + * @param {string} [body.recipientEmailId] Email Id of recipient for transfer. + * + * @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 TransferDetails} for more information. + * + * {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 _initiate(billingAccountName, invoiceSectionName, body, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionName === null || invoiceSectionName === undefined || typeof invoiceSectionName.valueOf() !== 'string') { + throw new Error('invoiceSectionName cannot be null or undefined and it must be of type string.'); + } + if (body === null || body === undefined) { + throw new Error('body 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/{billingAccountName}/invoiceSections/{invoiceSectionName}/initiateTransfer'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{invoiceSectionName}', encodeURIComponent(invoiceSectionName)); + 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 (body !== null && body !== undefined) { + let requestModelMapper = new client.models['InitiateTransferRequest']().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['TransferDetails']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets the transfer details for given transfer Id. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} transferName Transfer Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link TransferDetails} for more information. + * + * {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(billingAccountName, invoiceSectionName, transferName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionName === null || invoiceSectionName === undefined || typeof invoiceSectionName.valueOf() !== 'string') { + throw new Error('invoiceSectionName cannot be null or undefined and it must be of type string.'); + } + if (transferName === null || transferName === undefined || typeof transferName.valueOf() !== 'string') { + throw new Error('transferName 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/{billingAccountName}/invoiceSections/{invoiceSectionName}/transfers/{transferName}'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{invoiceSectionName}', encodeURIComponent(invoiceSectionName)); + requestUrl = requestUrl.replace('{transferName}', encodeURIComponent(transferName)); + let queryParameters = []; + 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['TransferDetails']().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); + }); +} + +/** + * Cancels the transfer for given transfer Id. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} transferName Transfer Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link TransferDetails} for more information. + * + * {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 _cancel(billingAccountName, invoiceSectionName, transferName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionName === null || invoiceSectionName === undefined || typeof invoiceSectionName.valueOf() !== 'string') { + throw new Error('invoiceSectionName cannot be null or undefined and it must be of type string.'); + } + if (transferName === null || transferName === undefined || typeof transferName.valueOf() !== 'string') { + throw new Error('transferName 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/{billingAccountName}/invoiceSections/{invoiceSectionName}/transfers/{transferName}'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{invoiceSectionName}', encodeURIComponent(invoiceSectionName)); + requestUrl = requestUrl.replace('{transferName}', encodeURIComponent(transferName)); + let queryParameters = []; + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // 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['TransferDetails']().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); + }); +} + +/** + * @summary Accepts the transfer with given transfer Id. + * + * @param {string} transferName Transfer Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.productDetails] Request parameters to accept + * transfer. + * + * @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 RecipientTransferDetails} for more + * information. + * + * {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 _accept(transferName, 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 productDetails = (options && options.productDetails !== undefined) ? options.productDetails : undefined; + // Validate + try { + if (transferName === null || transferName === undefined || typeof transferName.valueOf() !== 'string') { + throw new Error('transferName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + let body; + if (productDetails !== null && productDetails !== undefined) { + body = new client.models['AcceptTransferRequest'](); + body.productDetails = productDetails; + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Billing/transfers/{transferName}/acceptTransfer'; + requestUrl = requestUrl.replace('{transferName}', encodeURIComponent(transferName)); + 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 (body !== null && body !== undefined) { + let requestModelMapper = new client.models['AcceptTransferRequest']().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['RecipientTransferDetails']().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); + }); +} + +/** + * @summary Declines the transfer with given transfer Id. + * + * @param {string} transferName Transfer Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link RecipientTransferDetails} for more + * information. + * + * {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 _decline(transferName, 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 (transferName === null || transferName === undefined || typeof transferName.valueOf() !== 'string') { + throw new Error('transferName 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/transfers/{transferName}/declineTransfer'; + requestUrl = requestUrl.replace('{transferName}', encodeURIComponent(transferName)); + 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]; + } + } + } + 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['RecipientTransferDetails']().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 Transfer. */ +class Transfer { + /** + * Create a Transfer. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._initiate = _initiate; + this._get = _get; + this._cancel = _cancel; + this._accept = _accept; + this._decline = _decline; + } + + /** + * Initiates the request to transfer the GTM or legacy subscriptions or RIs to + * GTM. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {object} body Initiate transfer parameters. + * + * @param {string} [body.billingProfileId] Target Usage context for devTest + * subscriptions. + * + * @param {string} [body.recipientEmailId] Email Id of recipient for transfer. + * + * @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. + */ + initiateWithHttpOperationResponse(billingAccountName, invoiceSectionName, body, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._initiate(billingAccountName, invoiceSectionName, body, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Initiates the request to transfer the GTM or legacy subscriptions or RIs to + * GTM. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {object} body Initiate transfer parameters. + * + * @param {string} [body.billingProfileId] Target Usage context for devTest + * subscriptions. + * + * @param {string} [body.recipientEmailId] Email Id of recipient for transfer. + * + * @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 {TransferDetails} - 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 TransferDetails} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + initiate(billingAccountName, invoiceSectionName, body, 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._initiate(billingAccountName, invoiceSectionName, body, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._initiate(billingAccountName, invoiceSectionName, body, options, optionalCallback); + } + } + + /** + * Gets the transfer details for given transfer Id. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} transferName Transfer Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(billingAccountName, invoiceSectionName, transferName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(billingAccountName, invoiceSectionName, transferName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the transfer details for given transfer Id. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} transferName Transfer 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 {TransferDetails} - 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 TransferDetails} for more information. + * + * {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(billingAccountName, invoiceSectionName, transferName, 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(billingAccountName, invoiceSectionName, transferName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(billingAccountName, invoiceSectionName, transferName, options, optionalCallback); + } + } + + /** + * Cancels the transfer for given transfer Id. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} transferName Transfer Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + cancelWithHttpOperationResponse(billingAccountName, invoiceSectionName, transferName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._cancel(billingAccountName, invoiceSectionName, transferName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Cancels the transfer for given transfer Id. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName InvoiceSection Id. + * + * @param {string} transferName Transfer 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 {TransferDetails} - 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 TransferDetails} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + cancel(billingAccountName, invoiceSectionName, transferName, 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._cancel(billingAccountName, invoiceSectionName, transferName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._cancel(billingAccountName, invoiceSectionName, transferName, options, optionalCallback); + } + } + + /** + * @summary Accepts the transfer with given transfer Id. + * + * @param {string} transferName Transfer Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.productDetails] Request parameters to accept + * transfer. + * + * @param {object} [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. + */ + acceptWithHttpOperationResponse(transferName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._accept(transferName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary Accepts the transfer with given transfer Id. + * + * @param {string} transferName Transfer Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.productDetails] Request parameters to accept + * transfer. + * + * @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 {RecipientTransferDetails} - 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 RecipientTransferDetails} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + accept(transferName, 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._accept(transferName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._accept(transferName, options, optionalCallback); + } + } + + /** + * @summary Declines the transfer with given transfer Id. + * + * @param {string} transferName Transfer Name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + declineWithHttpOperationResponse(transferName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._decline(transferName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary Declines the transfer with given transfer Id. + * + * @param {string} transferName Transfer 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 {RecipientTransferDetails} - 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 RecipientTransferDetails} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + decline(transferName, 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._decline(transferName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._decline(transferName, options, optionalCallback); + } + } + +} + +module.exports = Transfer; diff --git a/lib/services/billingManagement/lib/operations/transfers.js b/lib/services/billingManagement/lib/operations/transfers.js new file mode 100644 index 0000000000..21f1ae37e3 --- /dev/null +++ b/lib/services/billingManagement/lib/operations/transfers.js @@ -0,0 +1,471 @@ +/* + * 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 transfer's details initiated from given invoice section. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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 TransferDetailsListResult} for more + * information. + * + * {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(billingAccountName, invoiceSectionName, 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 (billingAccountName === null || billingAccountName === undefined || typeof billingAccountName.valueOf() !== 'string') { + throw new Error('billingAccountName cannot be null or undefined and it must be of type string.'); + } + if (invoiceSectionName === null || invoiceSectionName === undefined || typeof invoiceSectionName.valueOf() !== 'string') { + throw new Error('invoiceSectionName 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/{billingAccountName}/invoiceSections/{invoiceSectionName}/transfers'; + requestUrl = requestUrl.replace('{billingAccountName}', encodeURIComponent(billingAccountName)); + requestUrl = requestUrl.replace('{invoiceSectionName}', encodeURIComponent(invoiceSectionName)); + let queryParameters = []; + 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['TransferDetailsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists all transfer's details initiated from given invoice section. + * + * @param {string} nextPageLink The NextLink from 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 TransferDetailsListResult} for more + * information. + * + * {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['TransferDetailsListResult']().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 Transfers. */ +class Transfers { + /** + * Create a Transfers. + * @param {BillingManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listNext = _listNext; + } + + /** + * Lists all transfer's details initiated from given invoice section. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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(billingAccountName, invoiceSectionName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(billingAccountName, invoiceSectionName, 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 transfer's details initiated from given invoice section. + * + * @param {string} billingAccountName billing Account Id. + * + * @param {string} invoiceSectionName 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 {TransferDetailsListResult} - 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 TransferDetailsListResult} for more + * information. + * + * {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(billingAccountName, invoiceSectionName, 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(billingAccountName, invoiceSectionName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(billingAccountName, invoiceSectionName, options, optionalCallback); + } + } + + /** + * Lists all transfer's details initiated from given invoice section. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all transfer's details initiated from given invoice section. + * + * @param {string} nextPageLink The NextLink from 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 {TransferDetailsListResult} - 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 TransferDetailsListResult} for more + * information. + * + * {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 = Transfers; 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 +}