diff --git a/lib/services/applicationinsights/lib/applicationInsightsManagementClient.d.ts b/lib/services/applicationinsights/lib/applicationInsightsManagementClient.d.ts index 5503502dc0..09b7516202 100644 --- a/lib/services/applicationinsights/lib/applicationInsightsManagementClient.d.ts +++ b/lib/services/applicationinsights/lib/applicationInsightsManagementClient.d.ts @@ -68,12 +68,10 @@ export default class ApplicationInsightsManagementClient extends AzureServiceCli components: operations.Components; workItemConfigurations: operations.WorkItemConfigurations; favorites: operations.Favorites; - favorite: operations.Favorite; webTestLocations: operations.WebTestLocations; webTests: operations.WebTests; - analyticsItem: operations.AnalyticsItem; - workbooksOperations: operations.WorkbooksOperations; - workbookOperations: operations.WorkbookOperations; + analyticsItems: operations.AnalyticsItems; + workbooks: operations.Workbooks; } export { ApplicationInsightsManagementClient, models as ApplicationInsightsManagementModels }; diff --git a/lib/services/applicationinsights/lib/applicationInsightsManagementClient.js b/lib/services/applicationinsights/lib/applicationInsightsManagementClient.js index c4599eeba5..796c4092f0 100644 --- a/lib/services/applicationinsights/lib/applicationInsightsManagementClient.js +++ b/lib/services/applicationinsights/lib/applicationInsightsManagementClient.js @@ -84,12 +84,10 @@ class ApplicationInsightsManagementClient extends ServiceClient { this.components = new operations.Components(this); this.workItemConfigurations = new operations.WorkItemConfigurations(this); this.favorites = new operations.Favorites(this); - this.favorite = new operations.Favorite(this); this.webTestLocations = new operations.WebTestLocations(this); this.webTests = new operations.WebTests(this); - this.analyticsItem = new operations.AnalyticsItem(this); - this.workbooksOperations = new operations.WorkbooksOperations(this); - this.workbookOperations = new operations.WorkbookOperations(this); + this.analyticsItems = new operations.AnalyticsItems(this); + this.workbooks = new operations.Workbooks(this); this.models = models; msRest.addSerializationMixin(this); } diff --git a/lib/services/applicationinsights/lib/models/annotationsListResult.js b/lib/services/applicationinsights/lib/models/annotationsListResult.js new file mode 100644 index 0000000000..89f89db324 --- /dev/null +++ b/lib/services/applicationinsights/lib/models/annotationsListResult.js @@ -0,0 +1,60 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Annotations list result. + */ +class AnnotationsListResult extends Array { + /** + * Create a AnnotationsListResult. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of AnnotationsListResult + * + * @returns {object} metadata of AnnotationsListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'AnnotationsListResult', + type: { + name: 'Composite', + className: 'AnnotationsListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'AnnotationElementType', + type: { + name: 'Composite', + className: 'Annotation' + } + } + } + } + } + } + }; + } +} + +module.exports = AnnotationsListResult; diff --git a/lib/services/applicationinsights/lib/models/applicationInsightsComponent.js b/lib/services/applicationinsights/lib/models/applicationInsightsComponent.js index d6271996d3..d3de08e49d 100644 --- a/lib/services/applicationinsights/lib/models/applicationInsightsComponent.js +++ b/lib/services/applicationinsights/lib/models/applicationInsightsComponent.js @@ -15,9 +15,9 @@ const models = require('./index'); /** * An Application Insights component definition. * - * @extends models['Resource'] + * @extends models['ComponentsResource'] */ -class ApplicationInsightsComponent extends models['Resource'] { +class ApplicationInsightsComponent extends models['ComponentsResource'] { /** * Create a ApplicationInsightsComponent. * @member {string} kind The kind of application that this component refers diff --git a/lib/services/applicationinsights/lib/models/componentPurgeStatusResponse.js b/lib/services/applicationinsights/lib/models/componentPurgeStatusResponse.js index 47b5b6ec49..e80fa6469c 100644 --- a/lib/services/applicationinsights/lib/models/componentPurgeStatusResponse.js +++ b/lib/services/applicationinsights/lib/models/componentPurgeStatusResponse.js @@ -18,7 +18,7 @@ class ComponentPurgeStatusResponse { /** * Create a ComponentPurgeStatusResponse. * @member {string} status Status of the operation represented by the - * requested Id. Possible values include: 'Pending', 'Completed' + * requested Id. Possible values include: 'pending', 'completed' */ constructor() { } diff --git a/lib/services/applicationinsights/lib/models/componentsResource.js b/lib/services/applicationinsights/lib/models/componentsResource.js new file mode 100644 index 0000000000..c61e1baf14 --- /dev/null +++ b/lib/services/applicationinsights/lib/models/componentsResource.js @@ -0,0 +1,98 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * An azure resource object + * + * @extends models['BaseResource'] + */ +class ComponentsResource extends models['BaseResource'] { + /** + * Create a ComponentsResource. + * @member {string} [id] Azure resource Id + * @member {string} [name] Azure resource name + * @member {string} [type] Azure resource type + * @member {string} location Resource location + * @member {object} [tags] Resource tags + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ComponentsResource + * + * @returns {object} metadata of ComponentsResource + * + */ + mapper() { + return { + required: false, + serializedName: 'ComponentsResource', + type: { + name: 'Composite', + className: 'ComponentsResource', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + location: { + required: true, + serializedName: 'location', + type: { + name: 'String' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = ComponentsResource; diff --git a/lib/services/applicationinsights/lib/models/index.d.ts b/lib/services/applicationinsights/lib/models/index.d.ts index 6c20629a56..2e33a87dc4 100644 --- a/lib/services/applicationinsights/lib/models/index.d.ts +++ b/lib/services/applicationinsights/lib/models/index.d.ts @@ -533,7 +533,7 @@ export interface ApplicationInsightsComponentProactiveDetectionConfiguration ext /** * @class - * Initializes a new instance of the Resource class. + * Initializes a new instance of the ComponentsResource class. * @constructor * An azure resource object * @@ -543,7 +543,7 @@ export interface ApplicationInsightsComponentProactiveDetectionConfiguration ext * @member {string} location Resource location * @member {object} [tags] Resource tags */ -export interface Resource extends BaseResource { +export interface ComponentsResource extends BaseResource { readonly id?: string; readonly name?: string; readonly type?: string; @@ -605,7 +605,7 @@ export interface TagsResource { * application being monitored that is being sampled for Application Insights * telemetry. */ -export interface ApplicationInsightsComponent extends Resource { +export interface ApplicationInsightsComponent extends ComponentsResource { kind: string; readonly applicationId?: string; readonly appId?: string; @@ -676,7 +676,7 @@ export interface ComponentPurgeResponse { * Response containing status for a specific purge operation. * * @member {string} status Status of the operation represented by the requested - * Id. Possible values include: 'Pending', 'Completed' + * Id. Possible values include: 'pending', 'completed' */ export interface ComponentPurgeStatusResponse { status: string; @@ -805,6 +805,26 @@ export interface ApplicationInsightsComponentWebTestLocation { readonly tag?: string; } +/** + * @class + * Initializes a new instance of the WebtestsResource class. + * @constructor + * An azure resource object + * + * @member {string} [id] Azure resource Id + * @member {string} [name] Azure resource name + * @member {string} [type] Azure resource type + * @member {string} location Resource location + * @member {object} [tags] Resource tags + */ +export interface WebtestsResource extends BaseResource { + readonly id?: string; + readonly name?: string; + readonly type?: string; + location: string; + tags?: { [propertyName: string]: string }; +} + /** * @class * Initializes a new instance of the WebTestGeolocation class. @@ -865,7 +885,7 @@ export interface WebTestPropertiesConfiguration { * defined. Users cannot change this value but are able to read from it. Values * will include Succeeded, Deploying, Canceled, and Failed. */ -export interface WebTest extends Resource { +export interface WebTest extends WebtestsResource { kind?: string; syntheticMonitorId: string; webTestName: string; @@ -931,6 +951,26 @@ export interface ApplicationInsightsComponentAnalyticsItem { properties?: ApplicationInsightsComponentAnalyticsItemProperties; } +/** + * @class + * Initializes a new instance of the WorkbookResource class. + * @constructor + * An azure resource object + * + * @member {string} [id] Azure resource Id + * @member {string} [name] Azure resource name + * @member {string} [type] Azure resource type + * @member {string} [location] Resource location + * @member {object} [tags] Resource tags + */ +export interface WorkbookResource extends BaseResource { + readonly id?: string; + readonly name?: string; + readonly type?: string; + location?: string; + tags?: { [propertyName: string]: string }; +} + /** * @class * Initializes a new instance of the Workbook class. @@ -961,7 +1001,7 @@ export interface ApplicationInsightsComponentAnalyticsItem { * @member {string} [sourceResourceId] Optional resourceId for a source * resource. */ -export interface Workbook extends Resource { +export interface Workbook extends WorkbookResource { kind?: string; workbookName: string; serializedData: string; @@ -975,18 +1015,6 @@ export interface Workbook extends Resource { sourceResourceId?: string; } -/** - * @class - * Initializes a new instance of the Workbooks class. - * @constructor - * Workbook list result. - * - * @member {array} [value] An array of workbooks. - */ -export interface Workbooks { - value?: Workbook[]; -} - /** * @class * Initializes a new instance of the LinkProperties class. @@ -1053,6 +1081,16 @@ export interface OperationListResult extends Array { nextLink?: string; } +/** + * @class + * Initializes a new instance of the AnnotationsListResult class. + * @constructor + * Annotations list result. + * + */ +export interface AnnotationsListResult extends Array { +} + /** * @class * Initializes a new instance of the ApplicationInsightsComponentAPIKeyListResult class. @@ -1077,6 +1115,16 @@ export interface ApplicationInsightsComponentListResult extends Array { +} + /** * @class * Initializes a new instance of the ApplicationInsightsWebTestLocationsListResult class. @@ -1101,3 +1149,13 @@ export interface ApplicationInsightsWebTestLocationsListResult extends Array { nextLink?: string; } + +/** + * @class + * Initializes a new instance of the WorkbooksListResult class. + * @constructor + * Workbook list result. + * + */ +export interface WorkbooksListResult extends Array { +} diff --git a/lib/services/applicationinsights/lib/models/index.js b/lib/services/applicationinsights/lib/models/index.js index 61b83d139e..155639f1bd 100644 --- a/lib/services/applicationinsights/lib/models/index.js +++ b/lib/services/applicationinsights/lib/models/index.js @@ -37,7 +37,7 @@ exports.ApplicationInsightsComponentFeature = require('./applicationInsightsComp exports.ApplicationInsightsComponentAvailableFeatures = require('./applicationInsightsComponentAvailableFeatures'); exports.ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions = require('./applicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions'); exports.ApplicationInsightsComponentProactiveDetectionConfiguration = require('./applicationInsightsComponentProactiveDetectionConfiguration'); -exports.Resource = require('./resource'); +exports.ComponentsResource = require('./componentsResource'); exports.TagsResource = require('./tagsResource'); exports.ApplicationInsightsComponent = require('./applicationInsightsComponent'); exports.ComponentPurgeBodyFilters = require('./componentPurgeBodyFilters'); @@ -49,18 +49,22 @@ exports.WorkItemCreateConfiguration = require('./workItemCreateConfiguration'); exports.WorkItemConfigurationError = require('./workItemConfigurationError'); exports.ApplicationInsightsComponentFavorite = require('./applicationInsightsComponentFavorite'); exports.ApplicationInsightsComponentWebTestLocation = require('./applicationInsightsComponentWebTestLocation'); +exports.WebtestsResource = require('./webtestsResource'); exports.WebTestGeolocation = require('./webTestGeolocation'); exports.WebTestPropertiesConfiguration = require('./webTestPropertiesConfiguration'); exports.WebTest = require('./webTest'); exports.ApplicationInsightsComponentAnalyticsItemProperties = require('./applicationInsightsComponentAnalyticsItemProperties'); exports.ApplicationInsightsComponentAnalyticsItem = require('./applicationInsightsComponentAnalyticsItem'); +exports.WorkbookResource = require('./workbookResource'); exports.Workbook = require('./workbook'); -exports.Workbooks = require('./workbooks'); exports.LinkProperties = require('./linkProperties'); exports.ErrorFieldContract = require('./errorFieldContract'); exports.WorkbookError = require('./workbookError'); exports.OperationListResult = require('./operationListResult'); +exports.AnnotationsListResult = require('./annotationsListResult'); exports.ApplicationInsightsComponentAPIKeyListResult = require('./applicationInsightsComponentAPIKeyListResult'); exports.ApplicationInsightsComponentListResult = require('./applicationInsightsComponentListResult'); +exports.WorkItemConfigurationsListResult = require('./workItemConfigurationsListResult'); exports.ApplicationInsightsWebTestLocationsListResult = require('./applicationInsightsWebTestLocationsListResult'); exports.WebTestListResult = require('./webTestListResult'); +exports.WorkbooksListResult = require('./workbooksListResult'); diff --git a/lib/services/applicationinsights/lib/models/webTest.js b/lib/services/applicationinsights/lib/models/webTest.js index 4a980abf98..8b9cda8aad 100644 --- a/lib/services/applicationinsights/lib/models/webTest.js +++ b/lib/services/applicationinsights/lib/models/webTest.js @@ -15,9 +15,9 @@ const models = require('./index'); /** * An Application Insights web test definition. * - * @extends models['Resource'] + * @extends models['WebtestsResource'] */ -class WebTest extends models['Resource'] { +class WebTest extends models['WebtestsResource'] { /** * Create a WebTest. * @member {string} [kind] The kind of web test that this web test watches. diff --git a/lib/services/applicationinsights/lib/models/webtestsResource.js b/lib/services/applicationinsights/lib/models/webtestsResource.js new file mode 100644 index 0000000000..0eb20b5a51 --- /dev/null +++ b/lib/services/applicationinsights/lib/models/webtestsResource.js @@ -0,0 +1,98 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * An azure resource object + * + * @extends models['BaseResource'] + */ +class WebtestsResource extends models['BaseResource'] { + /** + * Create a WebtestsResource. + * @member {string} [id] Azure resource Id + * @member {string} [name] Azure resource name + * @member {string} [type] Azure resource type + * @member {string} location Resource location + * @member {object} [tags] Resource tags + */ + constructor() { + super(); + } + + /** + * Defines the metadata of WebtestsResource + * + * @returns {object} metadata of WebtestsResource + * + */ + mapper() { + return { + required: false, + serializedName: 'WebtestsResource', + type: { + name: 'Composite', + className: 'WebtestsResource', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + location: { + required: true, + serializedName: 'location', + type: { + name: 'String' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = WebtestsResource; diff --git a/lib/services/applicationinsights/lib/models/workItemConfigurationsListResult.js b/lib/services/applicationinsights/lib/models/workItemConfigurationsListResult.js new file mode 100644 index 0000000000..2bfd00bdb6 --- /dev/null +++ b/lib/services/applicationinsights/lib/models/workItemConfigurationsListResult.js @@ -0,0 +1,60 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Work item configuration list result. + */ +class WorkItemConfigurationsListResult extends Array { + /** + * Create a WorkItemConfigurationsListResult. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of WorkItemConfigurationsListResult + * + * @returns {object} metadata of WorkItemConfigurationsListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'WorkItemConfigurationsListResult', + type: { + name: 'Composite', + className: 'WorkItemConfigurationsListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'WorkItemConfigurationElementType', + type: { + name: 'Composite', + className: 'WorkItemConfiguration' + } + } + } + } + } + } + }; + } +} + +module.exports = WorkItemConfigurationsListResult; diff --git a/lib/services/applicationinsights/lib/models/workbook.js b/lib/services/applicationinsights/lib/models/workbook.js index 1cfb66657d..3ae9e0b443 100644 --- a/lib/services/applicationinsights/lib/models/workbook.js +++ b/lib/services/applicationinsights/lib/models/workbook.js @@ -15,9 +15,9 @@ const models = require('./index'); /** * An Application Insights workbook definition. * - * @extends models['Resource'] + * @extends models['WorkbookResource'] */ -class Workbook extends models['Resource'] { +class Workbook extends models['WorkbookResource'] { /** * Create a Workbook. * @member {string} [kind] The kind of workbook. Choices are user and shared. @@ -87,7 +87,7 @@ class Workbook extends models['Resource'] { } }, location: { - required: true, + required: false, serializedName: 'location', type: { name: 'String' diff --git a/lib/services/applicationinsights/lib/models/workbookResource.js b/lib/services/applicationinsights/lib/models/workbookResource.js new file mode 100644 index 0000000000..55a6f802c2 --- /dev/null +++ b/lib/services/applicationinsights/lib/models/workbookResource.js @@ -0,0 +1,98 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * An azure resource object + * + * @extends models['BaseResource'] + */ +class WorkbookResource extends models['BaseResource'] { + /** + * Create a WorkbookResource. + * @member {string} [id] Azure resource Id + * @member {string} [name] Azure resource name + * @member {string} [type] Azure resource type + * @member {string} [location] Resource location + * @member {object} [tags] Resource tags + */ + constructor() { + super(); + } + + /** + * Defines the metadata of WorkbookResource + * + * @returns {object} metadata of WorkbookResource + * + */ + mapper() { + return { + required: false, + serializedName: 'WorkbookResource', + type: { + name: 'Composite', + className: 'WorkbookResource', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + location: { + required: false, + serializedName: 'location', + type: { + name: 'String' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = WorkbookResource; diff --git a/lib/services/applicationinsights/lib/models/workbooksListResult.js b/lib/services/applicationinsights/lib/models/workbooksListResult.js new file mode 100644 index 0000000000..46e10a4041 --- /dev/null +++ b/lib/services/applicationinsights/lib/models/workbooksListResult.js @@ -0,0 +1,60 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Workbook list result. + */ +class WorkbooksListResult extends Array { + /** + * Create a WorkbooksListResult. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of WorkbooksListResult + * + * @returns {object} metadata of WorkbooksListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'WorkbooksListResult', + type: { + name: 'Composite', + className: 'WorkbooksListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'WorkbookElementType', + type: { + name: 'Composite', + className: 'Workbook' + } + } + } + } + } + } + }; + } +} + +module.exports = WorkbooksListResult; diff --git a/lib/services/applicationinsights/lib/operations/analyticsItems.js b/lib/services/applicationinsights/lib/operations/analyticsItems.js new file mode 100644 index 0000000000..8eb571855d --- /dev/null +++ b/lib/services/applicationinsights/lib/operations/analyticsItems.js @@ -0,0 +1,1280 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets a list of Analytics Items defined within an Application Insights + * component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} scopePath Enum indicating if this item definition is owned + * by a specific user or is shared between all users with access to the + * Application Insights component. Possible values include: 'analyticsItems', + * 'myanalyticsItems' + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.scope] Enum indicating if this item definition is + * owned by a specific user or is shared between all users with access to the + * Application Insights component. Possible values include: 'shared', 'user' + * + * @param {string} [options.type] Enum indicating the type of the Analytics + * item. Possible values include: 'none', 'query', 'function', 'folder', + * 'recent' + * + * @param {boolean} [options.includeContent] Flag indicating whether or not to + * return the content of each applicable item. If false, only return the item + * information. + * + * @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(resourceGroupName, resourceName, scopePath, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let scope = (options && options.scope !== undefined) ? options.scope : 'shared'; + let type = (options && options.type !== undefined) ? options.type : 'none'; + let includeContent = (options && options.includeContent !== undefined) ? options.includeContent : undefined; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (resourceName === null || resourceName === undefined || typeof resourceName.valueOf() !== 'string') { + throw new Error('resourceName cannot be null or undefined and it must be of type string.'); + } + if (scopePath === null || scopePath === undefined || typeof scopePath.valueOf() !== 'string') { + throw new Error('scopePath cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (scope !== null && scope !== undefined && typeof scope.valueOf() !== 'string') { + throw new Error('scope must be of type string.'); + } + if (type !== null && type !== undefined && typeof type.valueOf() !== 'string') { + throw new Error('type must be of type string.'); + } + if (includeContent !== null && includeContent !== undefined && typeof includeContent !== 'boolean') { + throw new Error('includeContent must be of type boolean.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); + requestUrl = requestUrl.replace('{scopePath}', encodeURIComponent(scopePath)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (scope !== null && scope !== undefined) { + queryParameters.push('scope=' + encodeURIComponent(scope)); + } + if (type !== null && type !== undefined) { + queryParameters.push('type=' + encodeURIComponent(type)); + } + if (includeContent !== null && includeContent !== undefined) { + queryParameters.push('includeContent=' + encodeURIComponent(includeContent.toString())); + } + 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: 'ApplicationInsightsComponentAnalyticsItemElementType', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentAnalyticsItem' + } + } + } + }; + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets a specific Analytics Items defined within an Application Insights + * component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} scopePath Enum indicating if this item definition is owned + * by a specific user or is shared between all users with access to the + * Application Insights component. Possible values include: 'analyticsItems', + * 'myanalyticsItems' + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.id] The Id of a specific item defined in the + * Application Insights component + * + * @param {string} [options.name] The name of a specific item defined in the + * Application Insights component + * + * @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 ApplicationInsightsComponentAnalyticsItem} + * for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, resourceName, scopePath, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let id = (options && options.id !== undefined) ? options.id : undefined; + let name = (options && options.name !== undefined) ? options.name : undefined; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (resourceName === null || resourceName === undefined || typeof resourceName.valueOf() !== 'string') { + throw new Error('resourceName cannot be null or undefined and it must be of type string.'); + } + if (scopePath === null || scopePath === undefined || typeof scopePath.valueOf() !== 'string') { + throw new Error('scopePath cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (id !== null && id !== undefined && typeof id.valueOf() !== 'string') { + throw new Error('id must be of type string.'); + } + if (name !== null && name !== undefined && typeof name.valueOf() !== 'string') { + throw new Error('name must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); + requestUrl = requestUrl.replace('{scopePath}', encodeURIComponent(scopePath)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (id !== null && id !== undefined) { + queryParameters.push('id=' + encodeURIComponent(id)); + } + if (name !== null && name !== undefined) { + queryParameters.push('name=' + encodeURIComponent(name)); + } + 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['ApplicationInsightsComponentAnalyticsItem']().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); + }); +} + +/** + * Adds or Updates a specific Analytics Item within an Application Insights + * component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} scopePath Enum indicating if this item definition is owned + * by a specific user or is shared between all users with access to the + * Application Insights component. Possible values include: 'analyticsItems', + * 'myanalyticsItems' + * + * @param {object} itemProperties Properties that need to be specified to + * create a new item and add it to an Application Insights component. + * + * @param {string} [itemProperties.id] Internally assigned unique id of the + * item definition. + * + * @param {string} [itemProperties.name] The user-defined name of the item. + * + * @param {string} [itemProperties.content] The content of this item + * + * @param {string} [itemProperties.scope] Enum indicating if this item + * definition is owned by a specific user or is shared between all users with + * access to the Application Insights component. Possible values include: + * 'shared', 'user' + * + * @param {string} [itemProperties.type] Enum indicating the type of the + * Analytics item. Possible values include: 'query', 'function', 'folder', + * 'recent' + * + * @param {object} [itemProperties.properties] + * + * @param {string} [itemProperties.properties.functionAlias] A function alias, + * used when the type of the item is Function + * + * @param {object} [options] Optional Parameters. + * + * @param {boolean} [options.overrideItem] Flag indicating whether or not to + * force save an item. This allows overriding an item if it already exists. + * + * @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 ApplicationInsightsComponentAnalyticsItem} + * for more information. + * + * {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 _put(resourceGroupName, resourceName, scopePath, itemProperties, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let overrideItem = (options && options.overrideItem !== undefined) ? options.overrideItem : undefined; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (resourceName === null || resourceName === undefined || typeof resourceName.valueOf() !== 'string') { + throw new Error('resourceName cannot be null or undefined and it must be of type string.'); + } + if (scopePath === null || scopePath === undefined || typeof scopePath.valueOf() !== 'string') { + throw new Error('scopePath cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (overrideItem !== null && overrideItem !== undefined && typeof overrideItem !== 'boolean') { + throw new Error('overrideItem must be of type boolean.'); + } + if (itemProperties === null || itemProperties === undefined) { + throw new Error('itemProperties cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); + requestUrl = requestUrl.replace('{scopePath}', encodeURIComponent(scopePath)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (overrideItem !== null && overrideItem !== undefined) { + queryParameters.push('overrideItem=' + encodeURIComponent(overrideItem.toString())); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (itemProperties !== null && itemProperties !== undefined) { + let requestModelMapper = new client.models['ApplicationInsightsComponentAnalyticsItem']().mapper(); + requestModel = client.serialize(requestModelMapper, itemProperties, 'itemProperties'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(itemProperties, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['ApplicationInsightsComponentAnalyticsItem']().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); + }); +} + +/** + * Deletes a specific Analytics Items defined within an Application Insights + * component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} scopePath Enum indicating if this item definition is owned + * by a specific user or is shared between all users with access to the + * Application Insights component. Possible values include: 'analyticsItems', + * 'myanalyticsItems' + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.id] The Id of a specific item defined in the + * Application Insights component + * + * @param {string} [options.name] The name of a specific item defined in the + * Application Insights component + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(resourceGroupName, resourceName, scopePath, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let id = (options && options.id !== undefined) ? options.id : undefined; + let name = (options && options.name !== undefined) ? options.name : undefined; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (resourceName === null || resourceName === undefined || typeof resourceName.valueOf() !== 'string') { + throw new Error('resourceName cannot be null or undefined and it must be of type string.'); + } + if (scopePath === null || scopePath === undefined || typeof scopePath.valueOf() !== 'string') { + throw new Error('scopePath cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (id !== null && id !== undefined && typeof id.valueOf() !== 'string') { + throw new Error('id must be of type string.'); + } + if (name !== null && name !== undefined && typeof name.valueOf() !== 'string') { + throw new Error('name must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); + requestUrl = requestUrl.replace('{scopePath}', encodeURIComponent(scopePath)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (id !== null && id !== undefined) { + queryParameters.push('id=' + encodeURIComponent(id)); + } + if (name !== null && name !== undefined) { + queryParameters.push('name=' + encodeURIComponent(name)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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; + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a AnalyticsItems. */ +class AnalyticsItems { + /** + * Create a AnalyticsItems. + * @param {ApplicationInsightsManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._get = _get; + this._put = _put; + this._deleteMethod = _deleteMethod; + } + + /** + * Gets a list of Analytics Items defined within an Application Insights + * component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} scopePath Enum indicating if this item definition is owned + * by a specific user or is shared between all users with access to the + * Application Insights component. Possible values include: 'analyticsItems', + * 'myanalyticsItems' + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.scope] Enum indicating if this item definition is + * owned by a specific user or is shared between all users with access to the + * Application Insights component. Possible values include: 'shared', 'user' + * + * @param {string} [options.type] Enum indicating the type of the Analytics + * item. Possible values include: 'none', 'query', 'function', 'folder', + * 'recent' + * + * @param {boolean} [options.includeContent] Flag indicating whether or not to + * return the content of each applicable item. If false, only return the item + * information. + * + * @param {object} [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(resourceGroupName, resourceName, scopePath, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(resourceGroupName, resourceName, scopePath, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a list of Analytics Items defined within an Application Insights + * component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} scopePath Enum indicating if this item definition is owned + * by a specific user or is shared between all users with access to the + * Application Insights component. Possible values include: 'analyticsItems', + * 'myanalyticsItems' + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.scope] Enum indicating if this item definition is + * owned by a specific user or is shared between all users with access to the + * Application Insights component. Possible values include: 'shared', 'user' + * + * @param {string} [options.type] Enum indicating the type of the Analytics + * item. Possible values include: 'none', 'query', 'function', 'folder', + * 'recent' + * + * @param {boolean} [options.includeContent] Flag indicating whether or not to + * return the content of each applicable item. If false, only return the item + * information. + * + * @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 {Array} - 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. + * + * {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. + */ + list(resourceGroupName, resourceName, scopePath, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(resourceGroupName, resourceName, scopePath, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(resourceGroupName, resourceName, scopePath, options, optionalCallback); + } + } + + /** + * Gets a specific Analytics Items defined within an Application Insights + * component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} scopePath Enum indicating if this item definition is owned + * by a specific user or is shared between all users with access to the + * Application Insights component. Possible values include: 'analyticsItems', + * 'myanalyticsItems' + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.id] The Id of a specific item defined in the + * Application Insights component + * + * @param {string} [options.name] The name of a specific item defined in the + * Application Insights component + * + * @param {object} [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(resourceGroupName, resourceName, scopePath, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, resourceName, scopePath, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a specific Analytics Items defined within an Application Insights + * component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} scopePath Enum indicating if this item definition is owned + * by a specific user or is shared between all users with access to the + * Application Insights component. Possible values include: 'analyticsItems', + * 'myanalyticsItems' + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.id] The Id of a specific item defined in the + * Application Insights component + * + * @param {string} [options.name] The name of a specific item defined in the + * Application Insights component + * + * @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 {ApplicationInsightsComponentAnalyticsItem} - 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 ApplicationInsightsComponentAnalyticsItem} + * for more information. + * + * {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(resourceGroupName, resourceName, scopePath, 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(resourceGroupName, resourceName, scopePath, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, resourceName, scopePath, options, optionalCallback); + } + } + + /** + * Adds or Updates a specific Analytics Item within an Application Insights + * component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} scopePath Enum indicating if this item definition is owned + * by a specific user or is shared between all users with access to the + * Application Insights component. Possible values include: 'analyticsItems', + * 'myanalyticsItems' + * + * @param {object} itemProperties Properties that need to be specified to + * create a new item and add it to an Application Insights component. + * + * @param {string} [itemProperties.id] Internally assigned unique id of the + * item definition. + * + * @param {string} [itemProperties.name] The user-defined name of the item. + * + * @param {string} [itemProperties.content] The content of this item + * + * @param {string} [itemProperties.scope] Enum indicating if this item + * definition is owned by a specific user or is shared between all users with + * access to the Application Insights component. Possible values include: + * 'shared', 'user' + * + * @param {string} [itemProperties.type] Enum indicating the type of the + * Analytics item. Possible values include: 'query', 'function', 'folder', + * 'recent' + * + * @param {object} [itemProperties.properties] + * + * @param {string} [itemProperties.properties.functionAlias] A function alias, + * used when the type of the item is Function + * + * @param {object} [options] Optional Parameters. + * + * @param {boolean} [options.overrideItem] Flag indicating whether or not to + * force save an item. This allows overriding an item if it already exists. + * + * @param {object} [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. + */ + putWithHttpOperationResponse(resourceGroupName, resourceName, scopePath, itemProperties, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._put(resourceGroupName, resourceName, scopePath, itemProperties, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Adds or Updates a specific Analytics Item within an Application Insights + * component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} scopePath Enum indicating if this item definition is owned + * by a specific user or is shared between all users with access to the + * Application Insights component. Possible values include: 'analyticsItems', + * 'myanalyticsItems' + * + * @param {object} itemProperties Properties that need to be specified to + * create a new item and add it to an Application Insights component. + * + * @param {string} [itemProperties.id] Internally assigned unique id of the + * item definition. + * + * @param {string} [itemProperties.name] The user-defined name of the item. + * + * @param {string} [itemProperties.content] The content of this item + * + * @param {string} [itemProperties.scope] Enum indicating if this item + * definition is owned by a specific user or is shared between all users with + * access to the Application Insights component. Possible values include: + * 'shared', 'user' + * + * @param {string} [itemProperties.type] Enum indicating the type of the + * Analytics item. Possible values include: 'query', 'function', 'folder', + * 'recent' + * + * @param {object} [itemProperties.properties] + * + * @param {string} [itemProperties.properties.functionAlias] A function alias, + * used when the type of the item is Function + * + * @param {object} [options] Optional Parameters. + * + * @param {boolean} [options.overrideItem] Flag indicating whether or not to + * force save an item. This allows overriding an item if it already exists. + * + * @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 {ApplicationInsightsComponentAnalyticsItem} - 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 ApplicationInsightsComponentAnalyticsItem} + * for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + put(resourceGroupName, resourceName, scopePath, itemProperties, 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._put(resourceGroupName, resourceName, scopePath, itemProperties, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._put(resourceGroupName, resourceName, scopePath, itemProperties, options, optionalCallback); + } + } + + /** + * Deletes a specific Analytics Items defined within an Application Insights + * component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} scopePath Enum indicating if this item definition is owned + * by a specific user or is shared between all users with access to the + * Application Insights component. Possible values include: 'analyticsItems', + * 'myanalyticsItems' + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.id] The Id of a specific item defined in the + * Application Insights component + * + * @param {string} [options.name] The name of a specific item defined in the + * Application Insights component + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, resourceName, scopePath, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, resourceName, scopePath, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Deletes a specific Analytics Items defined within an Application Insights + * component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} scopePath Enum indicating if this item definition is owned + * by a specific user or is shared between all users with access to the + * Application Insights component. Possible values include: 'analyticsItems', + * 'myanalyticsItems' + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.id] The Id of a specific item defined in the + * Application Insights component + * + * @param {string} [options.name] The name of a specific item defined in the + * Application Insights component + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName, resourceName, scopePath, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, resourceName, scopePath, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, resourceName, scopePath, options, optionalCallback); + } + } + +} + +module.exports = AnalyticsItems; diff --git a/lib/services/applicationinsights/lib/operations/annotations.js b/lib/services/applicationinsights/lib/operations/annotations.js index 9cbbf32d6a..f509e6384b 100644 --- a/lib/services/applicationinsights/lib/operations/annotations.js +++ b/lib/services/applicationinsights/lib/operations/annotations.js @@ -38,7 +38,8 @@ const WebResource = msRest.WebResource; * * {Error} err - The Error object if an error occurred, null otherwise. * - * {array} [result] - The deserialized result object if an error did not occur. + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link AnnotationsListResult} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * @@ -158,21 +159,7 @@ function _list(resourceGroupName, resourceName, start, end, options, callback) { 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: 'AnnotationElementType', - type: { - name: 'Composite', - className: 'Annotation' - } - } - } - }; + let resultMapper = new client.models['AnnotationsListResult']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -741,7 +728,7 @@ class Annotations { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ @@ -784,7 +771,7 @@ class Annotations { * * {Promise} A promise is returned * - * @resolve {Array} - The deserialized result object. + * @resolve {AnnotationsListResult} - The deserialized result object. * * @reject {Error} - The error object. * @@ -792,7 +779,8 @@ class Annotations { * * {Error} err - The Error object if an error occurred, null otherwise. * - * {array} [result] - The deserialized result object if an error did not occur. + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link AnnotationsListResult} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * diff --git a/lib/services/applicationinsights/lib/operations/components.js b/lib/services/applicationinsights/lib/operations/components.js index 04ae765c1a..94dfaed700 100644 --- a/lib/services/applicationinsights/lib/operations/components.js +++ b/lib/services/applicationinsights/lib/operations/components.js @@ -931,7 +931,6 @@ function _updateTags(resourceGroupName, resourceName, componentTags, options, ca }); } - /** * Purges data in an Application Insights component by a set of user-defined * filters. @@ -961,6 +960,8 @@ function _updateTags(resourceGroupName, resourceName, componentTags, options, ca * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ComponentPurgeResponse} for more + * information. * * {object} [request] - The HTTP Request object if an error did not occur. * @@ -973,43 +974,122 @@ function _purge(resourceGroupName, resourceName, body, options, callback) { callback = options; options = null; } - if (!callback) { throw new Error('callback cannot be null.'); } + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (this.client.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 (resourceName === null || resourceName === undefined || typeof resourceName.valueOf() !== 'string') { + throw new Error('resourceName cannot be null or undefined and it must be of type string.'); + } + if (body === null || body === undefined) { + throw new Error('body cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } - // Send request - this.beginPurge(resourceGroupName, resourceName, body, options, (err, parsedResult, httpRequest, response) => { - if (err) return callback(err); - - let initialResult = new msRest.HttpOperationResponse(); - initialResult.request = httpRequest; - initialResult.response = response; - initialResult.body = response.body; - client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { - if (err) return callback(err); - - // Create Result - let result = null; + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } - httpRequest = pollingResult.request; - response = pollingResult.response; - let responseBody = pollingResult.body; + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (body !== null && body !== undefined) { + let requestModelMapper = new client.models['ComponentPurgeBody']().mapper(); + requestModel = client.serialize(requestModelMapper, body, 'body'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(body, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 202) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); if (responseBody === '') responseBody = null; - - // Deserialize Response + 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 === 202) { 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: 'Object' - } - }; + let resultMapper = new client.models['ComponentPurgeResponse']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -1018,28 +1098,22 @@ function _purge(resourceGroupName, resourceName, body, options, callback) { deserializationError.response = msRest.stripResponse(response); return callback(deserializationError); } + } - return callback(null, result, httpRequest, response); - }); + return callback(null, result, httpRequest, response); }); } /** - * Purges data in an Application Insights component by a set of user-defined - * filters. + * Get status for an ongoing purge operation. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} resourceName The name of the Application Insights component * resource. * - * @param {object} body Describes the body of a request to purge data in a - * single table of an Application Insights component - * - * @param {string} body.table Table from which to purge data. - * - * @param {array} body.filters The set of columns and filters (queries) to run - * over them to purge the resulting data. + * @param {string} purgeId In a purge status request, this is the Id of the + * operation the status of which is returned. * * @param {object} [options] Optional Parameters. * @@ -1053,12 +1127,14 @@ function _purge(resourceGroupName, resourceName, body, 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 ComponentPurgeStatusResponse} for more + * information. * * {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 _beginPurge(resourceGroupName, resourceName, body, options, callback) { +function _getPurgeStatus(resourceGroupName, resourceName, purgeId, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -1082,8 +1158,8 @@ function _beginPurge(resourceGroupName, resourceName, body, options, callback) { if (resourceName === null || resourceName === undefined || typeof resourceName.valueOf() !== 'string') { throw new Error('resourceName cannot be null or undefined and it must be of type string.'); } - if (body === null || body === undefined) { - throw new Error('body cannot be null or undefined.'); + if (purgeId === null || purgeId === undefined || typeof purgeId.valueOf() !== 'string') { + throw new Error('purgeId 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.'); @@ -1094,10 +1170,11 @@ function _beginPurge(resourceGroupName, resourceName, body, options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/operations/{purgeId}'; requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); + requestUrl = requestUrl.replace('{purgeId}', encodeURIComponent(purgeId)); let queryParameters = []; queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); if (queryParameters.length > 0) { @@ -1106,7 +1183,7 @@ function _beginPurge(resourceGroupName, resourceName, body, options, callback) { // Create HTTP transport objects let httpRequest = new WebResource(); - httpRequest.method = 'POST'; + httpRequest.method = 'GET'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers @@ -1124,28 +1201,14 @@ function _beginPurge(resourceGroupName, resourceName, body, options, callback) { } } } - // Serialize Request - let requestContent = null; - let requestModel = null; - try { - if (body !== null && body !== undefined) { - let requestModelMapper = new client.models['ComponentPurgeBody']().mapper(); - requestModel = client.serialize(requestModelMapper, body, 'body'); - requestContent = JSON.stringify(requestModel); - } - } catch (error) { - let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(body, null, 2)}.`); - return callback(serializationError); - } - httpRequest.body = requestContent; + httpRequest.body = null; // Send Request return client.pipeline(httpRequest, (err, response, responseBody) => { if (err) { return callback(err); } let statusCode = response.statusCode; - if (statusCode !== 200 && statusCode !== 202) { + if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); @@ -1190,23 +1253,6 @@ function _beginPurge(resourceGroupName, resourceName, body, options, callback) { return callback(deserializationError); } } - // Deserialize Response - if (statusCode === 202) { - let parsedResponse = null; - try { - parsedResponse = JSON.parse(responseBody); - result = JSON.parse(responseBody); - if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['ComponentPurgeResponse']().mapper(); - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError1.request = msRest.stripRequest(httpRequest); - deserializationError1.response = msRest.stripResponse(response); - return callback(deserializationError1); - } - } return callback(null, result, httpRequest, response); }); @@ -1483,7 +1529,7 @@ class Components { this._createOrUpdate = _createOrUpdate; this._updateTags = _updateTags; this._purge = _purge; - this._beginPurge = _beginPurge; + this._getPurgeStatus = _getPurgeStatus; this._listNext = _listNext; this._listByResourceGroupNext = _listByResourceGroupNext; } @@ -2108,7 +2154,7 @@ class Components { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ @@ -2155,7 +2201,7 @@ class Components { * * {Promise} A promise is returned * - * @resolve {Object} - The deserialized result object. + * @resolve {ComponentPurgeResponse} - The deserialized result object. * * @reject {Error} - The error object. * @@ -2164,6 +2210,8 @@ class Components { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ComponentPurgeResponse} for more + * information. * * {object} [request] - The HTTP Request object if an error did not occur. * @@ -2190,21 +2238,15 @@ class Components { } /** - * Purges data in an Application Insights component by a set of user-defined - * filters. + * Get status for an ongoing purge operation. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} resourceName The name of the Application Insights component * resource. * - * @param {object} body Describes the body of a request to purge data in a - * single table of an Application Insights component - * - * @param {string} body.table Table from which to purge data. - * - * @param {array} body.filters The set of columns and filters (queries) to run - * over them to purge the resulting data. + * @param {string} purgeId In a purge status request, this is the Id of the + * operation the status of which is returned. * * @param {object} [options] Optional Parameters. * @@ -2213,15 +2255,15 @@ class Components { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ - beginPurgeWithHttpOperationResponse(resourceGroupName, resourceName, body, options) { + getPurgeStatusWithHttpOperationResponse(resourceGroupName, resourceName, purgeId, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._beginPurge(resourceGroupName, resourceName, body, options, (err, result, request, response) => { + self._getPurgeStatus(resourceGroupName, resourceName, purgeId, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -2232,21 +2274,15 @@ class Components { } /** - * Purges data in an Application Insights component by a set of user-defined - * filters. + * Get status for an ongoing purge operation. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} resourceName The name of the Application Insights component * resource. * - * @param {object} body Describes the body of a request to purge data in a - * single table of an Application Insights component - * - * @param {string} body.table Table from which to purge data. - * - * @param {array} body.filters The set of columns and filters (queries) to run - * over them to purge the resulting data. + * @param {string} purgeId In a purge status request, this is the Id of the + * operation the status of which is returned. * * @param {object} [options] Optional Parameters. * @@ -2260,7 +2296,7 @@ class Components { * * {Promise} A promise is returned * - * @resolve {Object} - The deserialized result object. + * @resolve {ComponentPurgeStatusResponse} - The deserialized result object. * * @reject {Error} - The error object. * @@ -2269,12 +2305,14 @@ class Components { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ComponentPurgeStatusResponse} for more + * information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - beginPurge(resourceGroupName, resourceName, body, options, optionalCallback) { + getPurgeStatus(resourceGroupName, resourceName, purgeId, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -2283,14 +2321,14 @@ class Components { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._beginPurge(resourceGroupName, resourceName, body, options, (err, result, request, response) => { + self._getPurgeStatus(resourceGroupName, resourceName, purgeId, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._beginPurge(resourceGroupName, resourceName, body, options, optionalCallback); + return self._getPurgeStatus(resourceGroupName, resourceName, purgeId, options, optionalCallback); } } diff --git a/lib/services/applicationinsights/lib/operations/favorites.js b/lib/services/applicationinsights/lib/operations/favorites.js index b72dd84a07..4ec94eafa3 100644 --- a/lib/services/applicationinsights/lib/operations/favorites.js +++ b/lib/services/applicationinsights/lib/operations/favorites.js @@ -223,56 +223,1146 @@ function _list(resourceGroupName, resourceName, options, callback) { }); } +/** + * Get a single favorite by its FavoriteId, defined within an Application + * Insights component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} favoriteId The Id of a specific favorite defined in the + * Application Insights component + * + * @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 ApplicationInsightsComponentFavorite} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, resourceName, favoriteId, 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 (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (this.client.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 (resourceName === null || resourceName === undefined || typeof resourceName.valueOf() !== 'string') { + throw new Error('resourceName cannot be null or undefined and it must be of type string.'); + } + if (favoriteId === null || favoriteId === undefined || typeof favoriteId.valueOf() !== 'string') { + throw new Error('favoriteId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); + requestUrl = requestUrl.replace('{favoriteId}', encodeURIComponent(favoriteId)); + 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['ApplicationInsightsComponentFavorite']().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); + }); +} + +/** + * Adds a new favorites to an Application Insights component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} favoriteId The Id of a specific favorite defined in the + * Application Insights component + * + * @param {object} favoriteProperties Properties that need to be specified to + * create a new favorite and add it to an Application Insights component. + * + * @param {string} [favoriteProperties.name] The user-defined name of the + * favorite. + * + * @param {string} [favoriteProperties.config] Configuration of this particular + * favorite, which are driven by the Azure portal UX. Configuration data is a + * string containing valid JSON + * + * @param {string} [favoriteProperties.version] This instance's version of the + * data model. This can change as new features are added that can be marked + * favorite. Current examples include MetricsExplorer (ME) and Search. + * + * @param {string} [favoriteProperties.favoriteType] Enum indicating if this + * favorite definition is owned by a specific user or is shared between all + * users with access to the Application Insights component. Possible values + * include: 'shared', 'user' + * + * @param {string} [favoriteProperties.sourceType] The source of the favorite + * definition. + * + * @param {array} [favoriteProperties.tags] A list of 0 or more tags that are + * associated with this favorite definition + * + * @param {string} [favoriteProperties.category] Favorite category, as defined + * by the user at creation time. + * + * @param {boolean} [favoriteProperties.isGeneratedFromTemplate] Flag denoting + * wether or not this favorite was generated from a template. + * + * @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 ApplicationInsightsComponentFavorite} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _add(resourceGroupName, resourceName, favoriteId, favoriteProperties, 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 (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (this.client.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 (resourceName === null || resourceName === undefined || typeof resourceName.valueOf() !== 'string') { + throw new Error('resourceName cannot be null or undefined and it must be of type string.'); + } + if (favoriteId === null || favoriteId === undefined || typeof favoriteId.valueOf() !== 'string') { + throw new Error('favoriteId cannot be null or undefined and it must be of type string.'); + } + if (favoriteProperties === null || favoriteProperties === undefined) { + throw new Error('favoriteProperties cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); + requestUrl = requestUrl.replace('{favoriteId}', encodeURIComponent(favoriteId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (favoriteProperties !== null && favoriteProperties !== undefined) { + let requestModelMapper = new client.models['ApplicationInsightsComponentFavorite']().mapper(); + requestModel = client.serialize(requestModelMapper, favoriteProperties, 'favoriteProperties'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(favoriteProperties, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['ApplicationInsightsComponentFavorite']().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); + }); +} + +/** + * Updates a favorite that has already been added to an Application Insights + * component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} favoriteId The Id of a specific favorite defined in the + * Application Insights component + * + * @param {object} favoriteProperties Properties that need to be specified to + * update the existing favorite. + * + * @param {string} [favoriteProperties.name] The user-defined name of the + * favorite. + * + * @param {string} [favoriteProperties.config] Configuration of this particular + * favorite, which are driven by the Azure portal UX. Configuration data is a + * string containing valid JSON + * + * @param {string} [favoriteProperties.version] This instance's version of the + * data model. This can change as new features are added that can be marked + * favorite. Current examples include MetricsExplorer (ME) and Search. + * + * @param {string} [favoriteProperties.favoriteType] Enum indicating if this + * favorite definition is owned by a specific user or is shared between all + * users with access to the Application Insights component. Possible values + * include: 'shared', 'user' + * + * @param {string} [favoriteProperties.sourceType] The source of the favorite + * definition. + * + * @param {array} [favoriteProperties.tags] A list of 0 or more tags that are + * associated with this favorite definition + * + * @param {string} [favoriteProperties.category] Favorite category, as defined + * by the user at creation time. + * + * @param {boolean} [favoriteProperties.isGeneratedFromTemplate] Flag denoting + * wether or not this favorite was generated from a template. + * + * @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 ApplicationInsightsComponentFavorite} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _update(resourceGroupName, resourceName, favoriteId, favoriteProperties, 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 (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (this.client.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 (resourceName === null || resourceName === undefined || typeof resourceName.valueOf() !== 'string') { + throw new Error('resourceName cannot be null or undefined and it must be of type string.'); + } + if (favoriteId === null || favoriteId === undefined || typeof favoriteId.valueOf() !== 'string') { + throw new Error('favoriteId cannot be null or undefined and it must be of type string.'); + } + if (favoriteProperties === null || favoriteProperties === undefined) { + throw new Error('favoriteProperties cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); + requestUrl = requestUrl.replace('{favoriteId}', encodeURIComponent(favoriteId)); + 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 = 'PATCH'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (favoriteProperties !== null && favoriteProperties !== undefined) { + let requestModelMapper = new client.models['ApplicationInsightsComponentFavorite']().mapper(); + requestModel = client.serialize(requestModelMapper, favoriteProperties, 'favoriteProperties'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(favoriteProperties, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['ApplicationInsightsComponentFavorite']().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); + }); +} + +/** + * Remove a favorite that is associated to an Application Insights component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} favoriteId The Id of a specific favorite defined in the + * Application Insights component + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(resourceGroupName, resourceName, favoriteId, 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 (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (this.client.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 (resourceName === null || resourceName === undefined || typeof resourceName.valueOf() !== 'string') { + throw new Error('resourceName cannot be null or undefined and it must be of type string.'); + } + if (favoriteId === null || favoriteId === undefined || typeof favoriteId.valueOf() !== 'string') { + throw new Error('favoriteId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); + requestUrl = requestUrl.replace('{favoriteId}', encodeURIComponent(favoriteId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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; + + return callback(null, result, httpRequest, response); + }); +} + /** Class representing a Favorites. */ class Favorites { /** - * Create a Favorites. - * @param {ApplicationInsightsManagementClient} client Reference to the service client. + * Create a Favorites. + * @param {ApplicationInsightsManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._get = _get; + this._add = _add; + this._update = _update; + this._deleteMethod = _deleteMethod; + } + + /** + * Gets a list of favorites defined within an Application Insights component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.favoriteType] The type of favorite. Value can be + * either shared or user. Possible values include: 'shared', 'user' + * + * @param {string} [options.sourceType] Source type of favorite to return. When + * left out, the source type defaults to 'other' (not present in this enum). + * Possible values include: 'retention', 'notebook', 'sessions', 'events', + * 'userflows', 'funnel', 'impact', 'segmentation' + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable favorite. If false, only return + * summary content for favorites. + * + * @param {array} [options.tags] Tags that must be present on each favorite + * returned. + * + * @param {object} [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(resourceGroupName, resourceName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(resourceGroupName, resourceName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a list of favorites defined within an Application Insights component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.favoriteType] The type of favorite. Value can be + * either shared or user. Possible values include: 'shared', 'user' + * + * @param {string} [options.sourceType] Source type of favorite to return. When + * left out, the source type defaults to 'other' (not present in this enum). + * Possible values include: 'retention', 'notebook', 'sessions', 'events', + * 'userflows', 'funnel', 'impact', 'segmentation' + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable favorite. If false, only return + * summary content for favorites. + * + * @param {array} [options.tags] Tags that must be present on each favorite + * returned. + * + * @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 {Array} - 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. + * + * {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. + */ + list(resourceGroupName, resourceName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(resourceGroupName, resourceName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(resourceGroupName, resourceName, options, optionalCallback); + } + } + + /** + * Get a single favorite by its FavoriteId, defined within an Application + * Insights component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} favoriteId The Id of a specific favorite defined in the + * Application Insights component + * + * @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(resourceGroupName, resourceName, favoriteId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, resourceName, favoriteId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get a single favorite by its FavoriteId, defined within an Application + * Insights component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} favoriteId The Id of a specific favorite defined in the + * Application Insights component + * + * @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 {ApplicationInsightsComponentFavorite} - 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 ApplicationInsightsComponentFavorite} for + * more information. + * + * {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(resourceGroupName, resourceName, favoriteId, 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(resourceGroupName, resourceName, favoriteId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, resourceName, favoriteId, options, optionalCallback); + } + } + + /** + * Adds a new favorites to an Application Insights component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} favoriteId The Id of a specific favorite defined in the + * Application Insights component + * + * @param {object} favoriteProperties Properties that need to be specified to + * create a new favorite and add it to an Application Insights component. + * + * @param {string} [favoriteProperties.name] The user-defined name of the + * favorite. + * + * @param {string} [favoriteProperties.config] Configuration of this particular + * favorite, which are driven by the Azure portal UX. Configuration data is a + * string containing valid JSON + * + * @param {string} [favoriteProperties.version] This instance's version of the + * data model. This can change as new features are added that can be marked + * favorite. Current examples include MetricsExplorer (ME) and Search. + * + * @param {string} [favoriteProperties.favoriteType] Enum indicating if this + * favorite definition is owned by a specific user or is shared between all + * users with access to the Application Insights component. Possible values + * include: 'shared', 'user' + * + * @param {string} [favoriteProperties.sourceType] The source of the favorite + * definition. + * + * @param {array} [favoriteProperties.tags] A list of 0 or more tags that are + * associated with this favorite definition + * + * @param {string} [favoriteProperties.category] Favorite category, as defined + * by the user at creation time. + * + * @param {boolean} [favoriteProperties.isGeneratedFromTemplate] Flag denoting + * wether or not this favorite was generated from a template. + * + * @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. */ - constructor(client) { - this.client = client; - this._list = _list; + addWithHttpOperationResponse(resourceGroupName, resourceName, favoriteId, favoriteProperties, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._add(resourceGroupName, resourceName, favoriteId, favoriteProperties, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); } /** - * Gets a list of favorites defined within an Application Insights component. + * Adds a new favorites to an Application Insights component. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} resourceName The name of the Application Insights component * resource. * + * @param {string} favoriteId The Id of a specific favorite defined in the + * Application Insights component + * + * @param {object} favoriteProperties Properties that need to be specified to + * create a new favorite and add it to an Application Insights component. + * + * @param {string} [favoriteProperties.name] The user-defined name of the + * favorite. + * + * @param {string} [favoriteProperties.config] Configuration of this particular + * favorite, which are driven by the Azure portal UX. Configuration data is a + * string containing valid JSON + * + * @param {string} [favoriteProperties.version] This instance's version of the + * data model. This can change as new features are added that can be marked + * favorite. Current examples include MetricsExplorer (ME) and Search. + * + * @param {string} [favoriteProperties.favoriteType] Enum indicating if this + * favorite definition is owned by a specific user or is shared between all + * users with access to the Application Insights component. Possible values + * include: 'shared', 'user' + * + * @param {string} [favoriteProperties.sourceType] The source of the favorite + * definition. + * + * @param {array} [favoriteProperties.tags] A list of 0 or more tags that are + * associated with this favorite definition + * + * @param {string} [favoriteProperties.category] Favorite category, as defined + * by the user at creation time. + * + * @param {boolean} [favoriteProperties.isGeneratedFromTemplate] Flag denoting + * wether or not this favorite was generated from a template. + * * @param {object} [options] Optional Parameters. * - * @param {string} [options.favoriteType] The type of favorite. Value can be - * either shared or user. Possible values include: 'shared', 'user' + * @param {object} [options.customHeaders] Headers that will be added to the + * request * - * @param {string} [options.sourceType] Source type of favorite to return. When - * left out, the source type defaults to 'other' (not present in this enum). - * Possible values include: 'retention', 'notebook', 'sessions', 'events', - * 'userflows', 'funnel', 'impact', 'segmentation' + * @param {function} [optionalCallback] - The optional callback. * - * @param {boolean} [options.canFetchContent] Flag indicating whether or not to - * return the full content for each applicable favorite. If false, only return - * summary content for favorites. + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. * - * @param {array} [options.tags] Tags that must be present on each favorite - * returned. + * {Promise} A promise is returned + * + * @resolve {ApplicationInsightsComponentFavorite} - 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 ApplicationInsightsComponentFavorite} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + add(resourceGroupName, resourceName, favoriteId, favoriteProperties, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._add(resourceGroupName, resourceName, favoriteId, favoriteProperties, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._add(resourceGroupName, resourceName, favoriteId, favoriteProperties, options, optionalCallback); + } + } + + /** + * Updates a favorite that has already been added to an Application Insights + * component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} favoriteId The Id of a specific favorite defined in the + * Application Insights component + * + * @param {object} favoriteProperties Properties that need to be specified to + * update the existing favorite. + * + * @param {string} [favoriteProperties.name] The user-defined name of the + * favorite. + * + * @param {string} [favoriteProperties.config] Configuration of this particular + * favorite, which are driven by the Azure portal UX. Configuration data is a + * string containing valid JSON + * + * @param {string} [favoriteProperties.version] This instance's version of the + * data model. This can change as new features are added that can be marked + * favorite. Current examples include MetricsExplorer (ME) and Search. + * + * @param {string} [favoriteProperties.favoriteType] Enum indicating if this + * favorite definition is owned by a specific user or is shared between all + * users with access to the Application Insights component. Possible values + * include: 'shared', 'user' + * + * @param {string} [favoriteProperties.sourceType] The source of the favorite + * definition. + * + * @param {array} [favoriteProperties.tags] A list of 0 or more tags that are + * associated with this favorite definition + * + * @param {string} [favoriteProperties.category] Favorite category, as defined + * by the user at creation time. + * + * @param {boolean} [favoriteProperties.isGeneratedFromTemplate] Flag denoting + * wether or not this favorite was generated from a template. + * + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ - listWithHttpOperationResponse(resourceGroupName, resourceName, options) { + updateWithHttpOperationResponse(resourceGroupName, resourceName, favoriteId, favoriteProperties, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._list(resourceGroupName, resourceName, options, (err, result, request, response) => { + self._update(resourceGroupName, resourceName, favoriteId, favoriteProperties, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -283,29 +1373,144 @@ class Favorites { } /** - * Gets a list of favorites defined within an Application Insights component. + * Updates a favorite that has already been added to an Application Insights + * component. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} resourceName The name of the Application Insights component * resource. * + * @param {string} favoriteId The Id of a specific favorite defined in the + * Application Insights component + * + * @param {object} favoriteProperties Properties that need to be specified to + * update the existing favorite. + * + * @param {string} [favoriteProperties.name] The user-defined name of the + * favorite. + * + * @param {string} [favoriteProperties.config] Configuration of this particular + * favorite, which are driven by the Azure portal UX. Configuration data is a + * string containing valid JSON + * + * @param {string} [favoriteProperties.version] This instance's version of the + * data model. This can change as new features are added that can be marked + * favorite. Current examples include MetricsExplorer (ME) and Search. + * + * @param {string} [favoriteProperties.favoriteType] Enum indicating if this + * favorite definition is owned by a specific user or is shared between all + * users with access to the Application Insights component. Possible values + * include: 'shared', 'user' + * + * @param {string} [favoriteProperties.sourceType] The source of the favorite + * definition. + * + * @param {array} [favoriteProperties.tags] A list of 0 or more tags that are + * associated with this favorite definition + * + * @param {string} [favoriteProperties.category] Favorite category, as defined + * by the user at creation time. + * + * @param {boolean} [favoriteProperties.isGeneratedFromTemplate] Flag denoting + * wether or not this favorite was generated from a template. + * * @param {object} [options] Optional Parameters. * - * @param {string} [options.favoriteType] The type of favorite. Value can be - * either shared or user. Possible values include: 'shared', 'user' + * @param {object} [options.customHeaders] Headers that will be added to the + * request * - * @param {string} [options.sourceType] Source type of favorite to return. When - * left out, the source type defaults to 'other' (not present in this enum). - * Possible values include: 'retention', 'notebook', 'sessions', 'events', - * 'userflows', 'funnel', 'impact', 'segmentation' + * @param {function} [optionalCallback] - The optional callback. * - * @param {boolean} [options.canFetchContent] Flag indicating whether or not to - * return the full content for each applicable favorite. If false, only return - * summary content for favorites. + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. * - * @param {array} [options.tags] Tags that must be present on each favorite - * returned. + * {Promise} A promise is returned + * + * @resolve {ApplicationInsightsComponentFavorite} - 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 ApplicationInsightsComponentFavorite} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + update(resourceGroupName, resourceName, favoriteId, favoriteProperties, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._update(resourceGroupName, resourceName, favoriteId, favoriteProperties, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(resourceGroupName, resourceName, favoriteId, favoriteProperties, options, optionalCallback); + } + } + + /** + * Remove a favorite that is associated to an Application Insights component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} favoriteId The Id of a specific favorite defined in the + * Application Insights component + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, resourceName, favoriteId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, resourceName, favoriteId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Remove a favorite that is associated to an Application Insights component. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} favoriteId The Id of a specific favorite defined in the + * Application Insights component + * + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -317,7 +1522,7 @@ class Favorites { * * {Promise} A promise is returned * - * @resolve {Array} - The deserialized result object. + * @resolve {null} - The deserialized result object. * * @reject {Error} - The error object. * @@ -325,13 +1530,13 @@ class Favorites { * * {Error} err - The Error object if an error occurred, null otherwise. * - * {array} [result] - The deserialized result object if an error did not occur. + * {null} [result] - The deserialized result object if an error did not occur. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - list(resourceGroupName, resourceName, options, optionalCallback) { + deleteMethod(resourceGroupName, resourceName, favoriteId, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -340,14 +1545,14 @@ class Favorites { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._list(resourceGroupName, resourceName, options, (err, result, request, response) => { + self._deleteMethod(resourceGroupName, resourceName, favoriteId, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._list(resourceGroupName, resourceName, options, optionalCallback); + return self._deleteMethod(resourceGroupName, resourceName, favoriteId, options, optionalCallback); } } diff --git a/lib/services/applicationinsights/lib/operations/index.d.ts b/lib/services/applicationinsights/lib/operations/index.d.ts index d0c357fc59..c8e8333e40 100644 --- a/lib/services/applicationinsights/lib/operations/index.d.ts +++ b/lib/services/applicationinsights/lib/operations/index.d.ts @@ -158,11 +158,11 @@ export interface Annotations { * * @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(resourceGroupName: string, resourceName: string, start: string, end: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listWithHttpOperationResponse(resourceGroupName: string, resourceName: string, start: string, end: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Gets the list of annotations for a component for given time range @@ -189,7 +189,7 @@ export interface Annotations { * * {Promise} A promise is returned. * - * @resolve {Array} - The deserialized result object. + * @resolve {AnnotationsListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -197,15 +197,16 @@ export interface Annotations { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {Array} [result] - The deserialized result object if an error did not occur. + * {AnnotationsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link AnnotationsListResult} 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(resourceGroupName: string, resourceName: string, start: string, end: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - list(resourceGroupName: string, resourceName: string, start: string, end: string, callback: ServiceCallback): void; - list(resourceGroupName: string, resourceName: string, start: string, end: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + list(resourceGroupName: string, resourceName: string, start: string, end: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(resourceGroupName: string, resourceName: string, start: string, end: string, callback: ServiceCallback): void; + list(resourceGroupName: string, resourceName: string, start: string, end: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -2366,11 +2367,11 @@ export interface Components { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - purgeWithHttpOperationResponse(resourceGroupName: string, resourceName: string, body: models.ComponentPurgeBody, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + purgeWithHttpOperationResponse(resourceGroupName: string, resourceName: string, body: models.ComponentPurgeBody, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Purges data in an Application Insights component by a set of user-defined @@ -2401,7 +2402,7 @@ export interface Components { * * {Promise} A promise is returned. * - * @resolve {Object} - The deserialized result object. + * @resolve {ComponentPurgeResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -2409,33 +2410,29 @@ export interface Components { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {Object} [result] - The deserialized result object if an error did not occur. + * {ComponentPurgeResponse} [result] - The deserialized result object if an error did not occur. + * See {@link ComponentPurgeResponse} 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. */ - purge(resourceGroupName: string, resourceName: string, body: models.ComponentPurgeBody, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - purge(resourceGroupName: string, resourceName: string, body: models.ComponentPurgeBody, callback: ServiceCallback): void; - purge(resourceGroupName: string, resourceName: string, body: models.ComponentPurgeBody, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + purge(resourceGroupName: string, resourceName: string, body: models.ComponentPurgeBody, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + purge(resourceGroupName: string, resourceName: string, body: models.ComponentPurgeBody, callback: ServiceCallback): void; + purge(resourceGroupName: string, resourceName: string, body: models.ComponentPurgeBody, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Purges data in an Application Insights component by a set of user-defined - * filters. + * Get status for an ongoing purge operation. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} resourceName The name of the Application Insights component * resource. * - * @param {object} body Describes the body of a request to purge data in a - * single table of an Application Insights component - * - * @param {string} body.table Table from which to purge data. - * - * @param {array} body.filters The set of columns and filters (queries) to run - * over them to purge the resulting data. + * @param {string} purgeId In a purge status request, this is the Id of the + * operation the status of which is returned. * * @param {object} [options] Optional Parameters. * @@ -2444,28 +2441,22 @@ export interface Components { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - beginPurgeWithHttpOperationResponse(resourceGroupName: string, resourceName: string, body: models.ComponentPurgeBody, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + getPurgeStatusWithHttpOperationResponse(resourceGroupName: string, resourceName: string, purgeId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Purges data in an Application Insights component by a set of user-defined - * filters. + * Get status for an ongoing purge operation. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} resourceName The name of the Application Insights component * resource. * - * @param {object} body Describes the body of a request to purge data in a - * single table of an Application Insights component - * - * @param {string} body.table Table from which to purge data. - * - * @param {array} body.filters The set of columns and filters (queries) to run - * over them to purge the resulting data. + * @param {string} purgeId In a purge status request, this is the Id of the + * operation the status of which is returned. * * @param {object} [options] Optional Parameters. * @@ -2479,7 +2470,7 @@ export interface Components { * * {Promise} A promise is returned. * - * @resolve {Object} - The deserialized result object. + * @resolve {ComponentPurgeStatusResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -2487,15 +2478,17 @@ export interface Components { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {Object} [result] - The deserialized result object if an error did not occur. + * {ComponentPurgeStatusResponse} [result] - The deserialized result object if an error did not occur. + * See {@link ComponentPurgeStatusResponse} 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. */ - beginPurge(resourceGroupName: string, resourceName: string, body: models.ComponentPurgeBody, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - beginPurge(resourceGroupName: string, resourceName: string, body: models.ComponentPurgeBody, callback: ServiceCallback): void; - beginPurge(resourceGroupName: string, resourceName: string, body: models.ComponentPurgeBody, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + getPurgeStatus(resourceGroupName: string, resourceName: string, purgeId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getPurgeStatus(resourceGroupName: string, resourceName: string, purgeId: string, callback: ServiceCallback): void; + getPurgeStatus(resourceGroupName: string, resourceName: string, purgeId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -2638,11 +2631,11 @@ export interface WorkItemConfigurations { * * @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(resourceGroupName: string, resourceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listWithHttpOperationResponse(resourceGroupName: string, resourceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Gets the list work item configurations that exist for the application @@ -2664,7 +2657,7 @@ export interface WorkItemConfigurations { * * {Promise} A promise is returned. * - * @resolve {Array} - The deserialized result object. + * @resolve {WorkItemConfigurationsListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -2672,15 +2665,17 @@ export interface WorkItemConfigurations { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {Array} [result] - The deserialized result object if an error did not occur. + * {WorkItemConfigurationsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link WorkItemConfigurationsListResult} 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(resourceGroupName: string, resourceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - list(resourceGroupName: string, resourceName: string, callback: ServiceCallback): void; - list(resourceGroupName: string, resourceName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + list(resourceGroupName: string, resourceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(resourceGroupName: string, resourceName: string, callback: ServiceCallback): void; + list(resourceGroupName: string, resourceName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -3002,15 +2997,6 @@ export interface Favorites { list(resourceGroupName: string, resourceName: string, options?: { favoriteType? : string, sourceType? : string, canFetchContent? : boolean, tags? : string[], customHeaders? : { [headerName: string]: string; } }): Promise; list(resourceGroupName: string, resourceName: string, callback: ServiceCallback): void; list(resourceGroupName: string, resourceName: string, options: { favoriteType? : string, sourceType? : string, canFetchContent? : boolean, tags? : string[], customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; -} - -/** - * @class - * Favorite - * __NOTE__: An instance of this class is automatically created for an - * instance of the ApplicationInsightsManagementClient. - */ -export interface Favorite { /** @@ -4187,11 +4173,11 @@ export interface WebTests { /** * @class - * AnalyticsItem + * AnalyticsItems * __NOTE__: An instance of this class is automatically created for an * instance of the ApplicationInsightsManagementClient. */ -export interface AnalyticsItem { +export interface AnalyticsItems { /** @@ -4590,11 +4576,11 @@ export interface AnalyticsItem { /** * @class - * WorkbooksOperations + * Workbooks * __NOTE__: An instance of this class is automatically created for an * instance of the ApplicationInsightsManagementClient. */ -export interface WorkbooksOperations { +export interface Workbooks { /** @@ -4618,11 +4604,11 @@ export interface WorkbooksOperations { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listByResourceGroupWithHttpOperationResponse(resourceGroupName: string, category: string, options?: { tags? : string[], canFetchContent? : boolean, customHeaders? : { [headerName: string]: string; } }): Promise>; + listByResourceGroupWithHttpOperationResponse(resourceGroupName: string, category: string, options?: { tags? : string[], canFetchContent? : boolean, customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Get all Workbooks defined within a specified resource group and category. @@ -4650,7 +4636,7 @@ export interface WorkbooksOperations { * * {Promise} A promise is returned. * - * @resolve {Workbooks} - The deserialized result object. + * @resolve {WorkbooksListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -4658,25 +4644,16 @@ export interface WorkbooksOperations { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {Workbooks} [result] - The deserialized result object if an error did not occur. - * See {@link Workbooks} for more information. + * {WorkbooksListResult} [result] - The deserialized result object if an error did not occur. + * See {@link WorkbooksListResult} 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. */ - listByResourceGroup(resourceGroupName: string, category: string, options?: { tags? : string[], canFetchContent? : boolean, customHeaders? : { [headerName: string]: string; } }): Promise; - listByResourceGroup(resourceGroupName: string, category: string, callback: ServiceCallback): void; - listByResourceGroup(resourceGroupName: string, category: string, options: { tags? : string[], canFetchContent? : boolean, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; -} - -/** - * @class - * WorkbookOperations - * __NOTE__: An instance of this class is automatically created for an - * instance of the ApplicationInsightsManagementClient. - */ -export interface WorkbookOperations { + listByResourceGroup(resourceGroupName: string, category: string, options?: { tags? : string[], canFetchContent? : boolean, customHeaders? : { [headerName: string]: string; } }): Promise; + listByResourceGroup(resourceGroupName: string, category: string, callback: ServiceCallback): void; + listByResourceGroup(resourceGroupName: string, category: string, options: { tags? : string[], canFetchContent? : boolean, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -4844,7 +4821,7 @@ export interface WorkbookOperations { * @param {string} [workbookProperties.sourceResourceId] Optional resourceId * for a source resource. * - * @param {string} workbookProperties.location Resource location + * @param {string} [workbookProperties.location] Resource location * * @param {object} [workbookProperties.tags] Resource tags * @@ -4905,7 +4882,7 @@ export interface WorkbookOperations { * @param {string} [workbookProperties.sourceResourceId] Optional resourceId * for a source resource. * - * @param {string} workbookProperties.location Resource location + * @param {string} [workbookProperties.location] Resource location * * @param {object} [workbookProperties.tags] Resource tags * @@ -4985,7 +4962,7 @@ export interface WorkbookOperations { * @param {string} [workbookProperties.sourceResourceId] Optional resourceId * for a source resource. * - * @param {string} workbookProperties.location Resource location + * @param {string} [workbookProperties.location] Resource location * * @param {object} [workbookProperties.tags] Resource tags * @@ -5046,7 +5023,7 @@ export interface WorkbookOperations { * @param {string} [workbookProperties.sourceResourceId] Optional resourceId * for a source resource. * - * @param {string} workbookProperties.location Resource location + * @param {string} [workbookProperties.location] Resource location * * @param {object} [workbookProperties.tags] Resource tags * diff --git a/lib/services/applicationinsights/lib/operations/index.js b/lib/services/applicationinsights/lib/operations/index.js index e3a91e4d8e..7d68215c66 100644 --- a/lib/services/applicationinsights/lib/operations/index.js +++ b/lib/services/applicationinsights/lib/operations/index.js @@ -26,9 +26,7 @@ exports.ProactiveDetectionConfigurations = require('./proactiveDetectionConfigur exports.Components = require('./components'); exports.WorkItemConfigurations = require('./workItemConfigurations'); exports.Favorites = require('./favorites'); -exports.Favorite = require('./favorite'); exports.WebTestLocations = require('./webTestLocations'); exports.WebTests = require('./webTests'); -exports.AnalyticsItem = require('./analyticsItem'); -exports.WorkbooksOperations = require('./workbooksOperations'); -exports.WorkbookOperations = require('./workbookOperations'); +exports.AnalyticsItems = require('./analyticsItems'); +exports.Workbooks = require('./workbooks'); diff --git a/lib/services/applicationinsights/lib/operations/workItemConfigurations.js b/lib/services/applicationinsights/lib/operations/workItemConfigurations.js index 12cf0121a1..12da50b54d 100644 --- a/lib/services/applicationinsights/lib/operations/workItemConfigurations.js +++ b/lib/services/applicationinsights/lib/operations/workItemConfigurations.js @@ -33,7 +33,9 @@ const WebResource = msRest.WebResource; * * {Error} err - The Error object if an error occurred, null otherwise. * - * {array} [result] - The deserialized result object if an error did not occur. + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link WorkItemConfigurationsListResult} for more + * information. * * {object} [request] - The HTTP Request object if an error did not occur. * @@ -145,21 +147,7 @@ function _list(resourceGroupName, resourceName, options, callback) { 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: 'WorkItemConfigurationElementType', - type: { - name: 'Composite', - className: 'WorkItemConfiguration' - } - } - } - }; + let resultMapper = new client.models['WorkItemConfigurationsListResult']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -687,7 +675,7 @@ class WorkItemConfigurations { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ @@ -725,7 +713,7 @@ class WorkItemConfigurations { * * {Promise} A promise is returned * - * @resolve {Array} - The deserialized result object. + * @resolve {WorkItemConfigurationsListResult} - The deserialized result object. * * @reject {Error} - The error object. * @@ -733,7 +721,9 @@ class WorkItemConfigurations { * * {Error} err - The Error object if an error occurred, null otherwise. * - * {array} [result] - The deserialized result object if an error did not occur. + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link WorkItemConfigurationsListResult} for more + * information. * * {object} [request] - The HTTP Request object if an error did not occur. * diff --git a/lib/services/applicationinsights/lib/operations/workbooks.js b/lib/services/applicationinsights/lib/operations/workbooks.js index e5349d3e6f..dafde7819a 100644 --- a/lib/services/applicationinsights/lib/operations/workbooks.js +++ b/lib/services/applicationinsights/lib/operations/workbooks.js @@ -15,20 +15,13 @@ const msRestAzure = require('ms-rest-azure'); const WebResource = msRest.WebResource; /** - * Get all Workbooks defined within a specified subscriptionId. It will get a - * list of workbooks or linked workbooks based on $filter clause. If sourceId - * is specified, it will get a list of linked workbboks. If a targetId is - * specified, it will get a list of workboks. When a targetId is specified, a - * resourceName is not required. Even if it is provided, it will be ignored. + * Get all Workbooks defined within a specified resource group and category. * - * @param {string} location The name of location where workbook is stored. + * @param {string} resourceGroupName The name of the resource group. * * @param {string} category Category of workbook to return. Possible values * include: 'workbook', 'TSG', 'performance', 'retention' * - * @param {string} resourceId Azure Resource id or any target workbook resource - * id. - * * @param {object} [options] Optional Parameters. * * @param {array} [options.tags] Tags presents on each workbook returned. @@ -47,13 +40,13 @@ const WebResource = msRest.WebResource; * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link WorkbookListResult} for more information. + * See {@link WorkbooksListResult} for more information. * * {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 _listByResourceGroup(location, category, resourceId, options, callback) { +function _listByResourceGroup(resourceGroupName, category, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -70,8 +63,8 @@ function _listByResourceGroup(location, category, resourceId, options, callback) 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 (location === null || location === undefined || typeof location.valueOf() !== 'string') { - throw new Error('location cannot be null or undefined and it must be of type string.'); + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); } if (category === null || category === undefined || typeof category.valueOf() !== 'string') { throw new Error('category cannot be null or undefined and it must be of type string.'); @@ -89,9 +82,6 @@ function _listByResourceGroup(location, category, resourceId, 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 (resourceId === null || resourceId === undefined || typeof resourceId.valueOf() !== 'string') { - throw new Error('resourceId 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.'); } @@ -101,10 +91,10 @@ function _listByResourceGroup(location, category, resourceId, options, callback) // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/microsoft.insights/workbooks'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks'; requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); let queryParameters = []; - queryParameters.push('location=' + encodeURIComponent(location)); queryParameters.push('category=' + encodeURIComponent(category)); if (tags !== null && tags !== undefined) { queryParameters.push('tags=' + encodeURIComponent(tags.join(','))); @@ -113,7 +103,6 @@ function _listByResourceGroup(location, category, resourceId, options, callback) queryParameters.push('canFetchContent=' + encodeURIComponent(canFetchContent.toString())); } queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); - queryParameters.push('resourceId=' + encodeURIComponent(resourceId)); if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); } @@ -161,7 +150,7 @@ function _listByResourceGroup(location, category, resourceId, options, callback) error.message = internalError ? internalError.message : parsedErrorResponse.message; } if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['WorkbookErrorResponse']().mapper(); + let resultMapper = new client.models['WorkbookError']().mapper(); error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); } } catch (defaultError) { @@ -181,7 +170,7 @@ function _listByResourceGroup(location, category, resourceId, options, callback) parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['WorkbookListResult']().mapper(); + let resultMapper = new client.models['WorkbooksListResult']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -197,15 +186,13 @@ function _listByResourceGroup(location, category, resourceId, options, callback) } /** - * Delete a workbook. + * Get a single workbook by its resourceName. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} resourceName The name of the Application Insights component * resource. * - * @param {string} location The name of location where workbook is stored. - * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -217,13 +204,14 @@ function _listByResourceGroup(location, category, resourceId, options, callback) * * {Error} err - The Error object if an error occurred, null otherwise. * - * {null} [result] - The deserialized result object if an error did not occur. + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Workbook} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _deleteMethod(resourceGroupName, resourceName, location, options, callback) { +function _get(resourceGroupName, resourceName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -244,9 +232,6 @@ function _deleteMethod(resourceGroupName, resourceName, location, options, callb if (resourceName === null || resourceName === undefined || typeof resourceName.valueOf() !== 'string') { throw new Error('resourceName cannot be null or undefined and it must be of type string.'); } - if (location === null || location === undefined || typeof location.valueOf() !== 'string') { - throw new Error('location cannot be null or undefined and it must be of type string.'); - } if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); } @@ -264,7 +249,6 @@ function _deleteMethod(resourceGroupName, resourceName, location, options, callb requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); let queryParameters = []; - queryParameters.push('location=' + encodeURIComponent(location)); queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); @@ -272,7 +256,7 @@ function _deleteMethod(resourceGroupName, resourceName, location, options, callb // Create HTTP transport objects let httpRequest = new WebResource(); - httpRequest.method = 'DELETE'; + httpRequest.method = 'GET'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers @@ -297,7 +281,7 @@ function _deleteMethod(resourceGroupName, resourceName, location, options, callb return callback(err); } let statusCode = response.statusCode; - if (statusCode !== 200 && statusCode !== 204) { + if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); @@ -313,7 +297,7 @@ function _deleteMethod(resourceGroupName, resourceName, location, options, callb error.message = internalError ? internalError.message : parsedErrorResponse.message; } if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['WorkbookErrorResponse']().mapper(); + let resultMapper = new client.models['WorkbookError']().mapper(); error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); } } catch (defaultError) { @@ -326,75 +310,36 @@ function _deleteMethod(resourceGroupName, resourceName, location, options, callb // 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['Workbook']().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); }); } /** - * Create a new workbook. + * Delete a workbook. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} resourceName The name of the Application Insights component * resource. * - * @param {object} workbookPayload Properties that need to be specified to - * create a new workbook or link. - * - * @param {object} [workbookPayload.workbook] Workbook properties. If provided, - * it will be used to create new workbook. - * - * @param {string} [workbookPayload.workbook.kind] The kind of workbook. - * Choices are user and shared. Possible values include: 'user', 'shared' - * - * @param {string} workbookPayload.workbook.workbookName The user-defined name - * of the workbook. - * - * @param {string} workbookPayload.workbook.serializedData Configuration of - * this particular workbook. Configuration data is a string containing valid - * JSON - * - * @param {string} [workbookPayload.workbook.version] This instance's version - * of the data model. This can change as new features are added that can be - * marked workbook. - * - * @param {string} workbookPayload.workbook.workbookId Internally assigned - * unique id of the workbook definition. - * - * @param {string} workbookPayload.workbook.sharedTypeKind Enum indicating if - * this workbook definition is owned by a specific user or is shared between - * all users with access to the Application Insights component. Possible values - * include: 'user', 'shared' - * - * @param {string} workbookPayload.workbook.category Workbook category, as - * defined by the user at creation time. - * - * @param {array} [workbookPayload.workbook.workbookTags] A list of 0 or more - * tags that are associated with this workbook definition - * - * @param {string} workbookPayload.workbook.userId Unique user id of the - * specific user that owns this workbook. - * - * @param {string} [workbookPayload.workbook.sourceResourceId] Optional - * resourceId for a source resource. - * - * @param {string} workbookPayload.workbook.location Resource location - * - * @param {object} [workbookPayload.workbook.tags] Resource tags - * - * @param {object} [workbookPayload.linkResource] LinkProperties. If provided, - * it will be used to create a link. - * - * @param {string} [workbookPayload.linkResource.sourceId] The source Azure - * resource id - * - * @param {string} [workbookPayload.linkResource.targetId] The workbook Azure - * resource id - * - * @param {string} [workbookPayload.linkResource.category] The category of - * workbook - * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -406,14 +351,13 @@ function _deleteMethod(resourceGroupName, resourceName, location, options, callb * * {Error} err - The Error object if an error occurred, null otherwise. * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link Workbook} for more information. + * {null} [result] - The deserialized result object if an error did not occur. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _create(resourceGroupName, resourceName, workbookPayload, options, callback) { +function _deleteMethod(resourceGroupName, resourceName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -437,9 +381,6 @@ function _create(resourceGroupName, resourceName, workbookPayload, options, call 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 (workbookPayload === null || workbookPayload === undefined) { - throw new Error('workbookPayload cannot be null or undefined.'); - } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); } @@ -461,7 +402,7 @@ function _create(resourceGroupName, resourceName, workbookPayload, options, call // Create HTTP transport objects let httpRequest = new WebResource(); - httpRequest.method = 'PUT'; + httpRequest.method = 'DELETE'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers @@ -479,28 +420,14 @@ function _create(resourceGroupName, resourceName, workbookPayload, options, call } } } - // Serialize Request - let requestContent = null; - let requestModel = null; - try { - if (workbookPayload !== null && workbookPayload !== undefined) { - let requestModelMapper = new client.models['WorkbookPayload']().mapper(); - requestModel = client.serialize(requestModelMapper, workbookPayload, 'workbookPayload'); - requestContent = JSON.stringify(requestModel); - } - } catch (error) { - let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(workbookPayload, null, 2)}.`); - return callback(serializationError); - } - httpRequest.body = requestContent; + httpRequest.body = null; // Send Request return client.pipeline(httpRequest, (err, response, responseBody) => { if (err) { return callback(err); } let statusCode = response.statusCode; - if (statusCode !== 200) { + if (statusCode !== 201 && statusCode !== 204) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); @@ -516,7 +443,7 @@ function _create(resourceGroupName, resourceName, workbookPayload, options, call error.message = internalError ? internalError.message : parsedErrorResponse.message; } if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['WorkbookErrorResponse']().mapper(); + let resultMapper = new client.models['WorkbookError']().mapper(); error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); } } catch (defaultError) { @@ -529,91 +456,58 @@ function _create(resourceGroupName, resourceName, workbookPayload, options, call // 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['Workbook']().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); }); } /** - * Updates a workbook that has already been added. + * Create a new workbook. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} resourceName The name of the Application Insights component * resource. * - * @param {object} workbookPayload Properties that need to be specified to - * create a new workbook or link. + * @param {object} workbookProperties Properties that need to be specified to + * create a new workbook. * - * @param {object} [workbookPayload.workbook] Workbook properties. If provided, - * it will be used to create new workbook. + * @param {string} [workbookProperties.kind] The kind of workbook. Choices are + * user and shared. Possible values include: 'user', 'shared' * - * @param {string} [workbookPayload.workbook.kind] The kind of workbook. - * Choices are user and shared. Possible values include: 'user', 'shared' + * @param {string} workbookProperties.workbookName The user-defined name of the + * workbook. * - * @param {string} workbookPayload.workbook.workbookName The user-defined name - * of the workbook. + * @param {string} workbookProperties.serializedData Configuration of this + * particular workbook. Configuration data is a string containing valid JSON * - * @param {string} workbookPayload.workbook.serializedData Configuration of - * this particular workbook. Configuration data is a string containing valid - * JSON + * @param {string} [workbookProperties.version] This instance's version of the + * data model. This can change as new features are added that can be marked + * workbook. * - * @param {string} [workbookPayload.workbook.version] This instance's version - * of the data model. This can change as new features are added that can be - * marked workbook. + * @param {string} workbookProperties.workbookId Internally assigned unique id + * of the workbook definition. * - * @param {string} workbookPayload.workbook.workbookId Internally assigned - * unique id of the workbook definition. - * - * @param {string} workbookPayload.workbook.sharedTypeKind Enum indicating if - * this workbook definition is owned by a specific user or is shared between - * all users with access to the Application Insights component. Possible values + * @param {string} workbookProperties.sharedTypeKind Enum indicating if this + * workbook definition is owned by a specific user or is shared between all + * users with access to the Application Insights component. Possible values * include: 'user', 'shared' * - * @param {string} workbookPayload.workbook.category Workbook category, as - * defined by the user at creation time. - * - * @param {array} [workbookPayload.workbook.workbookTags] A list of 0 or more - * tags that are associated with this workbook definition - * - * @param {string} workbookPayload.workbook.userId Unique user id of the - * specific user that owns this workbook. - * - * @param {string} [workbookPayload.workbook.sourceResourceId] Optional - * resourceId for a source resource. + * @param {string} workbookProperties.category Workbook category, as defined by + * the user at creation time. * - * @param {string} workbookPayload.workbook.location Resource location + * @param {array} [workbookProperties.workbookTags] A list of 0 or more tags + * that are associated with this workbook definition * - * @param {object} [workbookPayload.workbook.tags] Resource tags + * @param {string} workbookProperties.userId Unique user id of the specific + * user that owns this workbook. * - * @param {object} [workbookPayload.linkResource] LinkProperties. If provided, - * it will be used to create a link. + * @param {string} [workbookProperties.sourceResourceId] Optional resourceId + * for a source resource. * - * @param {string} [workbookPayload.linkResource.sourceId] The source Azure - * resource id + * @param {string} [workbookProperties.location] Resource location * - * @param {string} [workbookPayload.linkResource.targetId] The workbook Azure - * resource id - * - * @param {string} [workbookPayload.linkResource.category] The category of - * workbook + * @param {object} [workbookProperties.tags] Resource tags * * @param {object} [options] Optional Parameters. * @@ -633,7 +527,7 @@ function _create(resourceGroupName, resourceName, workbookPayload, options, call * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _update(resourceGroupName, resourceName, workbookPayload, options, callback) { +function _createOrUpdate(resourceGroupName, resourceName, workbookProperties, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -657,8 +551,8 @@ function _update(resourceGroupName, resourceName, workbookPayload, options, call 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 (workbookPayload === null || workbookPayload === undefined) { - throw new Error('workbookPayload cannot be null or undefined.'); + if (workbookProperties === null || workbookProperties === undefined) { + throw new Error('workbookProperties cannot be null or undefined.'); } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); @@ -681,7 +575,7 @@ function _update(resourceGroupName, resourceName, workbookPayload, options, call // Create HTTP transport objects let httpRequest = new WebResource(); - httpRequest.method = 'PATCH'; + httpRequest.method = 'PUT'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers @@ -703,14 +597,14 @@ function _update(resourceGroupName, resourceName, workbookPayload, options, call let requestContent = null; let requestModel = null; try { - if (workbookPayload !== null && workbookPayload !== undefined) { - let requestModelMapper = new client.models['WorkbookPayload']().mapper(); - requestModel = client.serialize(requestModelMapper, workbookPayload, 'workbookPayload'); + if (workbookProperties !== null && workbookProperties !== undefined) { + let requestModelMapper = new client.models['Workbook']().mapper(); + requestModel = client.serialize(requestModelMapper, workbookProperties, 'workbookProperties'); requestContent = JSON.stringify(requestModel); } } catch (error) { let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(workbookPayload, null, 2)}.`); + `payload - ${JSON.stringify(workbookProperties, null, 2)}.`); return callback(serializationError); } httpRequest.body = requestContent; @@ -720,7 +614,7 @@ function _update(resourceGroupName, resourceName, workbookPayload, options, call return callback(err); } let statusCode = response.statusCode; - if (statusCode !== 200) { + if (statusCode !== 200 && statusCode !== 201) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); @@ -736,7 +630,7 @@ function _update(resourceGroupName, resourceName, workbookPayload, options, call error.message = internalError ? internalError.message : parsedErrorResponse.message; } if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['WorkbookErrorResponse']().mapper(); + let resultMapper = new client.models['WorkbookError']().mapper(); error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); } } catch (defaultError) { @@ -766,18 +660,75 @@ function _update(resourceGroupName, resourceName, workbookPayload, options, call return callback(deserializationError); } } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Workbook']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } return callback(null, result, httpRequest, response); }); } /** - * Get a single workbook by its resourceName. + * Updates a workbook that has already been added. + * + * @param {string} resourceGroupName The name of the resource group. * * @param {string} resourceName The name of the Application Insights component * resource. * - * @param {string} location The name of location where workbook is stored. + * @param {object} workbookProperties Properties that need to be specified to + * create a new workbook. + * + * @param {string} [workbookProperties.kind] The kind of workbook. Choices are + * user and shared. Possible values include: 'user', 'shared' + * + * @param {string} workbookProperties.workbookName The user-defined name of the + * workbook. + * + * @param {string} workbookProperties.serializedData Configuration of this + * particular workbook. Configuration data is a string containing valid JSON + * + * @param {string} [workbookProperties.version] This instance's version of the + * data model. This can change as new features are added that can be marked + * workbook. + * + * @param {string} workbookProperties.workbookId Internally assigned unique id + * of the workbook definition. + * + * @param {string} workbookProperties.sharedTypeKind Enum indicating if this + * workbook definition is owned by a specific user or is shared between all + * users with access to the Application Insights component. Possible values + * include: 'user', 'shared' + * + * @param {string} workbookProperties.category Workbook category, as defined by + * the user at creation time. + * + * @param {array} [workbookProperties.workbookTags] A list of 0 or more tags + * that are associated with this workbook definition + * + * @param {string} workbookProperties.userId Unique user id of the specific + * user that owns this workbook. + * + * @param {string} [workbookProperties.sourceResourceId] Optional resourceId + * for a source resource. + * + * @param {string} [workbookProperties.location] Resource location + * + * @param {object} [workbookProperties.tags] Resource tags * * @param {object} [options] Optional Parameters. * @@ -797,7 +748,7 @@ function _update(resourceGroupName, resourceName, workbookPayload, options, call * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _get(resourceName, location, options, callback) { +function _update(resourceGroupName, resourceName, workbookProperties, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -812,15 +763,18 @@ function _get(resourceName, location, options, callback) { if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } if (resourceName === null || resourceName === undefined || typeof resourceName.valueOf() !== 'string') { throw new Error('resourceName cannot be null or undefined and it must be of type string.'); } - if (location === null || location === undefined || typeof location.valueOf() !== 'string') { - throw new Error('location cannot be null or undefined and it must be of type string.'); - } if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); } + if (workbookProperties === null || workbookProperties === undefined) { + throw new Error('workbookProperties cannot be null or undefined.'); + } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); } @@ -830,11 +784,11 @@ function _get(resourceName, location, options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/microsoft.insights/workbooks/{resourceName}'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'; requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); let queryParameters = []; - queryParameters.push('location=' + encodeURIComponent(location)); queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); @@ -842,7 +796,7 @@ function _get(resourceName, location, options, callback) { // Create HTTP transport objects let httpRequest = new WebResource(); - httpRequest.method = 'GET'; + httpRequest.method = 'PATCH'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers @@ -860,7 +814,21 @@ function _get(resourceName, location, options, callback) { } } } - httpRequest.body = null; + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (workbookProperties !== null && workbookProperties !== undefined) { + let requestModelMapper = new client.models['Workbook']().mapper(); + requestModel = client.serialize(requestModelMapper, workbookProperties, 'workbookProperties'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(workbookProperties, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; // Send Request return client.pipeline(httpRequest, (err, response, responseBody) => { if (err) { @@ -883,7 +851,7 @@ function _get(resourceName, location, options, callback) { error.message = internalError ? internalError.message : parsedErrorResponse.message; } if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['WorkbookErrorResponse']().mapper(); + let resultMapper = new client.models['WorkbookError']().mapper(); error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); } } catch (defaultError) { @@ -927,27 +895,20 @@ class Workbooks { constructor(client) { this.client = client; this._listByResourceGroup = _listByResourceGroup; + this._get = _get; this._deleteMethod = _deleteMethod; - this._create = _create; + this._createOrUpdate = _createOrUpdate; this._update = _update; - this._get = _get; } /** - * Get all Workbooks defined within a specified subscriptionId. It will get a - * list of workbooks or linked workbooks based on $filter clause. If sourceId - * is specified, it will get a list of linked workbboks. If a targetId is - * specified, it will get a list of workboks. When a targetId is specified, a - * resourceName is not required. Even if it is provided, it will be ignored. + * Get all Workbooks defined within a specified resource group and category. * - * @param {string} location The name of location where workbook is stored. + * @param {string} resourceGroupName The name of the resource group. * * @param {string} category Category of workbook to return. Possible values * include: 'workbook', 'TSG', 'performance', 'retention' * - * @param {string} resourceId Azure Resource id or any target workbook resource - * id. - * * @param {object} [options] Optional Parameters. * * @param {array} [options.tags] Tags presents on each workbook returned. @@ -961,15 +922,15 @@ class Workbooks { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ - listByResourceGroupWithHttpOperationResponse(location, category, resourceId, options) { + listByResourceGroupWithHttpOperationResponse(resourceGroupName, category, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._listByResourceGroup(location, category, resourceId, options, (err, result, request, response) => { + self._listByResourceGroup(resourceGroupName, category, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -980,20 +941,13 @@ class Workbooks { } /** - * Get all Workbooks defined within a specified subscriptionId. It will get a - * list of workbooks or linked workbooks based on $filter clause. If sourceId - * is specified, it will get a list of linked workbboks. If a targetId is - * specified, it will get a list of workboks. When a targetId is specified, a - * resourceName is not required. Even if it is provided, it will be ignored. + * Get all Workbooks defined within a specified resource group and category. * - * @param {string} location The name of location where workbook is stored. + * @param {string} resourceGroupName The name of the resource group. * * @param {string} category Category of workbook to return. Possible values * include: 'workbook', 'TSG', 'performance', 'retention' * - * @param {string} resourceId Azure Resource id or any target workbook resource - * id. - * * @param {object} [options] Optional Parameters. * * @param {array} [options.tags] Tags presents on each workbook returned. @@ -1012,7 +966,7 @@ class Workbooks { * * {Promise} A promise is returned * - * @resolve {WorkbookListResult} - The deserialized result object. + * @resolve {WorkbooksListResult} - The deserialized result object. * * @reject {Error} - The error object. * @@ -1021,13 +975,13 @@ class Workbooks { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link WorkbookListResult} for more information. + * See {@link WorkbooksListResult} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - listByResourceGroup(location, category, resourceId, options, optionalCallback) { + listByResourceGroup(resourceGroupName, category, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -1036,27 +990,25 @@ class Workbooks { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._listByResourceGroup(location, category, resourceId, options, (err, result, request, response) => { + self._listByResourceGroup(resourceGroupName, category, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._listByResourceGroup(location, category, resourceId, options, optionalCallback); + return self._listByResourceGroup(resourceGroupName, category, options, optionalCallback); } } /** - * Delete a workbook. + * Get a single workbook by its resourceName. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} resourceName The name of the Application Insights component * resource. * - * @param {string} location The name of location where workbook is stored. - * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -1064,15 +1016,15 @@ class Workbooks { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ - deleteMethodWithHttpOperationResponse(resourceGroupName, resourceName, location, options) { + getWithHttpOperationResponse(resourceGroupName, resourceName, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._deleteMethod(resourceGroupName, resourceName, location, options, (err, result, request, response) => { + self._get(resourceGroupName, resourceName, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -1083,15 +1035,13 @@ class Workbooks { } /** - * Delete a workbook. + * Get a single workbook by its resourceName. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} resourceName The name of the Application Insights component * resource. * - * @param {string} location The name of location where workbook is stored. - * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -1104,7 +1054,7 @@ class Workbooks { * * {Promise} A promise is returned * - * @resolve {null} - The deserialized result object. + * @resolve {Workbook} - The deserialized result object. * * @reject {Error} - The error object. * @@ -1112,13 +1062,14 @@ class Workbooks { * * {Error} err - The Error object if an error occurred, null otherwise. * - * {null} [result] - The deserialized result object if an error did not occur. + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Workbook} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - deleteMethod(resourceGroupName, resourceName, location, options, optionalCallback) { + get(resourceGroupName, resourceName, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -1127,81 +1078,25 @@ class Workbooks { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._deleteMethod(resourceGroupName, resourceName, location, options, (err, result, request, response) => { + self._get(resourceGroupName, resourceName, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._deleteMethod(resourceGroupName, resourceName, location, options, optionalCallback); + return self._get(resourceGroupName, resourceName, options, optionalCallback); } } /** - * Create a new workbook. + * Delete a workbook. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} resourceName The name of the Application Insights component * resource. * - * @param {object} workbookPayload Properties that need to be specified to - * create a new workbook or link. - * - * @param {object} [workbookPayload.workbook] Workbook properties. If provided, - * it will be used to create new workbook. - * - * @param {string} [workbookPayload.workbook.kind] The kind of workbook. - * Choices are user and shared. Possible values include: 'user', 'shared' - * - * @param {string} workbookPayload.workbook.workbookName The user-defined name - * of the workbook. - * - * @param {string} workbookPayload.workbook.serializedData Configuration of - * this particular workbook. Configuration data is a string containing valid - * JSON - * - * @param {string} [workbookPayload.workbook.version] This instance's version - * of the data model. This can change as new features are added that can be - * marked workbook. - * - * @param {string} workbookPayload.workbook.workbookId Internally assigned - * unique id of the workbook definition. - * - * @param {string} workbookPayload.workbook.sharedTypeKind Enum indicating if - * this workbook definition is owned by a specific user or is shared between - * all users with access to the Application Insights component. Possible values - * include: 'user', 'shared' - * - * @param {string} workbookPayload.workbook.category Workbook category, as - * defined by the user at creation time. - * - * @param {array} [workbookPayload.workbook.workbookTags] A list of 0 or more - * tags that are associated with this workbook definition - * - * @param {string} workbookPayload.workbook.userId Unique user id of the - * specific user that owns this workbook. - * - * @param {string} [workbookPayload.workbook.sourceResourceId] Optional - * resourceId for a source resource. - * - * @param {string} workbookPayload.workbook.location Resource location - * - * @param {object} [workbookPayload.workbook.tags] Resource tags - * - * @param {object} [workbookPayload.linkResource] LinkProperties. If provided, - * it will be used to create a link. - * - * @param {string} [workbookPayload.linkResource.sourceId] The source Azure - * resource id - * - * @param {string} [workbookPayload.linkResource.targetId] The workbook Azure - * resource id - * - * @param {string} [workbookPayload.linkResource.category] The category of - * workbook - * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -1209,15 +1104,15 @@ class Workbooks { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ - createWithHttpOperationResponse(resourceGroupName, resourceName, workbookPayload, options) { + deleteMethodWithHttpOperationResponse(resourceGroupName, resourceName, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._create(resourceGroupName, resourceName, workbookPayload, options, (err, result, request, response) => { + self._deleteMethod(resourceGroupName, resourceName, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -1228,69 +1123,13 @@ class Workbooks { } /** - * Create a new workbook. + * Delete a workbook. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} resourceName The name of the Application Insights component * resource. * - * @param {object} workbookPayload Properties that need to be specified to - * create a new workbook or link. - * - * @param {object} [workbookPayload.workbook] Workbook properties. If provided, - * it will be used to create new workbook. - * - * @param {string} [workbookPayload.workbook.kind] The kind of workbook. - * Choices are user and shared. Possible values include: 'user', 'shared' - * - * @param {string} workbookPayload.workbook.workbookName The user-defined name - * of the workbook. - * - * @param {string} workbookPayload.workbook.serializedData Configuration of - * this particular workbook. Configuration data is a string containing valid - * JSON - * - * @param {string} [workbookPayload.workbook.version] This instance's version - * of the data model. This can change as new features are added that can be - * marked workbook. - * - * @param {string} workbookPayload.workbook.workbookId Internally assigned - * unique id of the workbook definition. - * - * @param {string} workbookPayload.workbook.sharedTypeKind Enum indicating if - * this workbook definition is owned by a specific user or is shared between - * all users with access to the Application Insights component. Possible values - * include: 'user', 'shared' - * - * @param {string} workbookPayload.workbook.category Workbook category, as - * defined by the user at creation time. - * - * @param {array} [workbookPayload.workbook.workbookTags] A list of 0 or more - * tags that are associated with this workbook definition - * - * @param {string} workbookPayload.workbook.userId Unique user id of the - * specific user that owns this workbook. - * - * @param {string} [workbookPayload.workbook.sourceResourceId] Optional - * resourceId for a source resource. - * - * @param {string} workbookPayload.workbook.location Resource location - * - * @param {object} [workbookPayload.workbook.tags] Resource tags - * - * @param {object} [workbookPayload.linkResource] LinkProperties. If provided, - * it will be used to create a link. - * - * @param {string} [workbookPayload.linkResource.sourceId] The source Azure - * resource id - * - * @param {string} [workbookPayload.linkResource.targetId] The workbook Azure - * resource id - * - * @param {string} [workbookPayload.linkResource.category] The category of - * workbook - * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -1303,7 +1142,7 @@ class Workbooks { * * {Promise} A promise is returned * - * @resolve {Workbook} - The deserialized result object. + * @resolve {null} - The deserialized result object. * * @reject {Error} - The error object. * @@ -1311,14 +1150,13 @@ class Workbooks { * * {Error} err - The Error object if an error occurred, null otherwise. * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link Workbook} for more information. + * {null} [result] - The deserialized result object if an error did not occur. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - create(resourceGroupName, resourceName, workbookPayload, options, optionalCallback) { + deleteMethod(resourceGroupName, resourceName, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -1327,80 +1165,64 @@ class Workbooks { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._create(resourceGroupName, resourceName, workbookPayload, options, (err, result, request, response) => { + self._deleteMethod(resourceGroupName, resourceName, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._create(resourceGroupName, resourceName, workbookPayload, options, optionalCallback); + return self._deleteMethod(resourceGroupName, resourceName, options, optionalCallback); } } /** - * Updates a workbook that has already been added. + * Create a new workbook. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} resourceName The name of the Application Insights component * resource. * - * @param {object} workbookPayload Properties that need to be specified to - * create a new workbook or link. - * - * @param {object} [workbookPayload.workbook] Workbook properties. If provided, - * it will be used to create new workbook. + * @param {object} workbookProperties Properties that need to be specified to + * create a new workbook. * - * @param {string} [workbookPayload.workbook.kind] The kind of workbook. - * Choices are user and shared. Possible values include: 'user', 'shared' + * @param {string} [workbookProperties.kind] The kind of workbook. Choices are + * user and shared. Possible values include: 'user', 'shared' * - * @param {string} workbookPayload.workbook.workbookName The user-defined name - * of the workbook. + * @param {string} workbookProperties.workbookName The user-defined name of the + * workbook. * - * @param {string} workbookPayload.workbook.serializedData Configuration of - * this particular workbook. Configuration data is a string containing valid - * JSON + * @param {string} workbookProperties.serializedData Configuration of this + * particular workbook. Configuration data is a string containing valid JSON * - * @param {string} [workbookPayload.workbook.version] This instance's version - * of the data model. This can change as new features are added that can be - * marked workbook. + * @param {string} [workbookProperties.version] This instance's version of the + * data model. This can change as new features are added that can be marked + * workbook. * - * @param {string} workbookPayload.workbook.workbookId Internally assigned - * unique id of the workbook definition. + * @param {string} workbookProperties.workbookId Internally assigned unique id + * of the workbook definition. * - * @param {string} workbookPayload.workbook.sharedTypeKind Enum indicating if - * this workbook definition is owned by a specific user or is shared between - * all users with access to the Application Insights component. Possible values + * @param {string} workbookProperties.sharedTypeKind Enum indicating if this + * workbook definition is owned by a specific user or is shared between all + * users with access to the Application Insights component. Possible values * include: 'user', 'shared' * - * @param {string} workbookPayload.workbook.category Workbook category, as - * defined by the user at creation time. - * - * @param {array} [workbookPayload.workbook.workbookTags] A list of 0 or more - * tags that are associated with this workbook definition - * - * @param {string} workbookPayload.workbook.userId Unique user id of the - * specific user that owns this workbook. - * - * @param {string} [workbookPayload.workbook.sourceResourceId] Optional - * resourceId for a source resource. - * - * @param {string} workbookPayload.workbook.location Resource location + * @param {string} workbookProperties.category Workbook category, as defined by + * the user at creation time. * - * @param {object} [workbookPayload.workbook.tags] Resource tags + * @param {array} [workbookProperties.workbookTags] A list of 0 or more tags + * that are associated with this workbook definition * - * @param {object} [workbookPayload.linkResource] LinkProperties. If provided, - * it will be used to create a link. + * @param {string} workbookProperties.userId Unique user id of the specific + * user that owns this workbook. * - * @param {string} [workbookPayload.linkResource.sourceId] The source Azure - * resource id + * @param {string} [workbookProperties.sourceResourceId] Optional resourceId + * for a source resource. * - * @param {string} [workbookPayload.linkResource.targetId] The workbook Azure - * resource id + * @param {string} [workbookProperties.location] Resource location * - * @param {string} [workbookPayload.linkResource.category] The category of - * workbook + * @param {object} [workbookProperties.tags] Resource tags * * @param {object} [options] Optional Parameters. * @@ -1413,11 +1235,11 @@ class Workbooks { * * @reject {Error} - The error object. */ - updateWithHttpOperationResponse(resourceGroupName, resourceName, workbookPayload, options) { + createOrUpdateWithHttpOperationResponse(resourceGroupName, resourceName, workbookProperties, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._update(resourceGroupName, resourceName, workbookPayload, options, (err, result, request, response) => { + self._createOrUpdate(resourceGroupName, resourceName, workbookProperties, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -1428,68 +1250,52 @@ class Workbooks { } /** - * Updates a workbook that has already been added. + * Create a new workbook. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} resourceName The name of the Application Insights component * resource. * - * @param {object} workbookPayload Properties that need to be specified to - * create a new workbook or link. + * @param {object} workbookProperties Properties that need to be specified to + * create a new workbook. * - * @param {object} [workbookPayload.workbook] Workbook properties. If provided, - * it will be used to create new workbook. + * @param {string} [workbookProperties.kind] The kind of workbook. Choices are + * user and shared. Possible values include: 'user', 'shared' * - * @param {string} [workbookPayload.workbook.kind] The kind of workbook. - * Choices are user and shared. Possible values include: 'user', 'shared' + * @param {string} workbookProperties.workbookName The user-defined name of the + * workbook. * - * @param {string} workbookPayload.workbook.workbookName The user-defined name - * of the workbook. + * @param {string} workbookProperties.serializedData Configuration of this + * particular workbook. Configuration data is a string containing valid JSON * - * @param {string} workbookPayload.workbook.serializedData Configuration of - * this particular workbook. Configuration data is a string containing valid - * JSON + * @param {string} [workbookProperties.version] This instance's version of the + * data model. This can change as new features are added that can be marked + * workbook. * - * @param {string} [workbookPayload.workbook.version] This instance's version - * of the data model. This can change as new features are added that can be - * marked workbook. + * @param {string} workbookProperties.workbookId Internally assigned unique id + * of the workbook definition. * - * @param {string} workbookPayload.workbook.workbookId Internally assigned - * unique id of the workbook definition. - * - * @param {string} workbookPayload.workbook.sharedTypeKind Enum indicating if - * this workbook definition is owned by a specific user or is shared between - * all users with access to the Application Insights component. Possible values + * @param {string} workbookProperties.sharedTypeKind Enum indicating if this + * workbook definition is owned by a specific user or is shared between all + * users with access to the Application Insights component. Possible values * include: 'user', 'shared' * - * @param {string} workbookPayload.workbook.category Workbook category, as - * defined by the user at creation time. - * - * @param {array} [workbookPayload.workbook.workbookTags] A list of 0 or more - * tags that are associated with this workbook definition + * @param {string} workbookProperties.category Workbook category, as defined by + * the user at creation time. * - * @param {string} workbookPayload.workbook.userId Unique user id of the - * specific user that owns this workbook. + * @param {array} [workbookProperties.workbookTags] A list of 0 or more tags + * that are associated with this workbook definition * - * @param {string} [workbookPayload.workbook.sourceResourceId] Optional - * resourceId for a source resource. + * @param {string} workbookProperties.userId Unique user id of the specific + * user that owns this workbook. * - * @param {string} workbookPayload.workbook.location Resource location + * @param {string} [workbookProperties.sourceResourceId] Optional resourceId + * for a source resource. * - * @param {object} [workbookPayload.workbook.tags] Resource tags + * @param {string} [workbookProperties.location] Resource location * - * @param {object} [workbookPayload.linkResource] LinkProperties. If provided, - * it will be used to create a link. - * - * @param {string} [workbookPayload.linkResource.sourceId] The source Azure - * resource id - * - * @param {string} [workbookPayload.linkResource.targetId] The workbook Azure - * resource id - * - * @param {string} [workbookPayload.linkResource.category] The category of - * workbook + * @param {object} [workbookProperties.tags] Resource tags * * @param {object} [options] Optional Parameters. * @@ -1518,7 +1324,7 @@ class Workbooks { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - update(resourceGroupName, resourceName, workbookPayload, options, optionalCallback) { + createOrUpdate(resourceGroupName, resourceName, workbookProperties, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -1527,24 +1333,64 @@ class Workbooks { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._update(resourceGroupName, resourceName, workbookPayload, options, (err, result, request, response) => { + self._createOrUpdate(resourceGroupName, resourceName, workbookProperties, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._update(resourceGroupName, resourceName, workbookPayload, options, optionalCallback); + return self._createOrUpdate(resourceGroupName, resourceName, workbookProperties, options, optionalCallback); } } /** - * Get a single workbook by its resourceName. + * Updates a workbook that has already been added. + * + * @param {string} resourceGroupName The name of the resource group. * * @param {string} resourceName The name of the Application Insights component * resource. * - * @param {string} location The name of location where workbook is stored. + * @param {object} workbookProperties Properties that need to be specified to + * create a new workbook. + * + * @param {string} [workbookProperties.kind] The kind of workbook. Choices are + * user and shared. Possible values include: 'user', 'shared' + * + * @param {string} workbookProperties.workbookName The user-defined name of the + * workbook. + * + * @param {string} workbookProperties.serializedData Configuration of this + * particular workbook. Configuration data is a string containing valid JSON + * + * @param {string} [workbookProperties.version] This instance's version of the + * data model. This can change as new features are added that can be marked + * workbook. + * + * @param {string} workbookProperties.workbookId Internally assigned unique id + * of the workbook definition. + * + * @param {string} workbookProperties.sharedTypeKind Enum indicating if this + * workbook definition is owned by a specific user or is shared between all + * users with access to the Application Insights component. Possible values + * include: 'user', 'shared' + * + * @param {string} workbookProperties.category Workbook category, as defined by + * the user at creation time. + * + * @param {array} [workbookProperties.workbookTags] A list of 0 or more tags + * that are associated with this workbook definition + * + * @param {string} workbookProperties.userId Unique user id of the specific + * user that owns this workbook. + * + * @param {string} [workbookProperties.sourceResourceId] Optional resourceId + * for a source resource. + * + * @param {string} [workbookProperties.location] Resource location + * + * @param {object} [workbookProperties.tags] Resource tags * * @param {object} [options] Optional Parameters. * @@ -1557,11 +1403,11 @@ class Workbooks { * * @reject {Error} - The error object. */ - getWithHttpOperationResponse(resourceName, location, options) { + updateWithHttpOperationResponse(resourceGroupName, resourceName, workbookProperties, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._get(resourceName, location, options, (err, result, request, response) => { + self._update(resourceGroupName, resourceName, workbookProperties, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -1572,12 +1418,52 @@ class Workbooks { } /** - * Get a single workbook by its resourceName. + * Updates a workbook that has already been added. + * + * @param {string} resourceGroupName The name of the resource group. * * @param {string} resourceName The name of the Application Insights component * resource. * - * @param {string} location The name of location where workbook is stored. + * @param {object} workbookProperties Properties that need to be specified to + * create a new workbook. + * + * @param {string} [workbookProperties.kind] The kind of workbook. Choices are + * user and shared. Possible values include: 'user', 'shared' + * + * @param {string} workbookProperties.workbookName The user-defined name of the + * workbook. + * + * @param {string} workbookProperties.serializedData Configuration of this + * particular workbook. Configuration data is a string containing valid JSON + * + * @param {string} [workbookProperties.version] This instance's version of the + * data model. This can change as new features are added that can be marked + * workbook. + * + * @param {string} workbookProperties.workbookId Internally assigned unique id + * of the workbook definition. + * + * @param {string} workbookProperties.sharedTypeKind Enum indicating if this + * workbook definition is owned by a specific user or is shared between all + * users with access to the Application Insights component. Possible values + * include: 'user', 'shared' + * + * @param {string} workbookProperties.category Workbook category, as defined by + * the user at creation time. + * + * @param {array} [workbookProperties.workbookTags] A list of 0 or more tags + * that are associated with this workbook definition + * + * @param {string} workbookProperties.userId Unique user id of the specific + * user that owns this workbook. + * + * @param {string} [workbookProperties.sourceResourceId] Optional resourceId + * for a source resource. + * + * @param {string} [workbookProperties.location] Resource location + * + * @param {object} [workbookProperties.tags] Resource tags * * @param {object} [options] Optional Parameters. * @@ -1606,7 +1492,7 @@ class Workbooks { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - get(resourceName, location, options, optionalCallback) { + update(resourceGroupName, resourceName, workbookProperties, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -1615,14 +1501,14 @@ class Workbooks { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._get(resourceName, location, options, (err, result, request, response) => { + self._update(resourceGroupName, resourceName, workbookProperties, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._get(resourceName, location, options, optionalCallback); + return self._update(resourceGroupName, resourceName, workbookProperties, options, optionalCallback); } }