diff --git a/lib/services/marketplaceorderingManagement/LICENSE.txt b/lib/services/marketplaceorderingManagement/LICENSE.txt index 0313a903d7..8f3d856145 100644 --- a/lib/services/marketplaceorderingManagement/LICENSE.txt +++ b/lib/services/marketplaceorderingManagement/LICENSE.txt @@ -1,21 +1,21 @@ -The MIT License (MIT) - -Copyright (c) 2017 Microsoft - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +The MIT License (MIT) + +Copyright (c) 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/marketplaceorderingManagement/README.md b/lib/services/marketplaceorderingManagement/README.md index e34cb7ce99..ef0e441d61 100644 --- a/lib/services/marketplaceorderingManagement/README.md +++ b/lib/services/marketplaceorderingManagement/README.md @@ -1,38 +1,46 @@ -# Microsoft Azure SDK for Node.js - MarketplaceOrderingAgreement - -This project provides a Node.js package for accessing the Azure PAS. Right now it supports: -- **Node.js version: 6.x.x or higher** - -## How to Install - -```bash -npm install azure-arm-marketplaceordering -``` - -## How to Use - -### Authentication, client creation and listing marketplaceAgreements as an example - - ```javascript - var msRestAzure = require('ms-rest-azure'); - var MarketplaceOrderingAgreementClient = require("azure-arm-marketplaceordering"); - - // Interactive Login - // It provides a url and code that needs to be copied and pasted in a browser and authenticated over there. If successful, - // the user will get a DeviceTokenCredentials object. - msRestAzure.interactiveLogin(function(err, credentials) { - let client = new MarketplaceOrderingAgreementClient(credentials, 'your-subscription-id'); - client.marketplaceAgreements.get('publisherId', 'offerId', 'planId').then((marketplaceAgreements) => { - console.log('List of marketplaceAgreements:'); - console.dir(marketplaceAgreements, {depth: null, colors: true}); - }); - }).catch((err) => { - console.log('An error ocurred'); - console.dir(err, {depth: null, colors: true}); - }); -}); -``` - -## Related projects - -- [Microsoft Azure SDK for Node.js](https://github.com/Azure/azure-sdk-for-node) +--- +uid: azure-arm-marketplaceordering +summary: *content + +--- +**This SDK will be deprecated next year and will be replaced by a new TypeScript-based isomorphic SDK (found at https://github.com/Azure/azure-sdk-for-js) which works on Node.js and browsers.** +## Microsoft Azure SDK for Node.js - MarketplaceOrderingAgreements + +This project provides a Node.js package for accessing Azure. Right now it supports: +- **Node.js version 6.x.x or higher** + +### Features + + +### How to Install + +```bash +npm install azure-arm-marketplaceordering +``` + +### How to use + +#### Authentication, client creation, and get marketplaceAgreements as an example. + +```javascript +const msRestAzure = require("ms-rest-azure"); +const MarketplaceOrderingAgreements = require("azure-arm-marketplaceordering"); +msRestAzure.interactiveLogin().then((creds) => { + const subscriptionId = ""; + const client = new MarketplaceOrderingAgreements(creds, subscriptionId); + const publisherId = "testpublisherId"; + const offerId = "testofferId"; + const planId = "testplanId"; + + return client.marketplaceAgreements.get(publisherId, offerId, planId).then((result) => { + console.log("The result is:"); + console.log(result); + }); +}).catch((err) => { + console.log('An error occurred:'); + console.dir(err, {depth: null, colors: true}); +}); +``` +### Related projects + +- [Microsoft Azure SDK for Node.js](https://github.com/Azure/azure-sdk-for-node) diff --git a/lib/services/marketplaceorderingManagement/lib/marketplaceOrderingAgreements.d.ts b/lib/services/marketplaceorderingManagement/lib/marketplaceOrderingAgreements.d.ts index bd00363cc8..ff3103f7d8 100644 --- a/lib/services/marketplaceorderingManagement/lib/marketplaceOrderingAgreements.d.ts +++ b/lib/services/marketplaceorderingManagement/lib/marketplaceOrderingAgreements.d.ts @@ -10,9 +10,10 @@ import { ServiceClientCredentials } from 'ms-rest'; import { AzureServiceClient, AzureServiceClientOptions } from 'ms-rest-azure'; +import * as models from "./models"; import * as operations from "./operations"; -declare class MarketplaceOrderingAgreements extends AzureServiceClient { +export default class MarketplaceOrderingAgreements extends AzureServiceClient { /** * Initializes a new instance of the MarketplaceOrderingAgreements class. * @constructor @@ -33,11 +34,11 @@ declare class MarketplaceOrderingAgreements 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); @@ -59,4 +60,4 @@ declare class MarketplaceOrderingAgreements extends AzureServiceClient { operations: operations.Operations; } -export = MarketplaceOrderingAgreements; +export { MarketplaceOrderingAgreements, models as MarketplaceOrderingAgreementsModels }; diff --git a/lib/services/marketplaceorderingManagement/lib/marketplaceOrderingAgreements.js b/lib/services/marketplaceorderingManagement/lib/marketplaceOrderingAgreements.js index 07fb1c577b..7896491206 100644 --- a/lib/services/marketplaceorderingManagement/lib/marketplaceOrderingAgreements.js +++ b/lib/services/marketplaceorderingManagement/lib/marketplaceOrderingAgreements.js @@ -34,9 +34,9 @@ class MarketplaceOrderingAgreements 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) { @@ -81,3 +81,6 @@ class MarketplaceOrderingAgreements extends ServiceClient { } module.exports = MarketplaceOrderingAgreements; +module.exports['default'] = MarketplaceOrderingAgreements; +module.exports.MarketplaceOrderingAgreements = MarketplaceOrderingAgreements; +module.exports.MarketplaceOrderingAgreementsModels = models; diff --git a/lib/services/marketplaceorderingManagement/lib/models/agreementTerms.js b/lib/services/marketplaceorderingManagement/lib/models/agreementTerms.js index 2714cb5e34..0a5eb86cf4 100644 --- a/lib/services/marketplaceorderingManagement/lib/models/agreementTerms.js +++ b/lib/services/marketplaceorderingManagement/lib/models/agreementTerms.js @@ -20,19 +20,19 @@ const models = require('./index'); class AgreementTerms extends models['Resource'] { /** * Create a AgreementTerms. - * @member {string} [publisher] Publisher identifier string of image being + * @property {string} [publisher] Publisher identifier string of image being * deployed. - * @member {string} [product] Offer identifier string of image being + * @property {string} [product] Offer identifier string of image being * deployed. - * @member {string} [plan] Plan identifier string of image being deployed. - * @member {string} [licenseTextLink] Link to HTML with Microsoft and + * @property {string} [plan] Plan identifier string of image being deployed. + * @property {string} [licenseTextLink] Link to HTML with Microsoft and * Publisher terms. - * @member {string} [privacyPolicyLink] Link to the privacy policy of the + * @property {string} [privacyPolicyLink] Link to the privacy policy of the * publisher. - * @member {string} [retrieveDatetime] Date and time in UTC of when the terms - * were accepted. This is empty if Accepted is false. - * @member {string} [signature] Terms signature. - * @member {boolean} [accepted] If any version of the terms have been + * @property {string} [retrieveDatetime] Date and time in UTC of when the + * terms were accepted. This is empty if Accepted is false. + * @property {string} [signature] Terms signature. + * @property {boolean} [accepted] If any version of the terms have been * accepted, otherwise false. */ constructor() { diff --git a/lib/services/marketplaceorderingManagement/lib/models/errorResponse.js b/lib/services/marketplaceorderingManagement/lib/models/errorResponse.js index a6adc77aa5..aa3f3d4a58 100644 --- a/lib/services/marketplaceorderingManagement/lib/models/errorResponse.js +++ b/lib/services/marketplaceorderingManagement/lib/models/errorResponse.js @@ -10,19 +10,18 @@ 'use strict'; -const models = require('./index'); - /** - * Error reponse indicates Microsoft.MarketplaceOrdering service is not able to - * process the incoming request. The reason is provided in the error message. + * Error response indicates Microsoft.MarketplaceOrdering service is not able + * to process the incoming request. The reason is provided in the error + * message. * */ class ErrorResponse { /** * Create a ErrorResponse. - * @member {object} [error] The details of the error. - * @member {string} [error.code] Error code. - * @member {string} [error.message] Error message indicating why the + * @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. */ constructor() { diff --git a/lib/services/marketplaceorderingManagement/lib/models/errorResponseError.js b/lib/services/marketplaceorderingManagement/lib/models/errorResponseError.js index ee425b8598..e745ed6dcb 100644 --- a/lib/services/marketplaceorderingManagement/lib/models/errorResponseError.js +++ b/lib/services/marketplaceorderingManagement/lib/models/errorResponseError.js @@ -17,8 +17,8 @@ class ErrorResponseError { /** * Create a ErrorResponseError. - * @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. */ constructor() { diff --git a/lib/services/marketplaceorderingManagement/lib/models/index.d.ts b/lib/services/marketplaceorderingManagement/lib/models/index.d.ts index c001d58abe..b3246053d7 100644 --- a/lib/services/marketplaceorderingManagement/lib/models/index.d.ts +++ b/lib/services/marketplaceorderingManagement/lib/models/index.d.ts @@ -1,148 +1,140 @@ /* * 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 +}; /** - * @class - * Initializes a new instance of the Resource class. - * @constructor * ARM resource. - * - * @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 AgreementTerms class. - * @constructor * Terms properties for provided Publisher/Offer/Plan tuple - * - * @member {string} [publisher] Publisher identifier string of image being - * deployed. - * @member {string} [product] Offer identifier string of image being deployed. - * @member {string} [plan] Plan identifier string of image being deployed. - * @member {string} [licenseTextLink] Link to HTML with Microsoft and Publisher - * terms. - * @member {string} [privacyPolicyLink] Link to the privacy policy of the - * publisher. - * @member {string} [retrieveDatetime] Date and time in UTC of when the terms - * were accepted. This is empty if Accepted is false. - * @member {string} [signature] Terms signature. - * @member {boolean} [accepted] If any version of the terms have been accepted, - * otherwise false. */ export interface AgreementTerms extends Resource { + /** + * Publisher identifier string of image being deployed. + */ publisher?: string; + /** + * Offer identifier string of image being deployed. + */ product?: string; + /** + * Plan identifier string of image being deployed. + */ plan?: string; + /** + * Link to HTML with Microsoft and Publisher terms. + */ licenseTextLink?: string; + /** + * Link to the privacy policy of the publisher. + */ privacyPolicyLink?: string; + /** + * Date and time in UTC of when the terms were accepted. This is empty if Accepted is false. + */ retrieveDatetime?: string; + /** + * Terms signature. + */ signature?: string; + /** + * If any version of the terms have been accepted, otherwise false. + */ accepted?: boolean; } /** - * @class - * Initializes a new instance of the ErrorResponseError class. - * @constructor * The details of the error. - * - * @member {string} [code] Error code. - * @member {string} [message] Error message indicating why the operation - * failed. */ export interface ErrorResponseError { + /** + * Error code. + */ readonly code?: string; + /** + * Error message indicating why the operation failed. + */ readonly message?: string; } /** - * @class - * Initializes a new instance of the ErrorResponse class. - * @constructor - * Error reponse indicates Microsoft.MarketplaceOrdering 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. + * Error response indicates Microsoft.MarketplaceOrdering 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?: ErrorResponseError; } /** - * @class - * Initializes a new instance of the OperationDisplay class. - * @constructor * The object that represents the operation. - * - * @member {string} [provider] Service provider: Microsoft.MarketplaceOrdering - * @member {string} [resource] Resource on which the operation is performed: - * Agreement, virtualmachine, etc. - * @member {string} [operation] Operation type: Get Agreement, Sign Agreement, - * Cancel Agreement etc. */ export interface OperationDisplay { + /** + * Service provider: Microsoft.MarketplaceOrdering + */ provider?: string; + /** + * Resource on which the operation is performed: Agreement, virtualmachine, etc. + */ resource?: string; + /** + * Operation type: Get Agreement, Sign Agreement, Cancel Agreement etc. + */ operation?: string; } /** - * @class - * Initializes a new instance of the Operation class. - * @constructor * Microsoft.MarketplaceOrdering 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.MarketplaceOrdering - * @member {string} [display.resource] Resource on which the operation is - * performed: Agreement, virtualmachine, etc. - * @member {string} [display.operation] Operation type: Get Agreement, Sign - * Agreement, Cancel Agreement etc. */ export interface Operation { + /** + * Operation name: {provider}/{resource}/{operation} + */ name?: string; + /** + * The object that represents the operation. + */ display?: OperationDisplay; } - /** - * @class - * Initializes a new instance of the OperationListResult class. - * @constructor - * Result of the request to list MarketplaceOrdering 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 the request to list MarketplaceOrdering 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/marketplaceorderingManagement/lib/models/operation.js b/lib/services/marketplaceorderingManagement/lib/models/operation.js index fc661742f2..1a6e54b1c6 100644 --- a/lib/services/marketplaceorderingManagement/lib/models/operation.js +++ b/lib/services/marketplaceorderingManagement/lib/models/operation.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Microsoft.MarketplaceOrdering 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: + * @property {string} [name] Operation name: + * {provider}/{resource}/{operation} + * @property {object} [display] The object that represents the operation. + * @property {string} [display.provider] Service provider: * Microsoft.MarketplaceOrdering - * @member {string} [display.resource] Resource on which the operation is + * @property {string} [display.resource] Resource on which the operation is * performed: Agreement, virtualmachine, etc. - * @member {string} [display.operation] Operation type: Get Agreement, Sign + * @property {string} [display.operation] Operation type: Get Agreement, Sign * Agreement, Cancel Agreement etc. */ constructor() { diff --git a/lib/services/marketplaceorderingManagement/lib/models/operationDisplay.js b/lib/services/marketplaceorderingManagement/lib/models/operationDisplay.js index 330b024cad..b834f6764d 100644 --- a/lib/services/marketplaceorderingManagement/lib/models/operationDisplay.js +++ b/lib/services/marketplaceorderingManagement/lib/models/operationDisplay.js @@ -17,11 +17,11 @@ class OperationDisplay { /** * Create a OperationDisplay. - * @member {string} [provider] Service provider: + * @property {string} [provider] Service provider: * Microsoft.MarketplaceOrdering - * @member {string} [resource] Resource on which the operation is performed: - * Agreement, virtualmachine, etc. - * @member {string} [operation] Operation type: Get Agreement, Sign + * @property {string} [resource] Resource on which the operation is + * performed: Agreement, virtualmachine, etc. + * @property {string} [operation] Operation type: Get Agreement, Sign * Agreement, Cancel Agreement etc. */ constructor() { diff --git a/lib/services/marketplaceorderingManagement/lib/models/operationListResult.js b/lib/services/marketplaceorderingManagement/lib/models/operationListResult.js index 8ee2f4156a..5414779ab5 100644 --- a/lib/services/marketplaceorderingManagement/lib/models/operationListResult.js +++ b/lib/services/marketplaceorderingManagement/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/marketplaceorderingManagement/lib/models/resource.js b/lib/services/marketplaceorderingManagement/lib/models/resource.js index 57088e37e3..9ccac357d1 100644 --- a/lib/services/marketplaceorderingManagement/lib/models/resource.js +++ b/lib/services/marketplaceorderingManagement/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/marketplaceorderingManagement/lib/operations/index.d.ts b/lib/services/marketplaceorderingManagement/lib/operations/index.d.ts index a630e49b05..625895273f 100644 --- a/lib/services/marketplaceorderingManagement/lib/operations/index.d.ts +++ b/lib/services/marketplaceorderingManagement/lib/operations/index.d.ts @@ -201,6 +201,251 @@ export interface MarketplaceAgreements { create(publisherId: string, offerId: string, planId: string, parameters: models.AgreementTerms, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; create(publisherId: string, offerId: string, planId: string, parameters: models.AgreementTerms, callback: ServiceCallback): void; create(publisherId: string, offerId: string, planId: string, parameters: models.AgreementTerms, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Sign marketplace terms. + * + * @param {string} publisherId Publisher identifier string of image being + * deployed. + * + * @param {string} offerId Offer identifier string of image being deployed. + * + * @param {string} planId Plan identifier string of image being deployed. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + signWithHttpOperationResponse(publisherId: string, offerId: string, planId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Sign marketplace terms. + * + * @param {string} publisherId Publisher identifier string of image being + * deployed. + * + * @param {string} offerId Offer identifier string of image being deployed. + * + * @param {string} planId Plan identifier string of image being deployed. + * + * @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 {AgreementTerms} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {AgreementTerms} [result] - The deserialized result object if an error did not occur. + * See {@link AgreementTerms} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + sign(publisherId: string, offerId: string, planId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + sign(publisherId: string, offerId: string, planId: string, callback: ServiceCallback): void; + sign(publisherId: string, offerId: string, planId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Cancel marketplace terms. + * + * @param {string} publisherId Publisher identifier string of image being + * deployed. + * + * @param {string} offerId Offer identifier string of image being deployed. + * + * @param {string} planId Plan identifier string of image being deployed. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that 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(publisherId: string, offerId: string, planId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Cancel marketplace terms. + * + * @param {string} publisherId Publisher identifier string of image being + * deployed. + * + * @param {string} offerId Offer identifier string of image being deployed. + * + * @param {string} planId Plan identifier string of image being deployed. + * + * @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 {AgreementTerms} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {AgreementTerms} [result] - The deserialized result object if an error did not occur. + * See {@link AgreementTerms} for more information. + * + * {WebResource} [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(publisherId: string, offerId: string, planId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + cancel(publisherId: string, offerId: string, planId: string, callback: ServiceCallback): void; + cancel(publisherId: string, offerId: string, planId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get marketplace agreement. + * + * @param {string} publisherId Publisher identifier string of image being + * deployed. + * + * @param {string} offerId Offer identifier string of image being deployed. + * + * @param {string} planId Plan identifier string of image being deployed. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getAgreementWithHttpOperationResponse(publisherId: string, offerId: string, planId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get marketplace agreement. + * + * @param {string} publisherId Publisher identifier string of image being + * deployed. + * + * @param {string} offerId Offer identifier string of image being deployed. + * + * @param {string} planId Plan identifier string of image being deployed. + * + * @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 {AgreementTerms} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {AgreementTerms} [result] - The deserialized result object if an error did not occur. + * See {@link AgreementTerms} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + getAgreement(publisherId: string, offerId: string, planId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getAgreement(publisherId: string, offerId: string, planId: string, callback: ServiceCallback): void; + getAgreement(publisherId: string, offerId: string, planId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * List marketplace agreements in the subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * List marketplace agreements in the subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Array} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } /** diff --git a/lib/services/marketplaceorderingManagement/lib/operations/marketplaceAgreements.js b/lib/services/marketplaceorderingManagement/lib/operations/marketplaceAgreements.js index 1cb90b3d10..76be9da5dd 100644 --- a/lib/services/marketplaceorderingManagement/lib/operations/marketplaceAgreements.js +++ b/lib/services/marketplaceorderingManagement/lib/operations/marketplaceAgreements.js @@ -366,20 +366,864 @@ function _create(publisherId, offerId, planId, parameters, options, callback) { }); } +/** + * Sign marketplace terms. + * + * @param {string} publisherId Publisher identifier string of image being + * deployed. + * + * @param {string} offerId Offer identifier string of image being deployed. + * + * @param {string} planId Plan identifier string of image being deployed. + * + * @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 AgreementTerms} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _sign(publisherId, offerId, planId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (publisherId === null || publisherId === undefined || typeof publisherId.valueOf() !== 'string') { + throw new Error('publisherId cannot be null or undefined and it must be of type string.'); + } + if (offerId === null || offerId === undefined || typeof offerId.valueOf() !== 'string') { + throw new Error('offerId cannot be null or undefined and it must be of type string.'); + } + if (planId === null || planId === undefined || typeof planId.valueOf() !== 'string') { + throw new Error('planId 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.MarketplaceOrdering/agreements/{publisherId}/offers/{offerId}/plans/{planId}/sign'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{publisherId}', encodeURIComponent(publisherId)); + requestUrl = requestUrl.replace('{offerId}', encodeURIComponent(offerId)); + requestUrl = requestUrl.replace('{planId}', encodeURIComponent(planId)); + 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]; + } + } + } + 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['AgreementTerms']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let 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 marketplace terms. + * + * @param {string} publisherId Publisher identifier string of image being + * deployed. + * + * @param {string} offerId Offer identifier string of image being deployed. + * + * @param {string} planId Plan identifier string of image being deployed. + * + * @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 AgreementTerms} for more information. + * + * {object} [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(publisherId, offerId, planId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (publisherId === null || publisherId === undefined || typeof publisherId.valueOf() !== 'string') { + throw new Error('publisherId cannot be null or undefined and it must be of type string.'); + } + if (offerId === null || offerId === undefined || typeof offerId.valueOf() !== 'string') { + throw new Error('offerId cannot be null or undefined and it must be of type string.'); + } + if (planId === null || planId === undefined || typeof planId.valueOf() !== 'string') { + throw new Error('planId 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.MarketplaceOrdering/agreements/{publisherId}/offers/{offerId}/plans/{planId}/cancel'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{publisherId}', encodeURIComponent(publisherId)); + requestUrl = requestUrl.replace('{offerId}', encodeURIComponent(offerId)); + requestUrl = requestUrl.replace('{planId}', encodeURIComponent(planId)); + 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]; + } + } + } + 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['AgreementTerms']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let 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 marketplace agreement. + * + * @param {string} publisherId Publisher identifier string of image being + * deployed. + * + * @param {string} offerId Offer identifier string of image being deployed. + * + * @param {string} planId Plan identifier string of image being deployed. + * + * @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 AgreementTerms} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _getAgreement(publisherId, offerId, planId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (publisherId === null || publisherId === undefined || typeof publisherId.valueOf() !== 'string') { + throw new Error('publisherId cannot be null or undefined and it must be of type string.'); + } + if (offerId === null || offerId === undefined || typeof offerId.valueOf() !== 'string') { + throw new Error('offerId cannot be null or undefined and it must be of type string.'); + } + if (planId === null || planId === undefined || typeof planId.valueOf() !== 'string') { + throw new Error('planId 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.MarketplaceOrdering/agreements/{publisherId}/offers/{offerId}/plans/{planId}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{publisherId}', encodeURIComponent(publisherId)); + requestUrl = requestUrl.replace('{offerId}', encodeURIComponent(offerId)); + requestUrl = requestUrl.replace('{planId}', encodeURIComponent(planId)); + 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) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().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['AgreementTerms']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * List marketplace agreements in the subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {array} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.MarketplaceOrdering/agreements'; + 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) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().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 = { + required: false, + serializedName: 'parsedResponse', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'AgreementTermsElementType', + type: { + name: 'Composite', + className: 'AgreementTerms' + } + } + } + }; + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let 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 MarketplaceAgreements. */ class MarketplaceAgreements { /** * Create a MarketplaceAgreements. * @param {MarketplaceOrderingAgreements} client Reference to the service client. */ - constructor(client) { - this.client = client; - this._get = _get; - this._create = _create; + constructor(client) { + this.client = client; + this._get = _get; + this._create = _create; + this._sign = _sign; + this._cancel = _cancel; + this._getAgreement = _getAgreement; + this._list = _list; + } + + /** + * Get marketplace terms. + * + * @param {string} publisherId Publisher identifier string of image being + * deployed. + * + * @param {string} offerId Offer identifier string of image being deployed. + * + * @param {string} planId Plan identifier string of image being deployed. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers 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(publisherId, offerId, planId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(publisherId, offerId, planId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get marketplace terms. + * + * @param {string} publisherId Publisher identifier string of image being + * deployed. + * + * @param {string} offerId Offer identifier string of image being deployed. + * + * @param {string} planId Plan identifier string of image being deployed. + * + * @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 {AgreementTerms} - The deserialized 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 AgreementTerms} for more information. + * + * {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(publisherId, offerId, planId, 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(publisherId, offerId, planId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(publisherId, offerId, planId, options, optionalCallback); + } + } + + /** + * Save marketplace terms. + * + * @param {string} publisherId Publisher identifier string of image being + * deployed. + * + * @param {string} offerId Offer identifier string of image being deployed. + * + * @param {string} planId Plan identifier string of image being deployed. + * + * @param {object} parameters Parameters supplied to the Create Marketplace + * Terms operation. + * + * @param {string} [parameters.publisher] Publisher identifier string of image + * being deployed. + * + * @param {string} [parameters.product] Offer identifier string of image being + * deployed. + * + * @param {string} [parameters.plan] Plan identifier string of image being + * deployed. + * + * @param {string} [parameters.licenseTextLink] Link to HTML with Microsoft and + * Publisher terms. + * + * @param {string} [parameters.privacyPolicyLink] Link to the privacy policy of + * the publisher. + * + * @param {string} [parameters.retrieveDatetime] Date and time in UTC of when + * the terms were accepted. This is empty if Accepted is false. + * + * @param {string} [parameters.signature] Terms signature. + * + * @param {boolean} [parameters.accepted] If any version of the terms have been + * accepted, otherwise false. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers 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(publisherId, offerId, planId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._create(publisherId, offerId, planId, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Save marketplace terms. + * + * @param {string} publisherId Publisher identifier string of image being + * deployed. + * + * @param {string} offerId Offer identifier string of image being deployed. + * + * @param {string} planId Plan identifier string of image being deployed. + * + * @param {object} parameters Parameters supplied to the Create Marketplace + * Terms operation. + * + * @param {string} [parameters.publisher] Publisher identifier string of image + * being deployed. + * + * @param {string} [parameters.product] Offer identifier string of image being + * deployed. + * + * @param {string} [parameters.plan] Plan identifier string of image being + * deployed. + * + * @param {string} [parameters.licenseTextLink] Link to HTML with Microsoft and + * Publisher terms. + * + * @param {string} [parameters.privacyPolicyLink] Link to the privacy policy of + * the publisher. + * + * @param {string} [parameters.retrieveDatetime] Date and time in UTC of when + * the terms were accepted. This is empty if Accepted is false. + * + * @param {string} [parameters.signature] Terms signature. + * + * @param {boolean} [parameters.accepted] If any version of the terms have been + * accepted, otherwise false. + * + * @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 {AgreementTerms} - The deserialized 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 AgreementTerms} for more information. + * + * {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(publisherId, offerId, planId, 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(publisherId, offerId, planId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._create(publisherId, offerId, planId, parameters, options, optionalCallback); + } } /** - * Get marketplace terms. + * Sign marketplace terms. * * @param {string} publisherId Publisher identifier string of image being * deployed. @@ -399,11 +1243,11 @@ class MarketplaceAgreements { * * @reject {Error} - The error object. */ - getWithHttpOperationResponse(publisherId, offerId, planId, options) { + signWithHttpOperationResponse(publisherId, offerId, planId, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._get(publisherId, offerId, planId, options, (err, result, request, response) => { + self._sign(publisherId, offerId, planId, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -414,7 +1258,7 @@ class MarketplaceAgreements { } /** - * Get marketplace terms. + * Sign marketplace terms. * * @param {string} publisherId Publisher identifier string of image being * deployed. @@ -450,7 +1294,7 @@ class MarketplaceAgreements { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - get(publisherId, offerId, planId, options, optionalCallback) { + sign(publisherId, offerId, planId, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -459,19 +1303,19 @@ class MarketplaceAgreements { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._get(publisherId, offerId, planId, options, (err, result, request, response) => { + self._sign(publisherId, offerId, planId, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._get(publisherId, offerId, planId, options, optionalCallback); + return self._sign(publisherId, offerId, planId, options, optionalCallback); } } /** - * Save marketplace terms. + * Cancel marketplace terms. * * @param {string} publisherId Publisher identifier string of image being * deployed. @@ -480,31 +1324,97 @@ class MarketplaceAgreements { * * @param {string} planId Plan identifier string of image being deployed. * - * @param {object} parameters Parameters supplied to the Create Marketplace - * Terms operation. + * @param {object} [options] Optional Parameters. * - * @param {string} [parameters.publisher] Publisher identifier string of image - * being deployed. + * @param {object} [options.customHeaders] Headers that will be added to the + * request * - * @param {string} [parameters.product] Offer identifier string of image being - * deployed. + * @returns {Promise} A promise is returned * - * @param {string} [parameters.plan] Plan identifier string of image being + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + cancelWithHttpOperationResponse(publisherId, offerId, planId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._cancel(publisherId, offerId, planId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Cancel marketplace terms. + * + * @param {string} publisherId Publisher identifier string of image being * deployed. * - * @param {string} [parameters.licenseTextLink] Link to HTML with Microsoft and - * Publisher terms. + * @param {string} offerId Offer identifier string of image being deployed. * - * @param {string} [parameters.privacyPolicyLink] Link to the privacy policy of - * the publisher. + * @param {string} planId Plan identifier string of image being deployed. * - * @param {string} [parameters.retrieveDatetime] Date and time in UTC of when - * the terms were accepted. This is empty if Accepted is false. + * @param {object} [options] Optional Parameters. * - * @param {string} [parameters.signature] Terms signature. + * @param {object} [options.customHeaders] Headers that will be added to the + * request * - * @param {boolean} [parameters.accepted] If any version of the terms have been - * accepted, otherwise false. + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {AgreementTerms} - The deserialized 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 AgreementTerms} for more information. + * + * {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(publisherId, offerId, planId, 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(publisherId, offerId, planId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._cancel(publisherId, offerId, planId, options, optionalCallback); + } + } + + /** + * Get marketplace agreement. + * + * @param {string} publisherId Publisher identifier string of image being + * deployed. + * + * @param {string} offerId Offer identifier string of image being deployed. + * + * @param {string} planId Plan identifier string of image being deployed. * * @param {object} [options] Optional Parameters. * @@ -517,11 +1427,11 @@ class MarketplaceAgreements { * * @reject {Error} - The error object. */ - createWithHttpOperationResponse(publisherId, offerId, planId, parameters, options) { + getAgreementWithHttpOperationResponse(publisherId, offerId, planId, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._create(publisherId, offerId, planId, parameters, options, (err, result, request, response) => { + self._getAgreement(publisherId, offerId, planId, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -532,7 +1442,7 @@ class MarketplaceAgreements { } /** - * Save marketplace terms. + * Get marketplace agreement. * * @param {string} publisherId Publisher identifier string of image being * deployed. @@ -541,31 +1451,83 @@ class MarketplaceAgreements { * * @param {string} planId Plan identifier string of image being deployed. * - * @param {object} parameters Parameters supplied to the Create Marketplace - * Terms operation. + * @param {object} [options] Optional Parameters. * - * @param {string} [parameters.publisher] Publisher identifier string of image - * being deployed. + * @param {object} [options.customHeaders] Headers that will be added to the + * request * - * @param {string} [parameters.product] Offer identifier string of image being - * deployed. + * @param {function} [optionalCallback] - The optional callback. * - * @param {string} [parameters.plan] Plan identifier string of image being - * deployed. + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. * - * @param {string} [parameters.licenseTextLink] Link to HTML with Microsoft and - * Publisher terms. + * {Promise} A promise is returned * - * @param {string} [parameters.privacyPolicyLink] Link to the privacy policy of - * the publisher. + * @resolve {AgreementTerms} - The deserialized result object. * - * @param {string} [parameters.retrieveDatetime] Date and time in UTC of when - * the terms were accepted. This is empty if Accepted is false. + * @reject {Error} - The error object. * - * @param {string} [parameters.signature] Terms signature. + * {function} optionalCallback(err, result, request, response) * - * @param {boolean} [parameters.accepted] If any version of the terms have been - * accepted, otherwise false. + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link AgreementTerms} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + getAgreement(publisherId, offerId, planId, 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._getAgreement(publisherId, offerId, planId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._getAgreement(publisherId, offerId, planId, options, optionalCallback); + } + } + + /** + * List marketplace agreements in the subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * List marketplace agreements in the subscription. * * @param {object} [options] Optional Parameters. * @@ -579,7 +1541,7 @@ class MarketplaceAgreements { * * {Promise} A promise is returned * - * @resolve {AgreementTerms} - The deserialized result object. + * @resolve {Array} - The deserialized result object. * * @reject {Error} - The error object. * @@ -587,14 +1549,13 @@ class MarketplaceAgreements { * * {Error} err - The Error object if an error occurred, null otherwise. * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link AgreementTerms} for more information. + * {array} [result] - The deserialized result object if an error did not occur. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - create(publisherId, offerId, planId, parameters, options, optionalCallback) { + list(options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -603,14 +1564,14 @@ class MarketplaceAgreements { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._create(publisherId, offerId, planId, parameters, options, (err, result, request, response) => { + self._list(options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._create(publisherId, offerId, planId, parameters, options, optionalCallback); + return self._list(options, optionalCallback); } } diff --git a/lib/services/marketplaceorderingManagement/package.json b/lib/services/marketplaceorderingManagement/package.json index 797e8b144d..26ede7f57e 100644 --- a/lib/services/marketplaceorderingManagement/package.json +++ b/lib/services/marketplaceorderingManagement/package.json @@ -1,35 +1,25 @@ { "name": "azure-arm-marketplaceordering", "author": "Microsoft Corporation", - "contributors": [ - "Zavery, Amar " - ], + "description": "MarketplaceOrderingAgreements Library with typescript type definitions for node", "version": "1.2.0-preview", - "description": "Microsoft Azure Consumption Management Client Library for node", - "tags": [ - "azure", - "sdk" - ], + "dependencies": { + "ms-rest": "^2.3.3", + "ms-rest-azure": "^2.5.5" + }, "keywords": [ "node", "azure" ], + "license": "MIT", "main": "./lib/marketplaceOrderingAgreements.js", "types": "./lib/marketplaceOrderingAgreements.d.ts", - "license": "MIT", - "dependencies": { - "ms-rest": "^2.3.1", - "ms-rest-azure": "^2.5.4" - }, - "homepage": "http://github.com/Azure/azure-sdk-for-node", + "homepage": "https://github.com/azure/azure-sdk-for-node/tree/master/lib/services/marketplaceorderingManagement", "repository": { "type": "git", - "url": "git@github.com:Azure/azure-sdk-for-node.git" + "url": "https://github.com/azure/azure-sdk-for-node.git" }, "bugs": { - "url": "http://github.com/Azure/azure-sdk-for-node/issues" - }, - "scripts": { - "test": "npm -s run-script jshint" + "url": "https://github.com/azure/azure-sdk-for-node/issues" } -} \ No newline at end of file +}