diff --git a/lib/services/advisorManagement/LICENSE.txt b/lib/services/advisorManagement/LICENSE.txt index 0313a903d7..5431ba98b9 100644 --- a/lib/services/advisorManagement/LICENSE.txt +++ b/lib/services/advisorManagement/LICENSE.txt @@ -1,21 +1,21 @@ -The MIT License (MIT) - -Copyright (c) 2017 Microsoft - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +The MIT License (MIT) + +Copyright (c) 2018 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/lib/services/advisorManagement/README.md b/lib/services/advisorManagement/README.md index 44ca4f76e5..bfc069ad40 100644 --- a/lib/services/advisorManagement/README.md +++ b/lib/services/advisorManagement/README.md @@ -1,46 +1,41 @@ ---- -uid: azure-arm-advisor -summary: *content ---- - -# Microsoft Azure SDK for Node.js - AdvisorManagement - -This project provides a Node.js package for accessing Azure. Right now it supports: -- **Node.js version: 6.x.x or higher** -- **API version: 2017-04-19** - -## Features - - -## How to Install - -```bash -npm install azure-arm-advisor -``` - -## How to Use - -### Authentication, client creation and listing recommendations as an example - - ```javascript - const msRestAzure = require('ms-rest-azure'); - const advisorManagement = require("azure-arm-advisor"); - - // 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().then((credentials) => { - let client = new advisorManagement(credentials, 'your-subscription-id'); - client.recommendations.list().then((recommendations) => { - console.log('List of recommendations:'); - console.dir(recommendations, {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-advisor +summary: *content + +--- +# Microsoft Azure SDK for Node.js - AdvisorManagementClient +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-advisor +``` + +## How to use + +### Authentication, client creation and getGenerateRecommendationsStatus recommendations as an example. + +```javascript +const msRestAzure = require("ms-rest-azure"); +const AdvisorManagementClient = require("azure-arm-advisor"); +msRestAzure.interactiveLogin().then((creds) => { + const subscriptionId = ""; + const client = new AdvisorManagementClient(creds, subscriptionId); + const operationId = ec7b1657-199d-4d8a-bbb2-89a11a42e02a; + return client.recommendations.getGenerateRecommendationsStatus(operationId).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/advisorManagement/lib/advisorManagementClient.d.ts b/lib/services/advisorManagement/lib/advisorManagementClient.d.ts index 4a16869620..1a6006225a 100644 --- a/lib/services/advisorManagement/lib/advisorManagementClient.d.ts +++ b/lib/services/advisorManagement/lib/advisorManagementClient.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 AdvisorManagementClient extends AzureServiceClient { +export default class AdvisorManagementClient extends AzureServiceClient { /** * Initializes a new instance of the AdvisorManagementClient class. * @constructor @@ -60,4 +61,4 @@ declare class AdvisorManagementClient extends AzureServiceClient { suppressions: operations.Suppressions; } -export = AdvisorManagementClient; +export { AdvisorManagementClient, models as AdvisorManagementModels }; diff --git a/lib/services/advisorManagement/lib/advisorManagementClient.js b/lib/services/advisorManagement/lib/advisorManagementClient.js index b2446ec6d2..6e5b6bf62f 100644 --- a/lib/services/advisorManagement/lib/advisorManagementClient.js +++ b/lib/services/advisorManagement/lib/advisorManagementClient.js @@ -50,7 +50,7 @@ class AdvisorManagementClient extends ServiceClient { super(credentials, options); - this.apiVersion = '2017-04-19'; + this.apiVersion = '2018-01-02-preview'; this.acceptLanguage = 'en-US'; this.longRunningOperationRetryTimeout = 30; this.generateClientRequestId = true; @@ -82,3 +82,6 @@ class AdvisorManagementClient extends ServiceClient { } module.exports = AdvisorManagementClient; +module.exports['default'] = AdvisorManagementClient; +module.exports.AdvisorManagementClient = AdvisorManagementClient; +module.exports.AdvisorManagementModels = models; diff --git a/lib/services/advisorManagement/lib/models/index.d.ts b/lib/services/advisorManagement/lib/models/index.d.ts index 43ab355b43..f1c636056c 100644 --- a/lib/services/advisorManagement/lib/models/index.d.ts +++ b/lib/services/advisorManagement/lib/models/index.d.ts @@ -32,28 +32,15 @@ export interface ShortDescription { solution?: string; } -/** - * @class - * Initializes a new instance of the Resource class. - * @constructor - * An Azure resource. - * - * @member {string} [id] The resource ID. - * @member {string} [name] The name of the resource. - * @member {string} [type] The type of the resource. - */ -export interface Resource extends BaseResource { - readonly id?: string; - readonly name?: string; - readonly type?: string; -} - /** * @class * Initializes a new instance of the ResourceRecommendationBase class. * @constructor * Advisor Recommendation. * + * @member {string} [id] The fully qualified recommendation ID, for example + * /subscriptions/subscriptionId/resourceGroups/resourceGroup1/providers/Microsoft.ClassicCompute/virtualMachines/vm1/providers/Microsoft.Advisor/recommendations/recommendationGUID. + * @member {string} [name] The name of recommendation. * @member {string} [category] The category of the recommendation. Possible * values include: 'HighAvailability', 'Security', 'Performance', 'Cost' * @member {string} [impact] The business impact of the recommendation. @@ -73,8 +60,12 @@ export interface Resource extends BaseResource { * suggested by the recommendation. * @member {array} [suppressionIds] The list of snoozed and dismissed rules for * the recommendation. + * @member {string} [type] The recommendation type: + * Microsoft.Advisor/recommendations. */ -export interface ResourceRecommendationBase extends Resource { +export interface ResourceRecommendationBase { + id?: string; + name?: string; category?: string; impact?: string; impactedField?: string; @@ -85,6 +76,28 @@ export interface ResourceRecommendationBase extends Resource { risk?: string; shortDescription?: ShortDescription; suppressionIds?: string[]; + type?: string; +} + +/** + * @class + * Initializes a new instance of the Resource class. + * @constructor + * An Azure resource. + * + * @member {string} [id] The resource ID. + * @member {string} [name] The name of the resource. + * @member {string} [type] The type of the resource. + * @member {string} [location] The location of the resource. This cannot be + * changed after the resource is created. + * @member {object} [tags] The tags of the resource. + */ +export interface Resource extends BaseResource { + readonly id?: string; + readonly name?: string; + readonly type?: string; + location?: string; + tags?: { [propertyName: string]: string }; } /** @@ -167,16 +180,3 @@ export interface ResourceRecommendationBaseListResult extends Array { nextLink?: string; } - -/** - * @class - * Initializes a new instance of the SuppressionContractListResult class. - * @constructor - * The list of Advisor suppressions. - * - * @member {string} [nextLink] The link used to get the next page of - * suppressions. - */ -export interface SuppressionContractListResult extends Array { - nextLink?: string; -} diff --git a/lib/services/advisorManagement/lib/models/index.js b/lib/services/advisorManagement/lib/models/index.js index 579404b2f2..78ffddd23a 100644 --- a/lib/services/advisorManagement/lib/models/index.js +++ b/lib/services/advisorManagement/lib/models/index.js @@ -19,11 +19,10 @@ var msRestAzure = require('ms-rest-azure'); exports.BaseResource = msRestAzure.BaseResource; exports.CloudError = msRestAzure.CloudError; exports.ShortDescription = require('./shortDescription'); -exports.Resource = require('./resource'); exports.ResourceRecommendationBase = require('./resourceRecommendationBase'); +exports.Resource = require('./resource'); exports.OperationDisplayInfo = require('./operationDisplayInfo'); exports.OperationEntity = require('./operationEntity'); exports.SuppressionContract = require('./suppressionContract'); exports.ResourceRecommendationBaseListResult = require('./resourceRecommendationBaseListResult'); exports.OperationEntityListResult = require('./operationEntityListResult'); -exports.SuppressionContractListResult = require('./suppressionContractListResult'); diff --git a/lib/services/advisorManagement/lib/models/resource.js b/lib/services/advisorManagement/lib/models/resource.js index f8b004ac2b..b86be7eca0 100644 --- a/lib/services/advisorManagement/lib/models/resource.js +++ b/lib/services/advisorManagement/lib/models/resource.js @@ -23,6 +23,9 @@ class Resource extends models['BaseResource'] { * @member {string} [id] The resource ID. * @member {string} [name] The name of the resource. * @member {string} [type] The type of the resource. + * @member {string} [location] The location of the resource. This cannot be + * changed after the resource is created. + * @member {object} [tags] The tags of the resource. */ constructor() { super(); @@ -65,6 +68,27 @@ class Resource extends models['BaseResource'] { type: { name: 'String' } + }, + location: { + required: false, + serializedName: 'location', + type: { + name: 'String' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } } } } diff --git a/lib/services/advisorManagement/lib/models/resourceRecommendationBase.js b/lib/services/advisorManagement/lib/models/resourceRecommendationBase.js index fbd4187b82..df5f50cb03 100644 --- a/lib/services/advisorManagement/lib/models/resourceRecommendationBase.js +++ b/lib/services/advisorManagement/lib/models/resourceRecommendationBase.js @@ -15,11 +15,13 @@ const models = require('./index'); /** * Advisor Recommendation. * - * @extends models['Resource'] */ -class ResourceRecommendationBase extends models['Resource'] { +class ResourceRecommendationBase { /** * Create a ResourceRecommendationBase. + * @member {string} [id] The fully qualified recommendation ID, for example + * /subscriptions/subscriptionId/resourceGroups/resourceGroup1/providers/Microsoft.ClassicCompute/virtualMachines/vm1/providers/Microsoft.Advisor/recommendations/recommendationGUID. + * @member {string} [name] The name of recommendation. * @member {string} [category] The category of the recommendation. Possible * values include: 'HighAvailability', 'Security', 'Performance', 'Cost' * @member {string} [impact] The business impact of the recommendation. @@ -39,9 +41,10 @@ class ResourceRecommendationBase extends models['Resource'] { * suggested by the recommendation. * @member {array} [suppressionIds] The list of snoozed and dismissed rules * for the recommendation. + * @member {string} [type] The recommendation type: + * Microsoft.Advisor/recommendations. */ constructor() { - super(); } /** @@ -60,7 +63,6 @@ class ResourceRecommendationBase extends models['Resource'] { modelProperties: { id: { required: false, - readOnly: true, serializedName: 'id', type: { name: 'String' @@ -68,20 +70,11 @@ class ResourceRecommendationBase extends models['Resource'] { }, name: { required: false, - readOnly: true, serializedName: 'name', type: { name: 'String' } }, - type: { - required: false, - readOnly: true, - serializedName: 'type', - type: { - name: 'String' - } - }, category: { required: false, serializedName: 'properties.category', @@ -155,7 +148,7 @@ class ResourceRecommendationBase extends models['Resource'] { }, suppressionIds: { required: false, - serializedName: 'properties.suppressionIds', + serializedName: 'suppressionIds', type: { name: 'Sequence', element: { @@ -166,6 +159,13 @@ class ResourceRecommendationBase extends models['Resource'] { } } } + }, + type: { + required: false, + serializedName: 'type', + type: { + name: 'String' + } } } } diff --git a/lib/services/advisorManagement/lib/models/suppressionContract.js b/lib/services/advisorManagement/lib/models/suppressionContract.js index fb6854aa50..489359b476 100644 --- a/lib/services/advisorManagement/lib/models/suppressionContract.js +++ b/lib/services/advisorManagement/lib/models/suppressionContract.js @@ -66,16 +66,37 @@ class SuppressionContract extends models['Resource'] { name: 'String' } }, + location: { + required: false, + serializedName: 'location', + type: { + name: 'String' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, suppressionId: { required: false, - serializedName: 'properties.suppressionId', + serializedName: 'suppressionId', type: { name: 'String' } }, ttl: { required: false, - serializedName: 'properties.ttl', + serializedName: 'ttl', type: { name: 'String' } diff --git a/lib/services/advisorManagement/lib/operations/index.d.ts b/lib/services/advisorManagement/lib/operations/index.d.ts index c0fa07eb01..a2397131bb 100644 --- a/lib/services/advisorManagement/lib/operations/index.d.ts +++ b/lib/services/advisorManagement/lib/operations/index.d.ts @@ -94,7 +94,7 @@ export interface Recommendations { * * @reject {Error|ServiceError} - The error object. */ - getGenerateStatusWithHttpOperationResponse(operationId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + getGenerateRecommendationsStatusWithHttpOperationResponse(operationId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Retrieves the status of the recommendation computation or generation @@ -130,9 +130,9 @@ export interface Recommendations { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - getGenerateStatus(operationId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - getGenerateStatus(operationId: string, callback: ServiceCallback): void; - getGenerateStatus(operationId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + getGenerateRecommendationsStatus(operationId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getGenerateRecommendationsStatus(operationId: string, callback: ServiceCallback): void; + getGenerateRecommendationsStatus(operationId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -541,6 +541,11 @@ export interface Suppressions { * @param {string} [suppressionContract.ttl] The duration for which the * suppression is valid. * + * @param {string} [suppressionContract.location] The location of the resource. + * This cannot be changed after the resource is created. + * + * @param {object} [suppressionContract.tags] The tags of the resource. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -575,6 +580,11 @@ export interface Suppressions { * @param {string} [suppressionContract.ttl] The duration for which the * suppression is valid. * + * @param {string} [suppressionContract.location] The location of the resource. + * This cannot be changed after the resource is created. + * + * @param {object} [suppressionContract.tags] The tags of the resource. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -680,22 +690,16 @@ export interface Suppressions { * * @param {object} [options] Optional Parameters. * - * @param {number} [options.top] The number of suppressions per page if a paged - * version of this API is being used. - * - * @param {string} [options.skipToken] The page-continuation token to use with - * a paged version of this API. - * * @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?: { top? : number, skipToken? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + listWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Retrieves the list of snoozed or dismissed suppressions for a subscription. @@ -704,12 +708,6 @@ export interface Suppressions { * * @param {object} [options] Optional Parameters. * - * @param {number} [options.top] The number of suppressions per page if a paged - * version of this API is being used. - * - * @param {string} [options.skipToken] The page-continuation token to use with - * a paged version of this API. - * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -720,7 +718,7 @@ export interface Suppressions { * * {Promise} A promise is returned. * - * @resolve {SuppressionContractListResult} - The deserialized result object. + * @resolve {Array} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -728,77 +726,13 @@ export interface Suppressions { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {SuppressionContractListResult} [result] - The deserialized result object if an error did not occur. - * See {@link SuppressionContractListResult} for more - * information. - * - * {WebResource} [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?: { top? : number, skipToken? : string, customHeaders? : { [headerName: string]: string; } }): Promise; - list(callback: ServiceCallback): void; - list(options: { top? : number, skipToken? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * Retrieves the list of snoozed or dismissed suppressions for a subscription. - * The snoozed or dismissed attribute of a recommendation is referred to as a - * suppression. - * - * @param {string} nextPageLink The NextLink from 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>; - - /** - * Retrieves the list of snoozed or dismissed suppressions for a subscription. - * The snoozed or dismissed attribute of a recommendation is referred to as a - * suppression. - * - * @param {string} nextPageLink The NextLink from 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 {SuppressionContractListResult} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {SuppressionContractListResult} [result] - The deserialized result object if an error did not occur. - * See {@link SuppressionContractListResult} for more - * information. + * {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. */ - 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?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } diff --git a/lib/services/advisorManagement/lib/operations/recommendations.js b/lib/services/advisorManagement/lib/operations/recommendations.js index 3393e82775..260082169c 100644 --- a/lib/services/advisorManagement/lib/operations/recommendations.js +++ b/lib/services/advisorManagement/lib/operations/recommendations.js @@ -156,7 +156,7 @@ function _generate(options, callback) { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _getGenerateStatus(operationId, options, callback) { +function _getGenerateRecommendationsStatus(operationId, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -700,7 +700,7 @@ class Recommendations { constructor(client) { this.client = client; this._generate = _generate; - this._getGenerateStatus = _getGenerateStatus; + this._getGenerateRecommendationsStatus = _getGenerateRecommendationsStatus; this._list = _list; this._get = _get; this._listNext = _listNext; @@ -806,11 +806,11 @@ class Recommendations { * * @reject {Error} - The error object. */ - getGenerateStatusWithHttpOperationResponse(operationId, options) { + getGenerateRecommendationsStatusWithHttpOperationResponse(operationId, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._getGenerateStatus(operationId, options, (err, result, request, response) => { + self._getGenerateRecommendationsStatus(operationId, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -854,7 +854,7 @@ class Recommendations { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - getGenerateStatus(operationId, options, optionalCallback) { + getGenerateRecommendationsStatus(operationId, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -863,14 +863,14 @@ class Recommendations { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._getGenerateStatus(operationId, options, (err, result, request, response) => { + self._getGenerateRecommendationsStatus(operationId, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._getGenerateStatus(operationId, options, optionalCallback); + return self._getGenerateRecommendationsStatus(operationId, options, optionalCallback); } } diff --git a/lib/services/advisorManagement/lib/operations/suppressions.js b/lib/services/advisorManagement/lib/operations/suppressions.js index ecfcaaff3e..8209f0e227 100644 --- a/lib/services/advisorManagement/lib/operations/suppressions.js +++ b/lib/services/advisorManagement/lib/operations/suppressions.js @@ -183,6 +183,11 @@ function _get(resourceUri, recommendationId, name, options, callback) { * @param {string} [suppressionContract.ttl] The duration for which the * suppression is valid. * + * @param {string} [suppressionContract.location] The location of the resource. + * This cannot be changed after the resource is created. + * + * @param {object} [suppressionContract.tags] The tags of the resource. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -476,12 +481,6 @@ function _deleteMethod(resourceUri, recommendationId, name, options, callback) { * * @param {object} [options] Optional Parameters. * - * @param {number} [options.top] The number of suppressions per page if a paged - * version of this API is being used. - * - * @param {string} [options.skipToken] The page-continuation token to use with - * a paged version of this API. - * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -491,9 +490,7 @@ function _deleteMethod(resourceUri, recommendationId, name, options, callback) { * * {Error} err - The Error object if an error occurred, null otherwise. * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link SuppressionContractListResult} 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. * @@ -509,8 +506,6 @@ function _list(options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } - let top = (options && options.top !== undefined) ? options.top : undefined; - let skipToken = (options && options.skipToken !== undefined) ? options.skipToken : undefined; // Validate try { if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { @@ -519,12 +514,6 @@ function _list(options, callback) { 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 (top !== null && top !== undefined && typeof top !== 'number') { - throw new Error('top must be of type number.'); - } - if (skipToken !== null && skipToken !== undefined && typeof skipToken.valueOf() !== 'string') { - throw new Error('skipToken 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.'); } @@ -538,12 +527,6 @@ function _list(options, callback) { requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); let queryParameters = []; queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); - if (top !== null && top !== undefined) { - queryParameters.push('$top=' + encodeURIComponent(top.toString())); - } - if (skipToken !== null && skipToken !== undefined) { - queryParameters.push('$skipToken=' + encodeURIComponent(skipToken)); - } if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); } @@ -610,137 +593,21 @@ function _list(options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['SuppressionContractListResult']().mapper(); - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let 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); - }); -} - -/** - * Retrieves the list of snoozed or dismissed suppressions for a subscription. - * The snoozed or dismissed attribute of a recommendation is referred to as a - * suppression. - * - * @param {string} nextPageLink The NextLink from 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 SuppressionContractListResult} for more - * information. - * - * {object} [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) { - 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['SuppressionContractListResult']().mapper(); + let resultMapper = { + required: false, + serializedName: 'parsedResponse', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'SuppressionContractElementType', + type: { + name: 'Composite', + className: 'SuppressionContract' + } + } + } + }; result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -767,7 +634,6 @@ class Suppressions { this._create = _create; this._deleteMethod = _deleteMethod; this._list = _list; - this._listNext = _listNext; } /** @@ -883,6 +749,11 @@ class Suppressions { * @param {string} [suppressionContract.ttl] The duration for which the * suppression is valid. * + * @param {string} [suppressionContract.location] The location of the resource. + * This cannot be changed after the resource is created. + * + * @param {object} [suppressionContract.tags] The tags of the resource. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -929,6 +800,11 @@ class Suppressions { * @param {string} [suppressionContract.ttl] The duration for which the * suppression is valid. * + * @param {string} [suppressionContract.location] The location of the resource. + * This cannot be changed after the resource is created. + * + * @param {object} [suppressionContract.tags] The tags of the resource. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -1076,18 +952,12 @@ class Suppressions { * * @param {object} [options] Optional Parameters. * - * @param {number} [options.top] The number of suppressions per page if a paged - * version of this API is being used. - * - * @param {string} [options.skipToken] The page-continuation token to use with - * a paged version of this API. - * * @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} - The error object. */ @@ -1112,12 +982,6 @@ class Suppressions { * * @param {object} [options] Optional Parameters. * - * @param {number} [options.top] The number of suppressions per page if a paged - * version of this API is being used. - * - * @param {string} [options.skipToken] The page-continuation token to use with - * a paged version of this API. - * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -1128,7 +992,7 @@ class Suppressions { * * {Promise} A promise is returned * - * @resolve {SuppressionContractListResult} - The deserialized result object. + * @resolve {Array} - The deserialized result object. * * @reject {Error} - The error object. * @@ -1136,9 +1000,7 @@ class Suppressions { * * {Error} err - The Error object if an error occurred, null otherwise. * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link SuppressionContractListResult} 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. * @@ -1164,95 +1026,6 @@ class Suppressions { } } - /** - * Retrieves the list of snoozed or dismissed suppressions for a subscription. - * The snoozed or dismissed attribute of a recommendation is referred to as a - * suppression. - * - * @param {string} nextPageLink The NextLink from 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; - }); - }); - } - - /** - * Retrieves the list of snoozed or dismissed suppressions for a subscription. - * The snoozed or dismissed attribute of a recommendation is referred to as a - * suppression. - * - * @param {string} nextPageLink The NextLink from 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 {SuppressionContractListResult} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link SuppressionContractListResult} for more - * information. - * - * {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 = Suppressions; diff --git a/lib/services/advisorManagement/package.json b/lib/services/advisorManagement/package.json index 0d3b9a14c1..579e4fa22a 100644 --- a/lib/services/advisorManagement/package.json +++ b/lib/services/advisorManagement/package.json @@ -1,33 +1,25 @@ { "name": "azure-arm-advisor", "author": "Microsoft Corporation", - "contributors": [ - "Krishnan, Balaji ", - "Zavery, Amar