diff --git a/lib/services/websiteManagement2/LICENSE.txt b/lib/services/applicationinsights/lib/LICENSE.txt similarity index 98% rename from lib/services/websiteManagement2/LICENSE.txt rename to lib/services/applicationinsights/lib/LICENSE.txt index a70e8cf660..5431ba98b9 100644 --- a/lib/services/websiteManagement2/LICENSE.txt +++ b/lib/services/applicationinsights/lib/LICENSE.txt @@ -1,21 +1,21 @@ -The MIT License (MIT) - -Copyright (c) 2018 Microsoft - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +The MIT License (MIT) + +Copyright (c) 2018 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/lib/services/applicationinsights/lib/applicationInsightsManagementClient.d.ts b/lib/services/applicationinsights/lib/applicationInsightsManagementClient.d.ts index 5503502dc0..710c74dd2b 100644 --- a/lib/services/applicationinsights/lib/applicationInsightsManagementClient.d.ts +++ b/lib/services/applicationinsights/lib/applicationInsightsManagementClient.d.ts @@ -34,11 +34,11 @@ export default class ApplicationInsightsManagementClient extends AzureServiceCli * * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy * - * @param {string} [options.acceptLanguage] - Gets or sets the preferred language for the response. + * @param {string} [options.acceptLanguage] - The preferred language for the response. * - * @param {number} [options.longRunningOperationRetryTimeout] - Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * @param {number} [options.longRunningOperationRetryTimeout] - The retry timeout in seconds for Long Running Operations. Default value is 30. * - * @param {boolean} [options.generateClientRequestId] - When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * @param {boolean} [options.generateClientRequestId] - Whether a unique x-ms-client-request-id should be generated. When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. * */ constructor(credentials: ServiceClientCredentials, subscriptionId: string, baseUri?: string, options?: AzureServiceClientOptions); @@ -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..71a33ea8e7 100644 --- a/lib/services/applicationinsights/lib/applicationInsightsManagementClient.js +++ b/lib/services/applicationinsights/lib/applicationInsightsManagementClient.js @@ -34,9 +34,9 @@ class ApplicationInsightsManagementClient extends ServiceClient { * @param {object} [options.requestOptions] - Options for the underlying request object * {@link https://github.com/request/request#requestoptions-callback Options doc} * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy - * @param {string} [options.acceptLanguage] - Gets or sets the preferred language for the response. - * @param {number} [options.longRunningOperationRetryTimeout] - Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. - * @param {boolean} [options.generateClientRequestId] - When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * @param {string} [options.acceptLanguage] - The preferred language for the response. + * @param {number} [options.longRunningOperationRetryTimeout] - The retry timeout in seconds for Long Running Operations. Default value is 30. + * @param {boolean} [options.generateClientRequestId] - Whether a unique x-ms-client-request-id should be generated. When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. */ constructor(credentials, subscriptionId, baseUri, options) { if (credentials === null || credentials === undefined) { @@ -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/lib/applicationInsightsManagementClient.d.ts b/lib/services/applicationinsights/lib/lib/applicationInsightsManagementClient.d.ts new file mode 100644 index 0000000000..4b16ffe9a7 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/applicationInsightsManagementClient.d.ts @@ -0,0 +1,78 @@ +/* + * 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. + */ + +import { ServiceClientCredentials } from 'ms-rest'; +import { AzureServiceClient, AzureServiceClientOptions } from 'ms-rest-azure'; +import * as models from "./models"; +import * as operations from "./operations"; + +export default class ApplicationInsightsManagementClient extends AzureServiceClient { + /** + * Initializes a new instance of the ApplicationInsightsManagementClient class. + * @constructor + * + * @class + * @param {credentials} credentials - Credentials needed for the client to connect to Azure. + * + * @param {string} subscriptionId - The Azure subscription ID. + * + * @param {string} [baseUri] - The base URI of the service. + * + * @param {object} [options] - The parameter options + * + * @param {Array} [options.filters] - Filters to be added to the request pipeline + * + * @param {object} [options.requestOptions] - Options for the underlying request object + * {@link https://github.com/request/request#requestoptions-callback Options doc} + * + * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy + * + * @param {string} [options.acceptLanguage] - Gets or sets the preferred language for the response. + * + * @param {number} [options.longRunningOperationRetryTimeout] - Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @param {boolean} [options.generateClientRequestId] - When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + */ + constructor(credentials: ServiceClientCredentials, subscriptionId: string, baseUri?: string, options?: AzureServiceClientOptions); + + credentials: ServiceClientCredentials; + + apiVersion: string; + + subscriptionId: string; + + acceptLanguage: string; + + longRunningOperationRetryTimeout: number; + + generateClientRequestId: boolean; + + // Operation groups + operations: operations.Operations; + annotations: operations.Annotations; + aPIKeys: operations.APIKeys; + exportConfigurations: operations.ExportConfigurations; + componentCurrentBillingFeatures: operations.ComponentCurrentBillingFeatures; + componentQuotaStatus: operations.ComponentQuotaStatus; + componentFeatureCapabilities: operations.ComponentFeatureCapabilities; + componentAvailableFeatures: operations.ComponentAvailableFeatures; + proactiveDetectionConfigurations: operations.ProactiveDetectionConfigurations; + components: operations.Components; + workItemConfigurations: operations.WorkItemConfigurations; + favorites: operations.Favorites; + favorite: operations.Favorite; + webTestLocations: operations.WebTestLocations; + webTests: operations.WebTests; + workbooksOperations: operations.WorkbooksOperations; + workbookOperations: operations.WorkbookOperations; +} + +export { ApplicationInsightsManagementClient, models as ApplicationInsightsManagementModels }; diff --git a/lib/services/applicationinsights/lib/lib/applicationInsightsManagementClient.js b/lib/services/applicationinsights/lib/lib/applicationInsightsManagementClient.js new file mode 100644 index 0000000000..56f8314e01 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/applicationInsightsManagementClient.js @@ -0,0 +1,101 @@ +/* + * 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. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const ServiceClient = msRestAzure.AzureServiceClient; + +const models = require('./models'); +const operations = require('./operations'); + + +/** Class representing a ApplicationInsightsManagementClient. */ +class ApplicationInsightsManagementClient extends ServiceClient { + /** + * Create a ApplicationInsightsManagementClient. + * @param {credentials} credentials - Credentials needed for the client to connect to Azure. + * @param {string} subscriptionId - The Azure subscription ID. + * @param {string} [baseUri] - The base URI of the service. + * @param {object} [options] - The parameter options + * @param {Array} [options.filters] - Filters to be added to the request pipeline + * @param {object} [options.requestOptions] - Options for the underlying request object + * {@link https://github.com/request/request#requestoptions-callback Options doc} + * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy + * @param {string} [options.acceptLanguage] - Gets or sets the preferred language for the response. + * @param {number} [options.longRunningOperationRetryTimeout] - Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * @param {boolean} [options.generateClientRequestId] - When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + */ + constructor(credentials, subscriptionId, baseUri, options) { + if (credentials === null || credentials === undefined) { + throw new Error('\'credentials\' cannot be null.'); + } + if (subscriptionId === null || subscriptionId === undefined) { + throw new Error('\'subscriptionId\' cannot be null.'); + } + + if (!options) options = {}; + + super(credentials, options); + + this.apiVersion = '2015-05-01'; + this.acceptLanguage = 'en-US'; + this.longRunningOperationRetryTimeout = 30; + this.generateClientRequestId = true; + this.baseUri = baseUri; + if (!this.baseUri) { + this.baseUri = 'https://management.azure.com'; + } + this.credentials = credentials; + this.subscriptionId = subscriptionId; + + let packageInfo = this.getPackageJsonInfo(__dirname); + this.addUserAgentInfo(`${packageInfo.name}/${packageInfo.version}`); + if(options.acceptLanguage !== null && options.acceptLanguage !== undefined) { + this.acceptLanguage = options.acceptLanguage; + } + if(options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) { + this.longRunningOperationRetryTimeout = options.longRunningOperationRetryTimeout; + } + if(options.generateClientRequestId !== null && options.generateClientRequestId !== undefined) { + this.generateClientRequestId = options.generateClientRequestId; + } + this.operations = new operations.Operations(this); + this.annotations = new operations.Annotations(this); + this.aPIKeys = new operations.APIKeys(this); + this.exportConfigurations = new operations.ExportConfigurations(this); + this.componentCurrentBillingFeatures = new operations.ComponentCurrentBillingFeatures(this); + this.componentQuotaStatus = new operations.ComponentQuotaStatus(this); + this.componentFeatureCapabilities = new operations.ComponentFeatureCapabilities(this); + this.componentAvailableFeatures = new operations.ComponentAvailableFeatures(this); + this.proactiveDetectionConfigurations = new operations.ProactiveDetectionConfigurations(this); + 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.workbooksOperations = new operations.WorkbooksOperations(this); + this.workbookOperations = new operations.WorkbookOperations(this); + this.models = models; + msRest.addSerializationMixin(this); + } + +} + +module.exports = ApplicationInsightsManagementClient; +module.exports['default'] = ApplicationInsightsManagementClient; +module.exports.ApplicationInsightsManagementClient = ApplicationInsightsManagementClient; +module.exports.ApplicationInsightsManagementModels = models; diff --git a/lib/services/applicationinsights/lib/lib/models/aPIKeyRequest.js b/lib/services/applicationinsights/lib/lib/models/aPIKeyRequest.js new file mode 100644 index 0000000000..7eba399145 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/aPIKeyRequest.js @@ -0,0 +1,84 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * An Application Insights component API Key createion request definition. + * + */ +class APIKeyRequest { + /** + * Create a APIKeyRequest. + * @member {string} [name] The name of the API Key. + * @member {array} [linkedReadProperties] The read access rights of this API + * Key. + * @member {array} [linkedWriteProperties] The write access rights of this + * API Key. + */ + constructor() { + } + + /** + * Defines the metadata of APIKeyRequest + * + * @returns {object} metadata of APIKeyRequest + * + */ + mapper() { + return { + required: false, + serializedName: 'APIKeyRequest', + type: { + name: 'Composite', + className: 'APIKeyRequest', + modelProperties: { + name: { + required: false, + serializedName: 'name', + type: { + name: 'String' + } + }, + linkedReadProperties: { + required: false, + serializedName: 'linkedReadProperties', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + linkedWriteProperties: { + required: false, + serializedName: 'linkedWriteProperties', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = APIKeyRequest; diff --git a/lib/services/applicationinsights/lib/lib/models/annotation.js b/lib/services/applicationinsights/lib/lib/models/annotation.js new file mode 100644 index 0000000000..49216c72a4 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/annotation.js @@ -0,0 +1,95 @@ +/* + * 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'; + +/** + * Annotation associated with an application insights resource. + * + */ +class Annotation { + /** + * Create a Annotation. + * @member {string} [annotationName] Name of annotation + * @member {string} [category] Category of annotation, free form + * @member {date} [eventTime] Time when event occurred + * @member {string} [id] Unique Id for annotation + * @member {string} [properties] Serialized JSON object for detailed + * properties + * @member {string} [relatedAnnotation] Related parent annotation if any. + * Default value: 'null' . + */ + constructor() { + } + + /** + * Defines the metadata of Annotation + * + * @returns {object} metadata of Annotation + * + */ + mapper() { + return { + required: false, + serializedName: 'Annotation', + type: { + name: 'Composite', + className: 'Annotation', + modelProperties: { + annotationName: { + required: false, + serializedName: 'AnnotationName', + type: { + name: 'String' + } + }, + category: { + required: false, + serializedName: 'Category', + type: { + name: 'String' + } + }, + eventTime: { + required: false, + serializedName: 'EventTime', + type: { + name: 'DateTime' + } + }, + id: { + required: false, + serializedName: 'Id', + type: { + name: 'String' + } + }, + properties: { + required: false, + serializedName: 'Properties', + type: { + name: 'String' + } + }, + relatedAnnotation: { + required: false, + serializedName: 'RelatedAnnotation', + defaultValue: 'null', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = Annotation; diff --git a/lib/services/applicationinsights/lib/lib/models/annotationError.js b/lib/services/applicationinsights/lib/lib/models/annotationError.js new file mode 100644 index 0000000000..4b9fc68492 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/annotationError.js @@ -0,0 +1,74 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Error associated with trying to create annotation with Id that already exist + * + */ +class AnnotationError { + /** + * Create a AnnotationError. + * @member {string} [code] Error detail code and explanation + * @member {string} [message] Error message + * @member {object} [innererror] + * @member {string} [innererror.diagnosticcontext] Provides correlation for + * request + * @member {date} [innererror.time] Request time + */ + constructor() { + } + + /** + * Defines the metadata of AnnotationError + * + * @returns {object} metadata of AnnotationError + * + */ + mapper() { + return { + required: false, + serializedName: 'AnnotationError', + type: { + name: 'Composite', + className: 'AnnotationError', + modelProperties: { + code: { + required: false, + serializedName: 'code', + type: { + name: 'String' + } + }, + message: { + required: false, + serializedName: 'message', + type: { + name: 'String' + } + }, + innererror: { + required: false, + serializedName: 'innererror', + type: { + name: 'Composite', + className: 'InnerError' + } + } + } + } + }; + } +} + +module.exports = AnnotationError; diff --git a/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponent.js b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponent.js new file mode 100644 index 0000000000..d6271996d3 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponent.js @@ -0,0 +1,231 @@ +/* + * 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 Application Insights component definition. + * + * @extends models['Resource'] + */ +class ApplicationInsightsComponent extends models['Resource'] { + /** + * Create a ApplicationInsightsComponent. + * @member {string} kind The kind of application that this component refers + * to, used to customize UI. This value is a freeform string, values should + * typically be one of the following: web, ios, other, store, java, phone. + * @member {string} [applicationId] The unique ID of your application. This + * field mirrors the 'Name' field and cannot be changed. + * @member {string} [appId] Application Insights Unique ID for your + * Application. + * @member {string} applicationType Type of application being monitored. + * Possible values include: 'web', 'other'. Default value: 'web' . + * @member {string} [flowType] Used by the Application Insights system to + * determine what kind of flow this component was created by. This is to be + * set to 'Bluefield' when creating/updating a component via the REST API. + * Possible values include: 'Bluefield'. Default value: 'Bluefield' . + * @member {string} [requestSource] Describes what tool created this + * Application Insights component. Customers using this API should set this + * to the default 'rest'. Possible values include: 'rest'. Default value: + * 'rest' . + * @member {string} [instrumentationKey] Application Insights Instrumentation + * key. A read-only value that applications can use to identify the + * destination for all telemetry sent to Azure Application Insights. This + * value will be supplied upon construction of each new Application Insights + * component. + * @member {date} [creationDate] Creation Date for the Application Insights + * component, in ISO 8601 format. + * @member {string} [tenantId] Azure Tenant Id. + * @member {string} [hockeyAppId] The unique application ID created when a + * new application is added to HockeyApp, used for communications with + * HockeyApp. + * @member {string} [hockeyAppToken] Token used to authenticate + * communications with between Application Insights and HockeyApp. + * @member {string} [provisioningState] Current state of this component: + * whether or not is has been provisioned within the resource group it is + * defined. Users cannot change this value but are able to read from it. + * Values will include Succeeded, Deploying, Canceled, and Failed. + * @member {number} [samplingPercentage] Percentage of the data produced by + * the application being monitored that is being sampled for Application + * Insights telemetry. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ApplicationInsightsComponent + * + * @returns {object} metadata of ApplicationInsightsComponent + * + */ + mapper() { + return { + required: false, + serializedName: 'ApplicationInsightsComponent', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponent', + 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' + } + } + } + }, + kind: { + required: true, + serializedName: 'kind', + type: { + name: 'String' + } + }, + applicationId: { + required: false, + readOnly: true, + serializedName: 'properties.ApplicationId', + type: { + name: 'String' + } + }, + appId: { + required: false, + readOnly: true, + serializedName: 'properties.AppId', + type: { + name: 'String' + } + }, + applicationType: { + required: true, + serializedName: 'properties.Application_Type', + defaultValue: 'web', + type: { + name: 'String' + } + }, + flowType: { + required: false, + serializedName: 'properties.Flow_Type', + defaultValue: 'Bluefield', + type: { + name: 'String' + } + }, + requestSource: { + required: false, + serializedName: 'properties.Request_Source', + defaultValue: 'rest', + type: { + name: 'String' + } + }, + instrumentationKey: { + required: false, + readOnly: true, + serializedName: 'properties.InstrumentationKey', + type: { + name: 'String' + } + }, + creationDate: { + required: false, + readOnly: true, + serializedName: 'properties.CreationDate', + type: { + name: 'DateTime' + } + }, + tenantId: { + required: false, + readOnly: true, + serializedName: 'properties.TenantId', + type: { + name: 'String' + } + }, + hockeyAppId: { + required: false, + serializedName: 'properties.HockeyAppId', + type: { + name: 'String' + } + }, + hockeyAppToken: { + required: false, + readOnly: true, + serializedName: 'properties.HockeyAppToken', + type: { + name: 'String' + } + }, + provisioningState: { + required: false, + readOnly: true, + serializedName: 'properties.provisioningState', + type: { + name: 'String' + } + }, + samplingPercentage: { + required: false, + serializedName: 'properties.SamplingPercentage', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = ApplicationInsightsComponent; diff --git a/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentAPIKey.js b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentAPIKey.js new file mode 100644 index 0000000000..8495c977f4 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentAPIKey.js @@ -0,0 +1,112 @@ +/* + * 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'; + +/** + * Properties that define an API key of an Application Insights Component. + * + */ +class ApplicationInsightsComponentAPIKey { + /** + * Create a ApplicationInsightsComponentAPIKey. + * @member {string} [id] The unique ID of the API key inside an Applciation + * Insights component. It is auto generated when the API key is created. + * @member {string} [apiKey] The API key value. It will be only return once + * when the API Key was created. + * @member {string} [createdDate] The create date of this API key. + * @member {string} [name] The name of the API key. + * @member {array} [linkedReadProperties] The read access rights of this API + * Key. + * @member {array} [linkedWriteProperties] The write access rights of this + * API Key. + */ + constructor() { + } + + /** + * Defines the metadata of ApplicationInsightsComponentAPIKey + * + * @returns {object} metadata of ApplicationInsightsComponentAPIKey + * + */ + mapper() { + return { + required: false, + serializedName: 'ApplicationInsightsComponentAPIKey', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentAPIKey', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + apiKey: { + required: false, + readOnly: true, + serializedName: 'apiKey', + type: { + name: 'String' + } + }, + createdDate: { + required: false, + serializedName: 'createdDate', + type: { + name: 'String' + } + }, + name: { + required: false, + serializedName: 'name', + type: { + name: 'String' + } + }, + linkedReadProperties: { + required: false, + serializedName: 'linkedReadProperties', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + linkedWriteProperties: { + required: false, + serializedName: 'linkedWriteProperties', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = ApplicationInsightsComponentAPIKey; diff --git a/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentAPIKeyListResult.js b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentAPIKeyListResult.js new file mode 100644 index 0000000000..f5484bc6b0 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentAPIKeyListResult.js @@ -0,0 +1,59 @@ +/* + * 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'; + +/** + * Describes the list of API Keys of an Application Insights Component. + */ +class ApplicationInsightsComponentAPIKeyListResult extends Array { + /** + * Create a ApplicationInsightsComponentAPIKeyListResult. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ApplicationInsightsComponentAPIKeyListResult + * + * @returns {object} metadata of ApplicationInsightsComponentAPIKeyListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'ApplicationInsightsComponentAPIKeyListResult', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentAPIKeyListResult', + modelProperties: { + value: { + required: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ApplicationInsightsComponentAPIKeyElementType', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentAPIKey' + } + } + } + } + } + } + }; + } +} + +module.exports = ApplicationInsightsComponentAPIKeyListResult; diff --git a/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentAvailableFeatures.js b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentAvailableFeatures.js new file mode 100644 index 0000000000..8867f4e048 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentAvailableFeatures.js @@ -0,0 +1,63 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * An Application Insights component available features. + * + */ +class ApplicationInsightsComponentAvailableFeatures { + /** + * Create a ApplicationInsightsComponentAvailableFeatures. + * @member {array} [result] A list of Application Insigths component feature. + */ + constructor() { + } + + /** + * Defines the metadata of ApplicationInsightsComponentAvailableFeatures + * + * @returns {object} metadata of ApplicationInsightsComponentAvailableFeatures + * + */ + mapper() { + return { + required: false, + serializedName: 'ApplicationInsightsComponentAvailableFeatures', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentAvailableFeatures', + modelProperties: { + result: { + required: false, + readOnly: true, + serializedName: 'Result', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ApplicationInsightsComponentFeatureElementType', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentFeature' + } + } + } + } + } + } + }; + } +} + +module.exports = ApplicationInsightsComponentAvailableFeatures; diff --git a/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentBillingFeatures.js b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentBillingFeatures.js new file mode 100644 index 0000000000..f7a4157280 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentBillingFeatures.js @@ -0,0 +1,84 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * An Application Insights component billing features + * + */ +class ApplicationInsightsComponentBillingFeatures { + /** + * Create a ApplicationInsightsComponentBillingFeatures. + * @member {object} [dataVolumeCap] An Application Insights component daily + * data volumne cap + * @member {number} [dataVolumeCap.cap] Daily data volume cap in GB. + * @member {number} [dataVolumeCap.resetTime] Daily data volume cap UTC reset + * hour. + * @member {number} [dataVolumeCap.warningThreshold] Reserved, not used for + * now. + * @member {boolean} [dataVolumeCap.stopSendNotificationWhenHitThreshold] + * Reserved, not used for now. + * @member {boolean} [dataVolumeCap.stopSendNotificationWhenHitCap] Do not + * send a notification email when the daily data volume cap is met. + * @member {number} [dataVolumeCap.maxHistoryCap] Maximum daily data volume + * cap that the user can set for this component. + * @member {array} [currentBillingFeatures] Current enabled pricing plan. + * When the component is in the Enterprise plan, this will list both 'Basic' + * and 'Application Insights Enterprise'. + */ + constructor() { + } + + /** + * Defines the metadata of ApplicationInsightsComponentBillingFeatures + * + * @returns {object} metadata of ApplicationInsightsComponentBillingFeatures + * + */ + mapper() { + return { + required: false, + serializedName: 'ApplicationInsightsComponentBillingFeatures', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentBillingFeatures', + modelProperties: { + dataVolumeCap: { + required: false, + serializedName: 'DataVolumeCap', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentDataVolumeCap' + } + }, + currentBillingFeatures: { + required: false, + serializedName: 'CurrentBillingFeatures', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = ApplicationInsightsComponentBillingFeatures; diff --git a/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentDataVolumeCap.js b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentDataVolumeCap.js new file mode 100644 index 0000000000..1db1cce43e --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentDataVolumeCap.js @@ -0,0 +1,97 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * An Application Insights component daily data volumne cap + * + */ +class ApplicationInsightsComponentDataVolumeCap { + /** + * Create a ApplicationInsightsComponentDataVolumeCap. + * @member {number} [cap] Daily data volume cap in GB. + * @member {number} [resetTime] Daily data volume cap UTC reset hour. + * @member {number} [warningThreshold] Reserved, not used for now. + * @member {boolean} [stopSendNotificationWhenHitThreshold] Reserved, not + * used for now. + * @member {boolean} [stopSendNotificationWhenHitCap] Do not send a + * notification email when the daily data volume cap is met. + * @member {number} [maxHistoryCap] Maximum daily data volume cap that the + * user can set for this component. + */ + constructor() { + } + + /** + * Defines the metadata of ApplicationInsightsComponentDataVolumeCap + * + * @returns {object} metadata of ApplicationInsightsComponentDataVolumeCap + * + */ + mapper() { + return { + required: false, + serializedName: 'ApplicationInsightsComponentDataVolumeCap', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentDataVolumeCap', + modelProperties: { + cap: { + required: false, + serializedName: 'Cap', + type: { + name: 'Number' + } + }, + resetTime: { + required: false, + readOnly: true, + serializedName: 'ResetTime', + type: { + name: 'Number' + } + }, + warningThreshold: { + required: false, + serializedName: 'WarningThreshold', + type: { + name: 'Number' + } + }, + stopSendNotificationWhenHitThreshold: { + required: false, + serializedName: 'StopSendNotificationWhenHitThreshold', + type: { + name: 'Boolean' + } + }, + stopSendNotificationWhenHitCap: { + required: false, + serializedName: 'StopSendNotificationWhenHitCap', + type: { + name: 'Boolean' + } + }, + maxHistoryCap: { + required: false, + readOnly: true, + serializedName: 'MaxHistoryCap', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = ApplicationInsightsComponentDataVolumeCap; diff --git a/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentExportConfiguration.js b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentExportConfiguration.js new file mode 100644 index 0000000000..3373d70254 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentExportConfiguration.js @@ -0,0 +1,235 @@ +/* + * 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'; + +/** + * Properties that define a Continuous Export configuration. + * + */ +class ApplicationInsightsComponentExportConfiguration { + /** + * Create a ApplicationInsightsComponentExportConfiguration. + * @member {string} [exportId] The unique ID of the export configuration + * inside an Applciation Insights component. It is auto generated when the + * Continuous Export configuration is created. + * @member {string} [instrumentationKey] The instrumentation key of the + * Application Insights component. + * @member {string} [recordTypes] This comma separated list of document types + * that will be exported. The possible values include 'Requests', 'Event', + * 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', + * 'PerformanceCounters', 'Availability', 'Messages'. + * @member {string} [applicationName] The name of the Application Insights + * component. + * @member {string} [subscriptionId] The subscription of the Application + * Insights component. + * @member {string} [resourceGroup] The resource group of the Application + * Insights component. + * @member {string} [destinationStorageSubscriptionId] The destination + * storage account subscription ID. + * @member {string} [destinationStorageLocationId] The destination account + * location ID. + * @member {string} [destinationAccountId] The name of destination account. + * @member {string} [destinationType] The destination type. + * @member {string} [isUserEnabled] This will be 'true' if the Continuous + * Export configuration is enabled, otherwise it will be 'false'. + * @member {string} [lastUserUpdate] Last time the Continuous Export + * configuration was updated. + * @member {string} [notificationQueueEnabled] Deprecated + * @member {string} [exportStatus] This indicates current Continuous Export + * configuration status. The possible values are 'Preparing', 'Success', + * 'Failure'. + * @member {string} [lastSuccessTime] The last time data was successfully + * delivered to the destination storage container for this Continuous Export + * configuration. + * @member {string} [lastGapTime] The last time the Continuous Export + * configuration started failing. + * @member {string} [permanentErrorReason] This is the reason the Continuous + * Export configuration started failing. It can be 'AzureStorageNotFound' or + * 'AzureStorageAccessDenied'. + * @member {string} [storageName] The name of the destination storage + * account. + * @member {string} [containerName] The name of the destination storage + * container. + */ + constructor() { + } + + /** + * Defines the metadata of ApplicationInsightsComponentExportConfiguration + * + * @returns {object} metadata of ApplicationInsightsComponentExportConfiguration + * + */ + mapper() { + return { + required: false, + serializedName: 'ApplicationInsightsComponentExportConfiguration', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentExportConfiguration', + modelProperties: { + exportId: { + required: false, + readOnly: true, + serializedName: 'ExportId', + type: { + name: 'String' + } + }, + instrumentationKey: { + required: false, + readOnly: true, + serializedName: 'InstrumentationKey', + type: { + name: 'String' + } + }, + recordTypes: { + required: false, + serializedName: 'RecordTypes', + type: { + name: 'String' + } + }, + applicationName: { + required: false, + readOnly: true, + serializedName: 'ApplicationName', + type: { + name: 'String' + } + }, + subscriptionId: { + required: false, + readOnly: true, + serializedName: 'SubscriptionId', + type: { + name: 'String' + } + }, + resourceGroup: { + required: false, + readOnly: true, + serializedName: 'ResourceGroup', + type: { + name: 'String' + } + }, + destinationStorageSubscriptionId: { + required: false, + readOnly: true, + serializedName: 'DestinationStorageSubscriptionId', + type: { + name: 'String' + } + }, + destinationStorageLocationId: { + required: false, + readOnly: true, + serializedName: 'DestinationStorageLocationId', + type: { + name: 'String' + } + }, + destinationAccountId: { + required: false, + readOnly: true, + serializedName: 'DestinationAccountId', + type: { + name: 'String' + } + }, + destinationType: { + required: false, + readOnly: true, + serializedName: 'DestinationType', + type: { + name: 'String' + } + }, + isUserEnabled: { + required: false, + readOnly: true, + serializedName: 'IsUserEnabled', + type: { + name: 'String' + } + }, + lastUserUpdate: { + required: false, + readOnly: true, + serializedName: 'LastUserUpdate', + type: { + name: 'String' + } + }, + notificationQueueEnabled: { + required: false, + serializedName: 'NotificationQueueEnabled', + type: { + name: 'String' + } + }, + exportStatus: { + required: false, + readOnly: true, + serializedName: 'ExportStatus', + type: { + name: 'String' + } + }, + lastSuccessTime: { + required: false, + readOnly: true, + serializedName: 'LastSuccessTime', + type: { + name: 'String' + } + }, + lastGapTime: { + required: false, + readOnly: true, + serializedName: 'LastGapTime', + type: { + name: 'String' + } + }, + permanentErrorReason: { + required: false, + readOnly: true, + serializedName: 'PermanentErrorReason', + type: { + name: 'String' + } + }, + storageName: { + required: false, + readOnly: true, + serializedName: 'StorageName', + type: { + name: 'String' + } + }, + containerName: { + required: false, + readOnly: true, + serializedName: 'ContainerName', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ApplicationInsightsComponentExportConfiguration; diff --git a/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentExportRequest.js b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentExportRequest.js new file mode 100644 index 0000000000..9860675c8a --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentExportRequest.js @@ -0,0 +1,126 @@ +/* + * 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'; + +/** + * An Application Insights component Continuous Export configuration request + * definition. + * + */ +class ApplicationInsightsComponentExportRequest { + /** + * Create a ApplicationInsightsComponentExportRequest. + * @member {string} [recordTypes] The document types to be exported, as comma + * separated values. Allowed values include 'Requests', 'Event', + * 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', + * 'PerformanceCounters', 'Availability', 'Messages'. + * @member {string} [destinationType] The Continuous Export destination type. + * This has to be 'Blob'. + * @member {string} [destinationAddress] The SAS URL for the destination + * storage container. It must grant write permission. + * @member {string} [isEnabled] Set to 'true' to create a Continuous Export + * configuration as enabled, otherwise set it to 'false'. + * @member {string} [notificationQueueEnabled] Deprecated + * @member {string} [notificationQueueUri] Deprecated + * @member {string} [destinationStorageSubscriptionId] The subscription ID of + * the destination storage container. + * @member {string} [destinationStorageLocationId] The location ID of the + * destination storage container. + * @member {string} [destinationAccountId] The name of destination storage + * account. + */ + constructor() { + } + + /** + * Defines the metadata of ApplicationInsightsComponentExportRequest + * + * @returns {object} metadata of ApplicationInsightsComponentExportRequest + * + */ + mapper() { + return { + required: false, + serializedName: 'ApplicationInsightsComponentExportRequest', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentExportRequest', + modelProperties: { + recordTypes: { + required: false, + serializedName: 'RecordTypes', + type: { + name: 'String' + } + }, + destinationType: { + required: false, + serializedName: 'DestinationType', + type: { + name: 'String' + } + }, + destinationAddress: { + required: false, + serializedName: 'DestinationAddress', + type: { + name: 'String' + } + }, + isEnabled: { + required: false, + serializedName: 'IsEnabled', + type: { + name: 'String' + } + }, + notificationQueueEnabled: { + required: false, + serializedName: 'NotificationQueueEnabled', + type: { + name: 'String' + } + }, + notificationQueueUri: { + required: false, + serializedName: 'NotificationQueueUri', + type: { + name: 'String' + } + }, + destinationStorageSubscriptionId: { + required: false, + serializedName: 'DestinationStorageSubscriptionId', + type: { + name: 'String' + } + }, + destinationStorageLocationId: { + required: false, + serializedName: 'DestinationStorageLocationId', + type: { + name: 'String' + } + }, + destinationAccountId: { + required: false, + serializedName: 'DestinationAccountId', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ApplicationInsightsComponentExportRequest; diff --git a/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentFavorite.js b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentFavorite.js new file mode 100644 index 0000000000..3b4372c28c --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentFavorite.js @@ -0,0 +1,157 @@ +/* + * 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'; + +/** + * Properties that define a favorite that is associated to an Application + * Insights component. + * + */ +class ApplicationInsightsComponentFavorite { + /** + * Create a ApplicationInsightsComponentFavorite. + * @member {string} [name] The user-defined name of the favorite. + * @member {string} [config] Configuration of this particular favorite, which + * are driven by the Azure portal UX. Configuration data is a string + * containing valid JSON + * @member {string} [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. + * @member {string} [favoriteId] Internally assigned unique id of the + * favorite definition. + * @member {string} [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' + * @member {string} [sourceType] The source of the favorite definition. + * @member {string} [timeModified] Date and time in UTC of the last + * modification that was made to this favorite definition. + * @member {array} [tags] A list of 0 or more tags that are associated with + * this favorite definition + * @member {string} [category] Favorite category, as defined by the user at + * creation time. + * @member {boolean} [isGeneratedFromTemplate] Flag denoting wether or not + * this favorite was generated from a template. + * @member {string} [userId] Unique user id of the specific user that owns + * this favorite. + */ + constructor() { + } + + /** + * Defines the metadata of ApplicationInsightsComponentFavorite + * + * @returns {object} metadata of ApplicationInsightsComponentFavorite + * + */ + mapper() { + return { + required: false, + serializedName: 'ApplicationInsightsComponentFavorite', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentFavorite', + modelProperties: { + name: { + required: false, + serializedName: 'Name', + type: { + name: 'String' + } + }, + config: { + required: false, + serializedName: 'Config', + type: { + name: 'String' + } + }, + version: { + required: false, + serializedName: 'Version', + type: { + name: 'String' + } + }, + favoriteId: { + required: false, + readOnly: true, + serializedName: 'FavoriteId', + type: { + name: 'String' + } + }, + favoriteType: { + required: false, + serializedName: 'FavoriteType', + type: { + name: 'Enum', + allowedValues: [ 'shared', 'user' ] + } + }, + sourceType: { + required: false, + serializedName: 'SourceType', + type: { + name: 'String' + } + }, + timeModified: { + required: false, + readOnly: true, + serializedName: 'TimeModified', + type: { + name: 'String' + } + }, + tags: { + required: false, + serializedName: 'Tags', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + category: { + required: false, + serializedName: 'Category', + type: { + name: 'String' + } + }, + isGeneratedFromTemplate: { + required: false, + serializedName: 'IsGeneratedFromTemplate', + type: { + name: 'Boolean' + } + }, + userId: { + required: false, + readOnly: true, + serializedName: 'UserId', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ApplicationInsightsComponentFavorite; diff --git a/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentFeature.js b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentFeature.js new file mode 100644 index 0000000000..e7fbc07c23 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentFeature.js @@ -0,0 +1,139 @@ +/* + * 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 Application Insights component daily data volume cap status + * + */ +class ApplicationInsightsComponentFeature { + /** + * Create a ApplicationInsightsComponentFeature. + * @member {string} [featureName] The pricing feature name. + * @member {string} [meterId] The meter id used for the feature. + * @member {string} [meterRateFrequency] The meter meter rate for the + * feature's meter. + * @member {string} [resouceId] Reserved, not used now. + * @member {boolean} [isHidden] Reserved, not used now. + * @member {array} [capabilities] A list of Application Insigths component + * feature capability. + * @member {string} [title] Desplay name of the feature. + * @member {boolean} [isMainFeature] Whether can apply addon feature on to + * it. + * @member {string} [supportedAddonFeatures] The add on features on main + * feature. + */ + constructor() { + } + + /** + * Defines the metadata of ApplicationInsightsComponentFeature + * + * @returns {object} metadata of ApplicationInsightsComponentFeature + * + */ + mapper() { + return { + required: false, + serializedName: 'ApplicationInsightsComponentFeature', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentFeature', + modelProperties: { + featureName: { + required: false, + readOnly: true, + serializedName: 'FeatureName', + type: { + name: 'String' + } + }, + meterId: { + required: false, + readOnly: true, + serializedName: 'MeterId', + type: { + name: 'String' + } + }, + meterRateFrequency: { + required: false, + readOnly: true, + serializedName: 'MeterRateFrequency', + type: { + name: 'String' + } + }, + resouceId: { + required: false, + readOnly: true, + serializedName: 'ResouceId', + type: { + name: 'String' + } + }, + isHidden: { + required: false, + readOnly: true, + serializedName: 'IsHidden', + type: { + name: 'Boolean' + } + }, + capabilities: { + required: false, + readOnly: true, + serializedName: 'Capabilities', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ApplicationInsightsComponentFeatureCapabilityElementType', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentFeatureCapability' + } + } + } + }, + title: { + required: false, + readOnly: true, + serializedName: 'Title', + type: { + name: 'String' + } + }, + isMainFeature: { + required: false, + readOnly: true, + serializedName: 'IsMainFeature', + type: { + name: 'Boolean' + } + }, + supportedAddonFeatures: { + required: false, + readOnly: true, + serializedName: 'SupportedAddonFeatures', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ApplicationInsightsComponentFeature; diff --git a/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentFeatureCapabilities.js b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentFeatureCapabilities.js new file mode 100644 index 0000000000..ae93319d27 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentFeatureCapabilities.js @@ -0,0 +1,192 @@ +/* + * 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'; + +/** + * An Application Insights component feature capabilities + * + */ +class ApplicationInsightsComponentFeatureCapabilities { + /** + * Create a ApplicationInsightsComponentFeatureCapabilities. + * @member {boolean} [supportExportData] Whether allow to use continuous + * export feature. + * @member {string} [burstThrottlePolicy] Reserved, not used now. + * @member {string} [metadataClass] Reserved, not used now. + * @member {boolean} [liveStreamMetrics] Reserved, not used now. + * @member {boolean} [applicationMap] Reserved, not used now. + * @member {boolean} [workItemIntegration] Whether allow to use work item + * integration feature. + * @member {boolean} [powerBIIntegration] Reserved, not used now. + * @member {boolean} [openSchema] Reserved, not used now. + * @member {boolean} [proactiveDetection] Reserved, not used now. + * @member {boolean} [analyticsIntegration] Reserved, not used now. + * @member {boolean} [multipleStepWebTest] Whether allow to use multiple + * steps web test feature. + * @member {string} [apiAccessLevel] Reserved, not used now. + * @member {string} [trackingType] The applciation insights component used + * tracking type. + * @member {number} [dailyCap] Daily data volume cap in GB. + * @member {number} [dailyCapResetTime] Daily data volume cap UTC reset hour. + * @member {number} [throttleRate] Reserved, not used now. + */ + constructor() { + } + + /** + * Defines the metadata of ApplicationInsightsComponentFeatureCapabilities + * + * @returns {object} metadata of ApplicationInsightsComponentFeatureCapabilities + * + */ + mapper() { + return { + required: false, + serializedName: 'ApplicationInsightsComponentFeatureCapabilities', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentFeatureCapabilities', + modelProperties: { + supportExportData: { + required: false, + readOnly: true, + serializedName: 'SupportExportData', + type: { + name: 'Boolean' + } + }, + burstThrottlePolicy: { + required: false, + readOnly: true, + serializedName: 'BurstThrottlePolicy', + type: { + name: 'String' + } + }, + metadataClass: { + required: false, + readOnly: true, + serializedName: 'MetadataClass', + type: { + name: 'String' + } + }, + liveStreamMetrics: { + required: false, + readOnly: true, + serializedName: 'LiveStreamMetrics', + type: { + name: 'Boolean' + } + }, + applicationMap: { + required: false, + readOnly: true, + serializedName: 'ApplicationMap', + type: { + name: 'Boolean' + } + }, + workItemIntegration: { + required: false, + readOnly: true, + serializedName: 'WorkItemIntegration', + type: { + name: 'Boolean' + } + }, + powerBIIntegration: { + required: false, + readOnly: true, + serializedName: 'PowerBIIntegration', + type: { + name: 'Boolean' + } + }, + openSchema: { + required: false, + readOnly: true, + serializedName: 'OpenSchema', + type: { + name: 'Boolean' + } + }, + proactiveDetection: { + required: false, + readOnly: true, + serializedName: 'ProactiveDetection', + type: { + name: 'Boolean' + } + }, + analyticsIntegration: { + required: false, + readOnly: true, + serializedName: 'AnalyticsIntegration', + type: { + name: 'Boolean' + } + }, + multipleStepWebTest: { + required: false, + readOnly: true, + serializedName: 'MultipleStepWebTest', + type: { + name: 'Boolean' + } + }, + apiAccessLevel: { + required: false, + readOnly: true, + serializedName: 'ApiAccessLevel', + type: { + name: 'String' + } + }, + trackingType: { + required: false, + readOnly: true, + serializedName: 'TrackingType', + type: { + name: 'String' + } + }, + dailyCap: { + required: false, + readOnly: true, + serializedName: 'DailyCap', + type: { + name: 'Number' + } + }, + dailyCapResetTime: { + required: false, + readOnly: true, + serializedName: 'DailyCapResetTime', + type: { + name: 'Number' + } + }, + throttleRate: { + required: false, + readOnly: true, + serializedName: 'ThrottleRate', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = ApplicationInsightsComponentFeatureCapabilities; diff --git a/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentFeatureCapability.js b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentFeatureCapability.js new file mode 100644 index 0000000000..5499022ffb --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentFeatureCapability.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'; + +/** + * An Application Insights component feature capability + * + */ +class ApplicationInsightsComponentFeatureCapability { + /** + * Create a ApplicationInsightsComponentFeatureCapability. + * @member {string} [name] The name of the capability. + * @member {string} [description] The description of the capability. + * @member {string} [value] The vaule of the capability. + * @member {string} [unit] The unit of the capability. + * @member {string} [meterId] The meter used for the capability. + * @member {string} [meterRateFrequency] The meter rate of the meter. + */ + constructor() { + } + + /** + * Defines the metadata of ApplicationInsightsComponentFeatureCapability + * + * @returns {object} metadata of ApplicationInsightsComponentFeatureCapability + * + */ + mapper() { + return { + required: false, + serializedName: 'ApplicationInsightsComponentFeatureCapability', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentFeatureCapability', + modelProperties: { + name: { + required: false, + readOnly: true, + serializedName: 'Name', + type: { + name: 'String' + } + }, + description: { + required: false, + readOnly: true, + serializedName: 'Description', + type: { + name: 'String' + } + }, + value: { + required: false, + readOnly: true, + serializedName: 'Value', + type: { + name: 'String' + } + }, + unit: { + required: false, + readOnly: true, + serializedName: 'Unit', + type: { + name: 'String' + } + }, + meterId: { + required: false, + readOnly: true, + serializedName: 'MeterId', + type: { + name: 'String' + } + }, + meterRateFrequency: { + required: false, + readOnly: true, + serializedName: 'MeterRateFrequency', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ApplicationInsightsComponentFeatureCapability; diff --git a/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentListResult.js b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentListResult.js new file mode 100644 index 0000000000..c211757dff --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentListResult.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Describes the list of Application Insights Resources. + */ +class ApplicationInsightsComponentListResult extends Array { + /** + * Create a ApplicationInsightsComponentListResult. + * @member {string} [nextLink] The URI to get the next set of Application + * Insights component defintions if too many components where returned in the + * result set. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ApplicationInsightsComponentListResult + * + * @returns {object} metadata of ApplicationInsightsComponentListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'ApplicationInsightsComponentListResult', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentListResult', + modelProperties: { + value: { + required: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ApplicationInsightsComponentElementType', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponent' + } + } + } + }, + nextLink: { + required: false, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ApplicationInsightsComponentListResult; diff --git a/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentProactiveDetectionConfiguration.js b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentProactiveDetectionConfiguration.js new file mode 100644 index 0000000000..1c6090fea1 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentProactiveDetectionConfiguration.js @@ -0,0 +1,123 @@ +/* + * 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'); + +/** + * Properties that define a ProactiveDetection configuration. + * + * @extends models['BaseResource'] + */ +class ApplicationInsightsComponentProactiveDetectionConfiguration extends models['BaseResource'] { + /** + * Create a ApplicationInsightsComponentProactiveDetectionConfiguration. + * @member {string} [name] The rule name + * @member {boolean} [enabled] A flag that indicates whether this rule is + * enabled by the user + * @member {boolean} [sendEmailsToSubscriptionOwners] A flag that indicated + * whether notifications on this rule should be sent to subscription owners + * @member {array} [customEmails] Custom email addresses for this rule + * notifications + * @member {string} [lastUpdatedTime] The last time this rule was updated + * @member {object} [ruleDefinitions] Static definitions of the + * ProactiveDetection configuration rule (same values for all components). + * @member {string} [ruleDefinitions.name] The rule name + * @member {string} [ruleDefinitions.displayName] The rule name as it is + * displayed in UI + * @member {string} [ruleDefinitions.description] The rule description + * @member {string} [ruleDefinitions.helpUrl] URL which displays aditional + * info about the proactive detection rule + * @member {boolean} [ruleDefinitions.isHidden] A flag indicating whether the + * rule is hidden (from the UI) + * @member {boolean} [ruleDefinitions.isEnabledByDefault] A flag indicating + * whether the rule is enabled by default + * @member {boolean} [ruleDefinitions.isInPreview] A flag indicating whether + * the rule is in preview + * @member {boolean} [ruleDefinitions.supportsEmailNotifications] A flag + * indicating whether email notifications are supported for detections for + * this rule + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ApplicationInsightsComponentProactiveDetectionConfiguration + * + * @returns {object} metadata of ApplicationInsightsComponentProactiveDetectionConfiguration + * + */ + mapper() { + return { + required: false, + serializedName: 'ApplicationInsightsComponentProactiveDetectionConfiguration', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentProactiveDetectionConfiguration', + modelProperties: { + name: { + required: false, + serializedName: 'Name', + type: { + name: 'String' + } + }, + enabled: { + required: false, + serializedName: 'Enabled', + type: { + name: 'Boolean' + } + }, + sendEmailsToSubscriptionOwners: { + required: false, + serializedName: 'SendEmailsToSubscriptionOwners', + type: { + name: 'Boolean' + } + }, + customEmails: { + required: false, + serializedName: 'CustomEmails', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + lastUpdatedTime: { + required: false, + serializedName: 'LastUpdatedTime', + type: { + name: 'String' + } + }, + ruleDefinitions: { + required: false, + serializedName: 'RuleDefinitions', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions' + } + } + } + } + }; + } +} + +module.exports = ApplicationInsightsComponentProactiveDetectionConfiguration; diff --git a/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions.js b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions.js new file mode 100644 index 0000000000..b4b3187eac --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions.js @@ -0,0 +1,114 @@ +/* + * 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'; + +/** + * Static definitions of the ProactiveDetection configuration rule (same values + * for all components). + * + */ +class ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions { + /** + * Create a ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions. + * @member {string} [name] The rule name + * @member {string} [displayName] The rule name as it is displayed in UI + * @member {string} [description] The rule description + * @member {string} [helpUrl] URL which displays aditional info about the + * proactive detection rule + * @member {boolean} [isHidden] A flag indicating whether the rule is hidden + * (from the UI) + * @member {boolean} [isEnabledByDefault] A flag indicating whether the rule + * is enabled by default + * @member {boolean} [isInPreview] A flag indicating whether the rule is in + * preview + * @member {boolean} [supportsEmailNotifications] A flag indicating whether + * email notifications are supported for detections for this rule + */ + constructor() { + } + + /** + * Defines the metadata of ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions + * + * @returns {object} metadata of ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions + * + */ + mapper() { + return { + required: false, + serializedName: 'ApplicationInsightsComponentProactiveDetectionConfiguration_RuleDefinitions', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions', + modelProperties: { + name: { + required: false, + serializedName: 'Name', + type: { + name: 'String' + } + }, + displayName: { + required: false, + serializedName: 'DisplayName', + type: { + name: 'String' + } + }, + description: { + required: false, + serializedName: 'Description', + type: { + name: 'String' + } + }, + helpUrl: { + required: false, + serializedName: 'HelpUrl', + type: { + name: 'String' + } + }, + isHidden: { + required: false, + serializedName: 'IsHidden', + type: { + name: 'Boolean' + } + }, + isEnabledByDefault: { + required: false, + serializedName: 'IsEnabledByDefault', + type: { + name: 'Boolean' + } + }, + isInPreview: { + required: false, + serializedName: 'IsInPreview', + type: { + name: 'Boolean' + } + }, + supportsEmailNotifications: { + required: false, + serializedName: 'SupportsEmailNotifications', + type: { + name: 'Boolean' + } + } + } + } + }; + } +} + +module.exports = ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions; diff --git a/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentQuotaStatus.js b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentQuotaStatus.js new file mode 100644 index 0000000000..e496efb594 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentQuotaStatus.js @@ -0,0 +1,74 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * An Application Insights component daily data volume cap status + * + */ +class ApplicationInsightsComponentQuotaStatus { + /** + * Create a ApplicationInsightsComponentQuotaStatus. + * @member {string} [appId] The Application ID for the Application Insights + * component. + * @member {boolean} [shouldBeThrottled] The daily data volume cap is met, + * and data ingestion will be stopped. + * @member {string} [expirationTime] Date and time when the daily data volume + * cap will be reset, and data ingestion will resume. + */ + constructor() { + } + + /** + * Defines the metadata of ApplicationInsightsComponentQuotaStatus + * + * @returns {object} metadata of ApplicationInsightsComponentQuotaStatus + * + */ + mapper() { + return { + required: false, + serializedName: 'ApplicationInsightsComponentQuotaStatus', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentQuotaStatus', + modelProperties: { + appId: { + required: false, + readOnly: true, + serializedName: 'AppId', + type: { + name: 'String' + } + }, + shouldBeThrottled: { + required: false, + readOnly: true, + serializedName: 'ShouldBeThrottled', + type: { + name: 'Boolean' + } + }, + expirationTime: { + required: false, + readOnly: true, + serializedName: 'ExpirationTime', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ApplicationInsightsComponentQuotaStatus; diff --git a/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentWebTestLocation.js b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentWebTestLocation.js new file mode 100644 index 0000000000..00a5d48ac1 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/applicationInsightsComponentWebTestLocation.js @@ -0,0 +1,63 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Properties that define a web test location available to an Application + * Insights Component. + * + */ +class ApplicationInsightsComponentWebTestLocation { + /** + * Create a ApplicationInsightsComponentWebTestLocation. + * @member {string} [displayName] The display name of the web test location. + * @member {string} [tag] Internally defined geographic location tag. + */ + constructor() { + } + + /** + * Defines the metadata of ApplicationInsightsComponentWebTestLocation + * + * @returns {object} metadata of ApplicationInsightsComponentWebTestLocation + * + */ + mapper() { + return { + required: false, + serializedName: 'ApplicationInsightsComponentWebTestLocation', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentWebTestLocation', + modelProperties: { + displayName: { + required: false, + readOnly: true, + serializedName: 'DisplayName', + type: { + name: 'String' + } + }, + tag: { + required: false, + readOnly: true, + serializedName: 'Tag', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ApplicationInsightsComponentWebTestLocation; diff --git a/lib/services/applicationinsights/lib/lib/models/applicationInsightsWebTestLocationsListResult.js b/lib/services/applicationinsights/lib/lib/models/applicationInsightsWebTestLocationsListResult.js new file mode 100644 index 0000000000..8d05b47c26 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/applicationInsightsWebTestLocationsListResult.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'; + +/** + * Describes the list of web test locations available to an Application + * Insights Component. + */ +class ApplicationInsightsWebTestLocationsListResult extends Array { + /** + * Create a ApplicationInsightsWebTestLocationsListResult. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ApplicationInsightsWebTestLocationsListResult + * + * @returns {object} metadata of ApplicationInsightsWebTestLocationsListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'ApplicationInsightsWebTestLocationsListResult', + type: { + name: 'Composite', + className: 'ApplicationInsightsWebTestLocationsListResult', + modelProperties: { + value: { + required: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ApplicationInsightsComponentWebTestLocationElementType', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentWebTestLocation' + } + } + } + } + } + } + }; + } +} + +module.exports = ApplicationInsightsWebTestLocationsListResult; diff --git a/lib/services/applicationinsights/lib/lib/models/componentPurgeBody.js b/lib/services/applicationinsights/lib/lib/models/componentPurgeBody.js new file mode 100644 index 0000000000..14b09d26d4 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/componentPurgeBody.js @@ -0,0 +1,71 @@ +/* + * 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'); + +/** + * Describes the body of a purge request for an App Insights component + * + */ +class ComponentPurgeBody { + /** + * Create a ComponentPurgeBody. + * @member {string} table Table from which to purge data. + * @member {array} filters The set of columns and filters (queries) to run + * over them to purge the resulting data. + */ + constructor() { + } + + /** + * Defines the metadata of ComponentPurgeBody + * + * @returns {object} metadata of ComponentPurgeBody + * + */ + mapper() { + return { + required: false, + serializedName: 'ComponentPurgeBody', + type: { + name: 'Composite', + className: 'ComponentPurgeBody', + modelProperties: { + table: { + required: true, + serializedName: 'table', + type: { + name: 'String' + } + }, + filters: { + required: true, + serializedName: 'filters', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ComponentPurgeBodyFiltersElementType', + type: { + name: 'Composite', + className: 'ComponentPurgeBodyFilters' + } + } + } + } + } + } + }; + } +} + +module.exports = ComponentPurgeBody; diff --git a/lib/services/applicationinsights/lib/lib/models/componentPurgeBodyFilters.js b/lib/services/applicationinsights/lib/lib/models/componentPurgeBodyFilters.js new file mode 100644 index 0000000000..832ecedb3f --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/componentPurgeBodyFilters.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * User-defined filters to return data which will be purged from the table. + * + */ +class ComponentPurgeBodyFilters { + /** + * Create a ComponentPurgeBodyFilters. + * @member {string} [column] The column of the table over which the given + * query should run + * @member {string} [filter] A query to to run over the provided table and + * column to purge the corresponding data. + */ + constructor() { + } + + /** + * Defines the metadata of ComponentPurgeBodyFilters + * + * @returns {object} metadata of ComponentPurgeBodyFilters + * + */ + mapper() { + return { + required: false, + serializedName: 'ComponentPurgeBodyFilters', + type: { + name: 'Composite', + className: 'ComponentPurgeBodyFilters', + modelProperties: { + column: { + required: false, + serializedName: 'column', + type: { + name: 'String' + } + }, + filter: { + required: false, + serializedName: 'filter', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ComponentPurgeBodyFilters; diff --git a/lib/services/applicationinsights/lib/lib/models/componentPurgeResponse.js b/lib/services/applicationinsights/lib/lib/models/componentPurgeResponse.js new file mode 100644 index 0000000000..ef796df507 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/componentPurgeResponse.js @@ -0,0 +1,53 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Response containing operationId for a specific purge action. + * + */ +class ComponentPurgeResponse { + /** + * Create a ComponentPurgeResponse. + * @member {string} operationId Id to use when querying for status for a + * particular purge operation. + */ + constructor() { + } + + /** + * Defines the metadata of ComponentPurgeResponse + * + * @returns {object} metadata of ComponentPurgeResponse + * + */ + mapper() { + return { + required: false, + serializedName: 'ComponentPurgeResponse', + type: { + name: 'Composite', + className: 'ComponentPurgeResponse', + modelProperties: { + operationId: { + required: true, + serializedName: 'operationId', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ComponentPurgeResponse; diff --git a/lib/services/applicationinsights/lib/lib/models/componentPurgeStatusResponse.js b/lib/services/applicationinsights/lib/lib/models/componentPurgeStatusResponse.js new file mode 100644 index 0000000000..47b5b6ec49 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/componentPurgeStatusResponse.js @@ -0,0 +1,53 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Response containing status for a specific purge operation. + * + */ +class ComponentPurgeStatusResponse { + /** + * Create a ComponentPurgeStatusResponse. + * @member {string} status Status of the operation represented by the + * requested Id. Possible values include: 'Pending', 'Completed' + */ + constructor() { + } + + /** + * Defines the metadata of ComponentPurgeStatusResponse + * + * @returns {object} metadata of ComponentPurgeStatusResponse + * + */ + mapper() { + return { + required: false, + serializedName: 'ComponentPurgeStatusResponse', + type: { + name: 'Composite', + className: 'ComponentPurgeStatusResponse', + modelProperties: { + status: { + required: true, + serializedName: 'status', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ComponentPurgeStatusResponse; diff --git a/lib/services/applicationinsights/lib/lib/models/errorFieldContract.js b/lib/services/applicationinsights/lib/lib/models/errorFieldContract.js new file mode 100644 index 0000000000..844007b168 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/errorFieldContract.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Error Field contract. + * + */ +class ErrorFieldContract { + /** + * Create a ErrorFieldContract. + * @member {string} [code] Property level error code. + * @member {string} [message] Human-readable representation of property-level + * error. + * @member {string} [target] Property name. + */ + constructor() { + } + + /** + * Defines the metadata of ErrorFieldContract + * + * @returns {object} metadata of ErrorFieldContract + * + */ + mapper() { + return { + required: false, + serializedName: 'ErrorFieldContract', + type: { + name: 'Composite', + className: 'ErrorFieldContract', + modelProperties: { + code: { + required: false, + serializedName: 'code', + type: { + name: 'String' + } + }, + message: { + required: false, + serializedName: 'message', + type: { + name: 'String' + } + }, + target: { + required: false, + serializedName: 'target', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ErrorFieldContract; diff --git a/lib/services/applicationinsights/lib/lib/models/errorResponse.js b/lib/services/applicationinsights/lib/lib/models/errorResponse.js new file mode 100644 index 0000000000..4eda09b28c --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/errorResponse.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Error reponse indicates Insights service is not able to process the incoming + * request. The reason is provided in the error message. + * + */ +class ErrorResponse { + /** + * Create a ErrorResponse. + * @member {string} [code] Error code. + * @member {string} [message] Error message indicating why the operation + * failed. + */ + constructor() { + } + + /** + * Defines the metadata of ErrorResponse + * + * @returns {object} metadata of ErrorResponse + * + */ + mapper() { + return { + required: false, + serializedName: 'ErrorResponse', + type: { + name: 'Composite', + className: 'ErrorResponse', + modelProperties: { + code: { + required: false, + serializedName: 'code', + type: { + name: 'String' + } + }, + message: { + required: false, + serializedName: 'message', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ErrorResponse; diff --git a/lib/services/applicationinsights/lib/lib/models/index.d.ts b/lib/services/applicationinsights/lib/lib/models/index.d.ts new file mode 100644 index 0000000000..f6b6a75f1f --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/index.d.ts @@ -0,0 +1,1048 @@ +/* + * 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. + */ + +import { BaseResource } from 'ms-rest-azure'; +import { CloudError } from 'ms-rest-azure'; +import * as moment from 'moment'; + +export { BaseResource } from 'ms-rest-azure'; +export { CloudError } from 'ms-rest-azure'; + + +/** + * @class + * Initializes a new instance of the ErrorResponse class. + * @constructor + * Error reponse indicates Insights service is not able to process the incoming + * request. The reason is provided in the error message. + * + * @member {string} [code] Error code. + * @member {string} [message] Error message indicating why the operation + * failed. + */ +export interface ErrorResponse { + code?: string; + message?: string; +} + +/** + * @class + * Initializes a new instance of the OperationDisplay class. + * @constructor + * The object that represents the operation. + * + * @member {string} [provider] Service provider: Microsoft.Cdn + * @member {string} [resource] Resource on which the operation is performed: + * Profile, endpoint, etc. + * @member {string} [operation] Operation type: Read, write, delete, etc. + */ +export interface OperationDisplay { + provider?: string; + resource?: string; + operation?: string; +} + +/** + * @class + * Initializes a new instance of the Operation class. + * @constructor + * CDN REST API operation + * + * @member {string} [name] Operation name: {provider}/{resource}/{operation} + * @member {object} [display] The object that represents the operation. + * @member {string} [display.provider] Service provider: Microsoft.Cdn + * @member {string} [display.resource] Resource on which the operation is + * performed: Profile, endpoint, etc. + * @member {string} [display.operation] Operation type: Read, write, delete, + * etc. + */ +export interface Operation { + name?: string; + display?: OperationDisplay; +} + +/** + * @class + * Initializes a new instance of the Annotation class. + * @constructor + * Annotation associated with an application insights resource. + * + * @member {string} [annotationName] Name of annotation + * @member {string} [category] Category of annotation, free form + * @member {date} [eventTime] Time when event occurred + * @member {string} [id] Unique Id for annotation + * @member {string} [properties] Serialized JSON object for detailed properties + * @member {string} [relatedAnnotation] Related parent annotation if any. + * Default value: 'null' . + */ +export interface Annotation { + annotationName?: string; + category?: string; + eventTime?: Date; + id?: string; + properties?: string; + relatedAnnotation?: string; +} + +/** + * @class + * Initializes a new instance of the InnerError class. + * @constructor + * Inner error + * + * @member {string} [diagnosticcontext] Provides correlation for request + * @member {date} [time] Request time + */ +export interface InnerError { + diagnosticcontext?: string; + time?: Date; +} + +/** + * @class + * Initializes a new instance of the AnnotationError class. + * @constructor + * Error associated with trying to create annotation with Id that already exist + * + * @member {string} [code] Error detail code and explanation + * @member {string} [message] Error message + * @member {object} [innererror] + * @member {string} [innererror.diagnosticcontext] Provides correlation for + * request + * @member {date} [innererror.time] Request time + */ +export interface AnnotationError { + code?: string; + message?: string; + innererror?: InnerError; +} + +/** + * @class + * Initializes a new instance of the APIKeyRequest class. + * @constructor + * An Application Insights component API Key createion request definition. + * + * @member {string} [name] The name of the API Key. + * @member {array} [linkedReadProperties] The read access rights of this API + * Key. + * @member {array} [linkedWriteProperties] The write access rights of this API + * Key. + */ +export interface APIKeyRequest { + name?: string; + linkedReadProperties?: string[]; + linkedWriteProperties?: string[]; +} + +/** + * @class + * Initializes a new instance of the ApplicationInsightsComponentAPIKey class. + * @constructor + * Properties that define an API key of an Application Insights Component. + * + * @member {string} [id] The unique ID of the API key inside an Applciation + * Insights component. It is auto generated when the API key is created. + * @member {string} [apiKey] The API key value. It will be only return once + * when the API Key was created. + * @member {string} [createdDate] The create date of this API key. + * @member {string} [name] The name of the API key. + * @member {array} [linkedReadProperties] The read access rights of this API + * Key. + * @member {array} [linkedWriteProperties] The write access rights of this API + * Key. + */ +export interface ApplicationInsightsComponentAPIKey { + readonly id?: string; + readonly apiKey?: string; + createdDate?: string; + name?: string; + linkedReadProperties?: string[]; + linkedWriteProperties?: string[]; +} + +/** + * @class + * Initializes a new instance of the ApplicationInsightsComponentExportRequest class. + * @constructor + * An Application Insights component Continuous Export configuration request + * definition. + * + * @member {string} [recordTypes] The document types to be exported, as comma + * separated values. Allowed values include 'Requests', 'Event', 'Exceptions', + * 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', 'PerformanceCounters', + * 'Availability', 'Messages'. + * @member {string} [destinationType] The Continuous Export destination type. + * This has to be 'Blob'. + * @member {string} [destinationAddress] The SAS URL for the destination + * storage container. It must grant write permission. + * @member {string} [isEnabled] Set to 'true' to create a Continuous Export + * configuration as enabled, otherwise set it to 'false'. + * @member {string} [notificationQueueEnabled] Deprecated + * @member {string} [notificationQueueUri] Deprecated + * @member {string} [destinationStorageSubscriptionId] The subscription ID of + * the destination storage container. + * @member {string} [destinationStorageLocationId] The location ID of the + * destination storage container. + * @member {string} [destinationAccountId] The name of destination storage + * account. + */ +export interface ApplicationInsightsComponentExportRequest { + recordTypes?: string; + destinationType?: string; + destinationAddress?: string; + isEnabled?: string; + notificationQueueEnabled?: string; + notificationQueueUri?: string; + destinationStorageSubscriptionId?: string; + destinationStorageLocationId?: string; + destinationAccountId?: string; +} + +/** + * @class + * Initializes a new instance of the ApplicationInsightsComponentExportConfiguration class. + * @constructor + * Properties that define a Continuous Export configuration. + * + * @member {string} [exportId] The unique ID of the export configuration inside + * an Applciation Insights component. It is auto generated when the Continuous + * Export configuration is created. + * @member {string} [instrumentationKey] The instrumentation key of the + * Application Insights component. + * @member {string} [recordTypes] This comma separated list of document types + * that will be exported. The possible values include 'Requests', 'Event', + * 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', + * 'PerformanceCounters', 'Availability', 'Messages'. + * @member {string} [applicationName] The name of the Application Insights + * component. + * @member {string} [subscriptionId] The subscription of the Application + * Insights component. + * @member {string} [resourceGroup] The resource group of the Application + * Insights component. + * @member {string} [destinationStorageSubscriptionId] The destination storage + * account subscription ID. + * @member {string} [destinationStorageLocationId] The destination account + * location ID. + * @member {string} [destinationAccountId] The name of destination account. + * @member {string} [destinationType] The destination type. + * @member {string} [isUserEnabled] This will be 'true' if the Continuous + * Export configuration is enabled, otherwise it will be 'false'. + * @member {string} [lastUserUpdate] Last time the Continuous Export + * configuration was updated. + * @member {string} [notificationQueueEnabled] Deprecated + * @member {string} [exportStatus] This indicates current Continuous Export + * configuration status. The possible values are 'Preparing', 'Success', + * 'Failure'. + * @member {string} [lastSuccessTime] The last time data was successfully + * delivered to the destination storage container for this Continuous Export + * configuration. + * @member {string} [lastGapTime] The last time the Continuous Export + * configuration started failing. + * @member {string} [permanentErrorReason] This is the reason the Continuous + * Export configuration started failing. It can be 'AzureStorageNotFound' or + * 'AzureStorageAccessDenied'. + * @member {string} [storageName] The name of the destination storage account. + * @member {string} [containerName] The name of the destination storage + * container. + */ +export interface ApplicationInsightsComponentExportConfiguration { + readonly exportId?: string; + readonly instrumentationKey?: string; + recordTypes?: string; + readonly applicationName?: string; + readonly subscriptionId?: string; + readonly resourceGroup?: string; + readonly destinationStorageSubscriptionId?: string; + readonly destinationStorageLocationId?: string; + readonly destinationAccountId?: string; + readonly destinationType?: string; + readonly isUserEnabled?: string; + readonly lastUserUpdate?: string; + notificationQueueEnabled?: string; + readonly exportStatus?: string; + readonly lastSuccessTime?: string; + readonly lastGapTime?: string; + readonly permanentErrorReason?: string; + readonly storageName?: string; + readonly containerName?: string; +} + +/** + * @class + * Initializes a new instance of the ApplicationInsightsComponentDataVolumeCap class. + * @constructor + * An Application Insights component daily data volumne cap + * + * @member {number} [cap] Daily data volume cap in GB. + * @member {number} [resetTime] Daily data volume cap UTC reset hour. + * @member {number} [warningThreshold] Reserved, not used for now. + * @member {boolean} [stopSendNotificationWhenHitThreshold] Reserved, not used + * for now. + * @member {boolean} [stopSendNotificationWhenHitCap] Do not send a + * notification email when the daily data volume cap is met. + * @member {number} [maxHistoryCap] Maximum daily data volume cap that the user + * can set for this component. + */ +export interface ApplicationInsightsComponentDataVolumeCap { + cap?: number; + readonly resetTime?: number; + warningThreshold?: number; + stopSendNotificationWhenHitThreshold?: boolean; + stopSendNotificationWhenHitCap?: boolean; + readonly maxHistoryCap?: number; +} + +/** + * @class + * Initializes a new instance of the ApplicationInsightsComponentBillingFeatures class. + * @constructor + * An Application Insights component billing features + * + * @member {object} [dataVolumeCap] An Application Insights component daily + * data volumne cap + * @member {number} [dataVolumeCap.cap] Daily data volume cap in GB. + * @member {number} [dataVolumeCap.resetTime] Daily data volume cap UTC reset + * hour. + * @member {number} [dataVolumeCap.warningThreshold] Reserved, not used for + * now. + * @member {boolean} [dataVolumeCap.stopSendNotificationWhenHitThreshold] + * Reserved, not used for now. + * @member {boolean} [dataVolumeCap.stopSendNotificationWhenHitCap] Do not send + * a notification email when the daily data volume cap is met. + * @member {number} [dataVolumeCap.maxHistoryCap] Maximum daily data volume cap + * that the user can set for this component. + * @member {array} [currentBillingFeatures] Current enabled pricing plan. When + * the component is in the Enterprise plan, this will list both 'Basic' and + * 'Application Insights Enterprise'. + */ +export interface ApplicationInsightsComponentBillingFeatures { + dataVolumeCap?: ApplicationInsightsComponentDataVolumeCap; + currentBillingFeatures?: string[]; +} + +/** + * @class + * Initializes a new instance of the ApplicationInsightsComponentQuotaStatus class. + * @constructor + * An Application Insights component daily data volume cap status + * + * @member {string} [appId] The Application ID for the Application Insights + * component. + * @member {boolean} [shouldBeThrottled] The daily data volume cap is met, and + * data ingestion will be stopped. + * @member {string} [expirationTime] Date and time when the daily data volume + * cap will be reset, and data ingestion will resume. + */ +export interface ApplicationInsightsComponentQuotaStatus { + readonly appId?: string; + readonly shouldBeThrottled?: boolean; + readonly expirationTime?: string; +} + +/** + * @class + * Initializes a new instance of the ApplicationInsightsComponentFeatureCapabilities class. + * @constructor + * An Application Insights component feature capabilities + * + * @member {boolean} [supportExportData] Whether allow to use continuous export + * feature. + * @member {string} [burstThrottlePolicy] Reserved, not used now. + * @member {string} [metadataClass] Reserved, not used now. + * @member {boolean} [liveStreamMetrics] Reserved, not used now. + * @member {boolean} [applicationMap] Reserved, not used now. + * @member {boolean} [workItemIntegration] Whether allow to use work item + * integration feature. + * @member {boolean} [powerBIIntegration] Reserved, not used now. + * @member {boolean} [openSchema] Reserved, not used now. + * @member {boolean} [proactiveDetection] Reserved, not used now. + * @member {boolean} [analyticsIntegration] Reserved, not used now. + * @member {boolean} [multipleStepWebTest] Whether allow to use multiple steps + * web test feature. + * @member {string} [apiAccessLevel] Reserved, not used now. + * @member {string} [trackingType] The applciation insights component used + * tracking type. + * @member {number} [dailyCap] Daily data volume cap in GB. + * @member {number} [dailyCapResetTime] Daily data volume cap UTC reset hour. + * @member {number} [throttleRate] Reserved, not used now. + */ +export interface ApplicationInsightsComponentFeatureCapabilities { + readonly supportExportData?: boolean; + readonly burstThrottlePolicy?: string; + readonly metadataClass?: string; + readonly liveStreamMetrics?: boolean; + readonly applicationMap?: boolean; + readonly workItemIntegration?: boolean; + readonly powerBIIntegration?: boolean; + readonly openSchema?: boolean; + readonly proactiveDetection?: boolean; + readonly analyticsIntegration?: boolean; + readonly multipleStepWebTest?: boolean; + readonly apiAccessLevel?: string; + readonly trackingType?: string; + readonly dailyCap?: number; + readonly dailyCapResetTime?: number; + readonly throttleRate?: number; +} + +/** + * @class + * Initializes a new instance of the ApplicationInsightsComponentFeatureCapability class. + * @constructor + * An Application Insights component feature capability + * + * @member {string} [name] The name of the capability. + * @member {string} [description] The description of the capability. + * @member {string} [value] The vaule of the capability. + * @member {string} [unit] The unit of the capability. + * @member {string} [meterId] The meter used for the capability. + * @member {string} [meterRateFrequency] The meter rate of the meter. + */ +export interface ApplicationInsightsComponentFeatureCapability { + readonly name?: string; + readonly description?: string; + readonly value?: string; + readonly unit?: string; + readonly meterId?: string; + readonly meterRateFrequency?: string; +} + +/** + * @class + * Initializes a new instance of the ApplicationInsightsComponentFeature class. + * @constructor + * An Application Insights component daily data volume cap status + * + * @member {string} [featureName] The pricing feature name. + * @member {string} [meterId] The meter id used for the feature. + * @member {string} [meterRateFrequency] The meter meter rate for the feature's + * meter. + * @member {string} [resouceId] Reserved, not used now. + * @member {boolean} [isHidden] Reserved, not used now. + * @member {array} [capabilities] A list of Application Insigths component + * feature capability. + * @member {string} [title] Desplay name of the feature. + * @member {boolean} [isMainFeature] Whether can apply addon feature on to it. + * @member {string} [supportedAddonFeatures] The add on features on main + * feature. + */ +export interface ApplicationInsightsComponentFeature { + readonly featureName?: string; + readonly meterId?: string; + readonly meterRateFrequency?: string; + readonly resouceId?: string; + readonly isHidden?: boolean; + readonly capabilities?: ApplicationInsightsComponentFeatureCapability[]; + readonly title?: string; + readonly isMainFeature?: boolean; + readonly supportedAddonFeatures?: string; +} + +/** + * @class + * Initializes a new instance of the ApplicationInsightsComponentAvailableFeatures class. + * @constructor + * An Application Insights component available features. + * + * @member {array} [result] A list of Application Insigths component feature. + */ +export interface ApplicationInsightsComponentAvailableFeatures { + readonly result?: ApplicationInsightsComponentFeature[]; +} + +/** + * @class + * Initializes a new instance of the ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions class. + * @constructor + * Static definitions of the ProactiveDetection configuration rule (same values + * for all components). + * + * @member {string} [name] The rule name + * @member {string} [displayName] The rule name as it is displayed in UI + * @member {string} [description] The rule description + * @member {string} [helpUrl] URL which displays aditional info about the + * proactive detection rule + * @member {boolean} [isHidden] A flag indicating whether the rule is hidden + * (from the UI) + * @member {boolean} [isEnabledByDefault] A flag indicating whether the rule is + * enabled by default + * @member {boolean} [isInPreview] A flag indicating whether the rule is in + * preview + * @member {boolean} [supportsEmailNotifications] A flag indicating whether + * email notifications are supported for detections for this rule + */ +export interface ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions { + name?: string; + displayName?: string; + description?: string; + helpUrl?: string; + isHidden?: boolean; + isEnabledByDefault?: boolean; + isInPreview?: boolean; + supportsEmailNotifications?: boolean; +} + +/** + * @class + * Initializes a new instance of the ApplicationInsightsComponentProactiveDetectionConfiguration class. + * @constructor + * Properties that define a ProactiveDetection configuration. + * + * @member {string} [name] The rule name + * @member {boolean} [enabled] A flag that indicates whether this rule is + * enabled by the user + * @member {boolean} [sendEmailsToSubscriptionOwners] A flag that indicated + * whether notifications on this rule should be sent to subscription owners + * @member {array} [customEmails] Custom email addresses for this rule + * notifications + * @member {string} [lastUpdatedTime] The last time this rule was updated + * @member {object} [ruleDefinitions] Static definitions of the + * ProactiveDetection configuration rule (same values for all components). + * @member {string} [ruleDefinitions.name] The rule name + * @member {string} [ruleDefinitions.displayName] The rule name as it is + * displayed in UI + * @member {string} [ruleDefinitions.description] The rule description + * @member {string} [ruleDefinitions.helpUrl] URL which displays aditional info + * about the proactive detection rule + * @member {boolean} [ruleDefinitions.isHidden] A flag indicating whether the + * rule is hidden (from the UI) + * @member {boolean} [ruleDefinitions.isEnabledByDefault] A flag indicating + * whether the rule is enabled by default + * @member {boolean} [ruleDefinitions.isInPreview] A flag indicating whether + * the rule is in preview + * @member {boolean} [ruleDefinitions.supportsEmailNotifications] A flag + * indicating whether email notifications are supported for detections for this + * rule + */ +export interface ApplicationInsightsComponentProactiveDetectionConfiguration extends BaseResource { + name?: string; + enabled?: boolean; + sendEmailsToSubscriptionOwners?: boolean; + customEmails?: string[]; + lastUpdatedTime?: string; + ruleDefinitions?: ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions; +} + +/** + * @class + * Initializes a new instance of the Resource 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 Resource extends BaseResource { + readonly id?: string; + readonly name?: string; + readonly type?: string; + location: string; + tags?: { [propertyName: string]: string }; +} + +/** + * @class + * Initializes a new instance of the TagsResource class. + * @constructor + * A container holding only the Tags for a resource, allowing the user to + * update the tags on a WebTest instance. + * + * @member {object} [tags] Resource tags + */ +export interface TagsResource { + tags?: { [propertyName: string]: string }; +} + +/** + * @class + * Initializes a new instance of the ApplicationInsightsComponent class. + * @constructor + * An Application Insights component definition. + * + * @member {string} kind The kind of application that this component refers to, + * used to customize UI. This value is a freeform string, values should + * typically be one of the following: web, ios, other, store, java, phone. + * @member {string} [applicationId] The unique ID of your application. This + * field mirrors the 'Name' field and cannot be changed. + * @member {string} [appId] Application Insights Unique ID for your + * Application. + * @member {string} applicationType Type of application being monitored. + * Possible values include: 'web', 'other'. Default value: 'web' . + * @member {string} [flowType] Used by the Application Insights system to + * determine what kind of flow this component was created by. This is to be set + * to 'Bluefield' when creating/updating a component via the REST API. Possible + * values include: 'Bluefield'. Default value: 'Bluefield' . + * @member {string} [requestSource] Describes what tool created this + * Application Insights component. Customers using this API should set this to + * the default 'rest'. Possible values include: 'rest'. Default value: 'rest' . + * @member {string} [instrumentationKey] Application Insights Instrumentation + * key. A read-only value that applications can use to identify the destination + * for all telemetry sent to Azure Application Insights. This value will be + * supplied upon construction of each new Application Insights component. + * @member {date} [creationDate] Creation Date for the Application Insights + * component, in ISO 8601 format. + * @member {string} [tenantId] Azure Tenant Id. + * @member {string} [hockeyAppId] The unique application ID created when a new + * application is added to HockeyApp, used for communications with HockeyApp. + * @member {string} [hockeyAppToken] Token used to authenticate communications + * with between Application Insights and HockeyApp. + * @member {string} [provisioningState] Current state of this component: + * whether or not is has been provisioned within the resource group it is + * defined. Users cannot change this value but are able to read from it. Values + * will include Succeeded, Deploying, Canceled, and Failed. + * @member {number} [samplingPercentage] Percentage of the data produced by the + * application being monitored that is being sampled for Application Insights + * telemetry. + */ +export interface ApplicationInsightsComponent extends Resource { + kind: string; + readonly applicationId?: string; + readonly appId?: string; + applicationType: string; + flowType?: string; + requestSource?: string; + readonly instrumentationKey?: string; + readonly creationDate?: Date; + readonly tenantId?: string; + hockeyAppId?: string; + readonly hockeyAppToken?: string; + readonly provisioningState?: string; + samplingPercentage?: number; +} + +/** + * @class + * Initializes a new instance of the ComponentPurgeBodyFilters class. + * @constructor + * User-defined filters to return data which will be purged from the table. + * + * @member {string} [column] The column of the table over which the given query + * should run + * @member {string} [filter] A query to to run over the provided table and + * column to purge the corresponding data. + */ +export interface ComponentPurgeBodyFilters { + column?: string; + filter?: string; +} + +/** + * @class + * Initializes a new instance of the ComponentPurgeBody class. + * @constructor + * Describes the body of a purge request for an App Insights component + * + * @member {string} table Table from which to purge data. + * @member {array} filters The set of columns and filters (queries) to run over + * them to purge the resulting data. + */ +export interface ComponentPurgeBody { + table: string; + filters: ComponentPurgeBodyFilters[]; +} + +/** + * @class + * Initializes a new instance of the ComponentPurgeResponse class. + * @constructor + * Response containing operationId for a specific purge action. + * + * @member {string} operationId Id to use when querying for status for a + * particular purge operation. + */ +export interface ComponentPurgeResponse { + operationId: string; +} + +/** + * @class + * Initializes a new instance of the ComponentPurgeStatusResponse class. + * @constructor + * 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' + */ +export interface ComponentPurgeStatusResponse { + status: string; +} + +/** + * @class + * Initializes a new instance of the WorkItemConfiguration class. + * @constructor + * Work item configuration associated with an application insights resource. + * + * @member {string} [connectorId] Connector identifier where work item is + * created + * @member {string} [configDisplayName] Configuration friendly name + * @member {boolean} [isDefault] Boolean value indicating whether configuration + * is default + * @member {string} [id] Unique Id for work item + * @member {string} [configProperties] Serialized JSON object for detailed + * properties + */ +export interface WorkItemConfiguration { + connectorId?: string; + configDisplayName?: string; + isDefault?: boolean; + id?: string; + configProperties?: string; +} + +/** + * @class + * Initializes a new instance of the WorkItemCreateConfiguration class. + * @constructor + * Work item configuration creation payload + * + * @member {string} [connectorId] Unique connector id + * @member {string} [connectorDataConfiguration] Serialized JSON object for + * detaile d properties + * @member {boolean} [validateOnly] Boolean indicating validate only + * @member {string} [workItemProperties] Custom work item properties + */ +export interface WorkItemCreateConfiguration { + connectorId?: string; + connectorDataConfiguration?: string; + validateOnly?: boolean; + workItemProperties?: string; +} + +/** + * @class + * Initializes a new instance of the WorkItemConfigurationError class. + * @constructor + * Error associated with trying to get work item configuration or + * configurations + * + * @member {string} [code] Error detail code and explanation + * @member {string} [message] Error message + * @member {object} [innererror] + * @member {string} [innererror.diagnosticcontext] Provides correlation for + * request + * @member {date} [innererror.time] Request time + */ +export interface WorkItemConfigurationError { + code?: string; + message?: string; + innererror?: InnerError; +} + +/** + * @class + * Initializes a new instance of the ApplicationInsightsComponentFavorite class. + * @constructor + * Properties that define a favorite that is associated to an Application + * Insights component. + * + * @member {string} [name] The user-defined name of the favorite. + * @member {string} [config] Configuration of this particular favorite, which + * are driven by the Azure portal UX. Configuration data is a string containing + * valid JSON + * @member {string} [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. + * @member {string} [favoriteId] Internally assigned unique id of the favorite + * definition. + * @member {string} [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' + * @member {string} [sourceType] The source of the favorite definition. + * @member {string} [timeModified] Date and time in UTC of the last + * modification that was made to this favorite definition. + * @member {array} [tags] A list of 0 or more tags that are associated with + * this favorite definition + * @member {string} [category] Favorite category, as defined by the user at + * creation time. + * @member {boolean} [isGeneratedFromTemplate] Flag denoting wether or not this + * favorite was generated from a template. + * @member {string} [userId] Unique user id of the specific user that owns this + * favorite. + */ +export interface ApplicationInsightsComponentFavorite { + name?: string; + config?: string; + version?: string; + readonly favoriteId?: string; + favoriteType?: string; + sourceType?: string; + readonly timeModified?: string; + tags?: string[]; + category?: string; + isGeneratedFromTemplate?: boolean; + readonly userId?: string; +} + +/** + * @class + * Initializes a new instance of the ApplicationInsightsComponentWebTestLocation class. + * @constructor + * Properties that define a web test location available to an Application + * Insights Component. + * + * @member {string} [displayName] The display name of the web test location. + * @member {string} [tag] Internally defined geographic location tag. + */ +export interface ApplicationInsightsComponentWebTestLocation { + readonly displayName?: string; + readonly tag?: string; +} + +/** + * @class + * Initializes a new instance of the WebTestGeolocation class. + * @constructor + * Geo-physical location to run a web test from. You must specify one or more + * locations for the test to run from. + * + * @member {string} [location] Location ID for the webtest to run from. + */ +export interface WebTestGeolocation { + location?: string; +} + +/** + * @class + * Initializes a new instance of the WebTestPropertiesConfiguration class. + * @constructor + * An XML configuration specification for a WebTest. + * + * @member {string} [webTest] The XML specification of a WebTest to run against + * an application. + */ +export interface WebTestPropertiesConfiguration { + webTest?: string; +} + +/** + * @class + * Initializes a new instance of the WebTest class. + * @constructor + * An Application Insights web test definition. + * + * @member {string} [kind] The kind of web test that this web test watches. + * Choices are ping and multistep. Possible values include: 'ping', + * 'multistep'. Default value: 'ping' . + * @member {string} syntheticMonitorId Unique ID of this WebTest. This is + * typically the same value as the Name field. + * @member {string} webTestName User defined name if this WebTest. + * @member {string} [description] Purpose/user defined descriptive test for + * this WebTest. + * @member {boolean} [enabled] Is the test actively being monitored. + * @member {number} [frequency] Interval in seconds between test runs for this + * WebTest. Default value is 300. Default value: 300 . + * @member {number} [timeout] Seconds until this WebTest will timeout and fail. + * Default value is 30. Default value: 30 . + * @member {string} webTestKind The kind of web test this is, valid choices are + * ping and multistep. Possible values include: 'ping', 'multistep'. Default + * value: 'ping' . + * @member {boolean} [retryEnabled] Allow for retries should this WebTest fail. + * @member {array} locations A list of where to physically run the tests from + * to give global coverage for accessibility of your application. + * @member {object} [configuration] An XML configuration specification for a + * WebTest. + * @member {string} [configuration.webTest] The XML specification of a WebTest + * to run against an application. + * @member {string} [provisioningState] Current state of this component, + * whether or not is has been provisioned within the resource group it is + * 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 { + kind?: string; + syntheticMonitorId: string; + webTestName: string; + description?: string; + enabled?: boolean; + frequency?: number; + timeout?: number; + webTestKind: string; + retryEnabled?: boolean; + locations: WebTestGeolocation[]; + configuration?: WebTestPropertiesConfiguration; + readonly provisioningState?: string; +} + +/** + * @class + * Initializes a new instance of the Workbook class. + * @constructor + * An Application Insights workbook definition. + * + * @member {string} [kind] The kind of workbook. Choices are user and shared. + * Possible values include: 'user', 'shared' + * @member {string} workbookName The user-defined name of the workbook. + * @member {string} serializedData Configuration of this particular workbook. + * Configuration data is a string containing valid JSON + * @member {string} [version] This instance's version of the data model. This + * can change as new features are added that can be marked workbook. + * @member {string} workbookId Internally assigned unique id of the workbook + * definition. + * @member {string} 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'. Default value: 'shared' . + * @member {string} [timeModified] Date and time in UTC of the last + * modification that was made to this workbook definition. + * @member {string} category Workbook category, as defined by the user at + * creation time. + * @member {array} [workbookTags] A list of 0 or more tags that are associated + * with this workbook definition + * @member {string} userId Unique user id of the specific user that owns this + * workbook. + * @member {string} [sourceResourceId] Optional resourceId for a source + * resource. + */ +export interface Workbook extends Resource { + kind?: string; + workbookName: string; + serializedData: string; + version?: string; + workbookId: string; + sharedTypeKind: string; + readonly timeModified?: string; + category: string; + workbookTags?: string[]; + userId: string; + 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. + * @constructor + * Contains a sourceId and workbook resource id to link two resources. + * + * @member {string} [sourceId] The source Azure resource id + * @member {string} [targetId] The workbook Azure resource id + * @member {string} [category] The category of workbook + */ +export interface LinkProperties { + sourceId?: string; + targetId?: string; + category?: string; +} + +/** + * @class + * Initializes a new instance of the ErrorFieldContract class. + * @constructor + * Error Field contract. + * + * @member {string} [code] Property level error code. + * @member {string} [message] Human-readable representation of property-level + * error. + * @member {string} [target] Property name. + */ +export interface ErrorFieldContract { + code?: string; + message?: string; + target?: string; +} + +/** + * @class + * Initializes a new instance of the WorkbookError class. + * @constructor + * Error message body that will indicate why the operation failed. + * + * @member {string} [code] Service-defined error code. This code serves as a + * sub-status for the HTTP error code specified in the response. + * @member {string} [message] Human-readable representation of the error. + * @member {array} [details] The list of invalid fields send in request, in + * case of validation error. + */ +export interface WorkbookError { + code?: string; + message?: string; + details?: ErrorFieldContract[]; +} + + +/** + * @class + * Initializes a new instance of the OperationListResult class. + * @constructor + * Result of the request to list CDN operations. It contains a list of + * operations and a URL link to get the next set of results. + * + * @member {string} [nextLink] URL to get the next set of operation list + * results if there are any. + */ +export interface OperationListResult extends Array { + nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the ApplicationInsightsComponentAPIKeyListResult class. + * @constructor + * Describes the list of API Keys of an Application Insights Component. + * + */ +export interface ApplicationInsightsComponentAPIKeyListResult extends Array { +} + +/** + * @class + * Initializes a new instance of the ApplicationInsightsComponentListResult class. + * @constructor + * Describes the list of Application Insights Resources. + * + * @member {string} [nextLink] The URI to get the next set of Application + * Insights component defintions if too many components where returned in the + * result set. + */ +export interface ApplicationInsightsComponentListResult extends Array { + nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the ApplicationInsightsWebTestLocationsListResult class. + * @constructor + * Describes the list of web test locations available to an Application + * Insights Component. + * + */ +export interface ApplicationInsightsWebTestLocationsListResult extends Array { +} + +/** + * @class + * Initializes a new instance of the WebTestListResult class. + * @constructor + * A list of 0 or more Application Insights web test definitions. + * + * @member {string} [nextLink] The link to get the next part of the returned + * list of web tests, should the return set be too large for a single request. + * May be null. + */ +export interface WebTestListResult extends Array { + nextLink?: string; +} diff --git a/lib/services/applicationinsights/lib/lib/models/index.js b/lib/services/applicationinsights/lib/lib/models/index.js new file mode 100644 index 0000000000..42328e863f --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/index.js @@ -0,0 +1,64 @@ +/* + * 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. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +var msRestAzure = require('ms-rest-azure'); + +exports.BaseResource = msRestAzure.BaseResource; +exports.CloudError = msRestAzure.CloudError; +exports.ErrorResponse = require('./errorResponse'); +exports.OperationDisplay = require('./operationDisplay'); +exports.Operation = require('./operation'); +exports.Annotation = require('./annotation'); +exports.InnerError = require('./innerError'); +exports.AnnotationError = require('./annotationError'); +exports.APIKeyRequest = require('./aPIKeyRequest'); +exports.ApplicationInsightsComponentAPIKey = require('./applicationInsightsComponentAPIKey'); +exports.ApplicationInsightsComponentExportRequest = require('./applicationInsightsComponentExportRequest'); +exports.ApplicationInsightsComponentExportConfiguration = require('./applicationInsightsComponentExportConfiguration'); +exports.ApplicationInsightsComponentDataVolumeCap = require('./applicationInsightsComponentDataVolumeCap'); +exports.ApplicationInsightsComponentBillingFeatures = require('./applicationInsightsComponentBillingFeatures'); +exports.ApplicationInsightsComponentQuotaStatus = require('./applicationInsightsComponentQuotaStatus'); +exports.ApplicationInsightsComponentFeatureCapabilities = require('./applicationInsightsComponentFeatureCapabilities'); +exports.ApplicationInsightsComponentFeatureCapability = require('./applicationInsightsComponentFeatureCapability'); +exports.ApplicationInsightsComponentFeature = require('./applicationInsightsComponentFeature'); +exports.ApplicationInsightsComponentAvailableFeatures = require('./applicationInsightsComponentAvailableFeatures'); +exports.ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions = require('./applicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions'); +exports.ApplicationInsightsComponentProactiveDetectionConfiguration = require('./applicationInsightsComponentProactiveDetectionConfiguration'); +exports.Resource = require('./resource'); +exports.TagsResource = require('./tagsResource'); +exports.ApplicationInsightsComponent = require('./applicationInsightsComponent'); +exports.ComponentPurgeBodyFilters = require('./componentPurgeBodyFilters'); +exports.ComponentPurgeBody = require('./componentPurgeBody'); +exports.ComponentPurgeResponse = require('./componentPurgeResponse'); +exports.ComponentPurgeStatusResponse = require('./componentPurgeStatusResponse'); +exports.WorkItemConfiguration = require('./workItemConfiguration'); +exports.WorkItemCreateConfiguration = require('./workItemCreateConfiguration'); +exports.WorkItemConfigurationError = require('./workItemConfigurationError'); +exports.ApplicationInsightsComponentFavorite = require('./applicationInsightsComponentFavorite'); +exports.ApplicationInsightsComponentWebTestLocation = require('./applicationInsightsComponentWebTestLocation'); +exports.WebTestGeolocation = require('./webTestGeolocation'); +exports.WebTestPropertiesConfiguration = require('./webTestPropertiesConfiguration'); +exports.WebTest = require('./webTest'); +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.ApplicationInsightsComponentAPIKeyListResult = require('./applicationInsightsComponentAPIKeyListResult'); +exports.ApplicationInsightsComponentListResult = require('./applicationInsightsComponentListResult'); +exports.ApplicationInsightsWebTestLocationsListResult = require('./applicationInsightsWebTestLocationsListResult'); +exports.WebTestListResult = require('./webTestListResult'); diff --git a/lib/services/applicationinsights/lib/lib/models/innerError.js b/lib/services/applicationinsights/lib/lib/models/innerError.js new file mode 100644 index 0000000000..171a217f5e --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/innerError.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'; + +/** + * Inner error + * + */ +class InnerError { + /** + * Create a InnerError. + * @member {string} [diagnosticcontext] Provides correlation for request + * @member {date} [time] Request time + */ + constructor() { + } + + /** + * Defines the metadata of InnerError + * + * @returns {object} metadata of InnerError + * + */ + mapper() { + return { + required: false, + serializedName: 'InnerError', + type: { + name: 'Composite', + className: 'InnerError', + modelProperties: { + diagnosticcontext: { + required: false, + serializedName: 'diagnosticcontext', + type: { + name: 'String' + } + }, + time: { + required: false, + serializedName: 'time', + type: { + name: 'DateTime' + } + } + } + } + }; + } +} + +module.exports = InnerError; diff --git a/lib/services/applicationinsights/lib/lib/models/linkProperties.js b/lib/services/applicationinsights/lib/lib/models/linkProperties.js new file mode 100644 index 0000000000..998d71f024 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/linkProperties.js @@ -0,0 +1,68 @@ +/* + * 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'; + +/** + * Contains a sourceId and workbook resource id to link two resources. + * + */ +class LinkProperties { + /** + * Create a LinkProperties. + * @member {string} [sourceId] The source Azure resource id + * @member {string} [targetId] The workbook Azure resource id + * @member {string} [category] The category of workbook + */ + constructor() { + } + + /** + * Defines the metadata of LinkProperties + * + * @returns {object} metadata of LinkProperties + * + */ + mapper() { + return { + required: false, + serializedName: 'LinkProperties', + type: { + name: 'Composite', + className: 'LinkProperties', + modelProperties: { + sourceId: { + required: false, + serializedName: 'sourceId', + type: { + name: 'String' + } + }, + targetId: { + required: false, + serializedName: 'targetId', + type: { + name: 'String' + } + }, + category: { + required: false, + serializedName: 'category', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = LinkProperties; diff --git a/lib/services/applicationinsights/lib/lib/models/operation.js b/lib/services/applicationinsights/lib/lib/models/operation.js new file mode 100644 index 0000000000..6c5b4ed71a --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/operation.js @@ -0,0 +1,68 @@ +/* + * 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'); + +/** + * CDN REST API operation + * + */ +class Operation { + /** + * Create a Operation. + * @member {string} [name] Operation name: {provider}/{resource}/{operation} + * @member {object} [display] The object that represents the operation. + * @member {string} [display.provider] Service provider: Microsoft.Cdn + * @member {string} [display.resource] Resource on which the operation is + * performed: Profile, endpoint, etc. + * @member {string} [display.operation] Operation type: Read, write, delete, + * etc. + */ + constructor() { + } + + /** + * Defines the metadata of Operation + * + * @returns {object} metadata of Operation + * + */ + mapper() { + return { + required: false, + serializedName: 'Operation', + type: { + name: 'Composite', + className: 'Operation', + modelProperties: { + name: { + required: false, + serializedName: 'name', + type: { + name: 'String' + } + }, + display: { + required: false, + serializedName: 'display', + type: { + name: 'Composite', + className: 'OperationDisplay' + } + } + } + } + }; + } +} + +module.exports = Operation; diff --git a/lib/services/applicationinsights/lib/lib/models/operationDisplay.js b/lib/services/applicationinsights/lib/lib/models/operationDisplay.js new file mode 100644 index 0000000000..59c79a2f66 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/operationDisplay.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The object that represents the operation. + * + */ +class OperationDisplay { + /** + * Create a OperationDisplay. + * @member {string} [provider] Service provider: Microsoft.Cdn + * @member {string} [resource] Resource on which the operation is performed: + * Profile, endpoint, etc. + * @member {string} [operation] Operation type: Read, write, delete, etc. + */ + constructor() { + } + + /** + * Defines the metadata of OperationDisplay + * + * @returns {object} metadata of OperationDisplay + * + */ + mapper() { + return { + required: false, + serializedName: 'Operation_display', + type: { + name: 'Composite', + className: 'OperationDisplay', + modelProperties: { + provider: { + required: false, + serializedName: 'provider', + type: { + name: 'String' + } + }, + resource: { + required: false, + serializedName: 'resource', + type: { + name: 'String' + } + }, + operation: { + required: false, + serializedName: 'operation', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = OperationDisplay; diff --git a/lib/services/applicationinsights/lib/lib/models/operationListResult.js b/lib/services/applicationinsights/lib/lib/models/operationListResult.js new file mode 100644 index 0000000000..0e53ce9ac9 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/operationListResult.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Result of the request to list CDN operations. It contains a list of + * operations and a URL link to get the next set of results. + */ +class OperationListResult extends Array { + /** + * Create a OperationListResult. + * @member {string} [nextLink] URL to get the next set of operation list + * results if there are any. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of OperationListResult + * + * @returns {object} metadata of OperationListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'OperationListResult', + type: { + name: 'Composite', + className: 'OperationListResult', + modelProperties: { + value: { + required: false, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'OperationElementType', + type: { + name: 'Composite', + className: 'Operation' + } + } + } + }, + nextLink: { + required: false, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = OperationListResult; diff --git a/lib/services/applicationinsights/lib/lib/models/resource.js b/lib/services/applicationinsights/lib/lib/models/resource.js new file mode 100644 index 0000000000..429ae3a958 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/resource.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 Resource extends models['BaseResource'] { + /** + * Create a Resource. + * @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 Resource + * + * @returns {object} metadata of Resource + * + */ + mapper() { + return { + required: false, + serializedName: 'Resource', + type: { + name: 'Composite', + className: 'Resource', + 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 = Resource; diff --git a/lib/services/applicationinsights/lib/lib/models/tagsResource.js b/lib/services/applicationinsights/lib/lib/models/tagsResource.js new file mode 100644 index 0000000000..cee86475e8 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/tagsResource.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'; + +/** + * A container holding only the Tags for a resource, allowing the user to + * update the tags on a WebTest instance. + * + */ +class TagsResource { + /** + * Create a TagsResource. + * @member {object} [tags] Resource tags + */ + constructor() { + } + + /** + * Defines the metadata of TagsResource + * + * @returns {object} metadata of TagsResource + * + */ + mapper() { + return { + required: false, + serializedName: 'TagsResource', + type: { + name: 'Composite', + className: 'TagsResource', + modelProperties: { + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = TagsResource; diff --git a/lib/services/applicationinsights/lib/lib/models/webTest.js b/lib/services/applicationinsights/lib/lib/models/webTest.js new file mode 100644 index 0000000000..4a980abf98 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/webTest.js @@ -0,0 +1,221 @@ +/* + * 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 Application Insights web test definition. + * + * @extends models['Resource'] + */ +class WebTest extends models['Resource'] { + /** + * Create a WebTest. + * @member {string} [kind] The kind of web test that this web test watches. + * Choices are ping and multistep. Possible values include: 'ping', + * 'multistep'. Default value: 'ping' . + * @member {string} syntheticMonitorId Unique ID of this WebTest. This is + * typically the same value as the Name field. + * @member {string} webTestName User defined name if this WebTest. + * @member {string} [description] Purpose/user defined descriptive test for + * this WebTest. + * @member {boolean} [enabled] Is the test actively being monitored. + * @member {number} [frequency] Interval in seconds between test runs for + * this WebTest. Default value is 300. Default value: 300 . + * @member {number} [timeout] Seconds until this WebTest will timeout and + * fail. Default value is 30. Default value: 30 . + * @member {string} webTestKind The kind of web test this is, valid choices + * are ping and multistep. Possible values include: 'ping', 'multistep'. + * Default value: 'ping' . + * @member {boolean} [retryEnabled] Allow for retries should this WebTest + * fail. + * @member {array} locations A list of where to physically run the tests from + * to give global coverage for accessibility of your application. + * @member {object} [configuration] An XML configuration specification for a + * WebTest. + * @member {string} [configuration.webTest] The XML specification of a + * WebTest to run against an application. + * @member {string} [provisioningState] Current state of this component, + * whether or not is has been provisioned within the resource group it is + * defined. Users cannot change this value but are able to read from it. + * Values will include Succeeded, Deploying, Canceled, and Failed. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of WebTest + * + * @returns {object} metadata of WebTest + * + */ + mapper() { + return { + required: false, + serializedName: 'WebTest', + type: { + name: 'Composite', + className: 'WebTest', + 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' + } + } + } + }, + kind: { + required: false, + serializedName: 'kind', + defaultValue: 'ping', + type: { + name: 'Enum', + allowedValues: [ 'ping', 'multistep' ] + } + }, + syntheticMonitorId: { + required: true, + serializedName: 'properties.SyntheticMonitorId', + type: { + name: 'String' + } + }, + webTestName: { + required: true, + serializedName: 'properties.Name', + type: { + name: 'String' + } + }, + description: { + required: false, + serializedName: 'properties.Description', + type: { + name: 'String' + } + }, + enabled: { + required: false, + serializedName: 'properties.Enabled', + type: { + name: 'Boolean' + } + }, + frequency: { + required: false, + serializedName: 'properties.Frequency', + defaultValue: 300, + type: { + name: 'Number' + } + }, + timeout: { + required: false, + serializedName: 'properties.Timeout', + defaultValue: 30, + type: { + name: 'Number' + } + }, + webTestKind: { + required: true, + serializedName: 'properties.Kind', + defaultValue: 'ping', + type: { + name: 'Enum', + allowedValues: [ 'ping', 'multistep' ] + } + }, + retryEnabled: { + required: false, + serializedName: 'properties.RetryEnabled', + type: { + name: 'Boolean' + } + }, + locations: { + required: true, + serializedName: 'properties.Locations', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'WebTestGeolocationElementType', + type: { + name: 'Composite', + className: 'WebTestGeolocation' + } + } + } + }, + configuration: { + required: false, + serializedName: 'properties.Configuration', + type: { + name: 'Composite', + className: 'WebTestPropertiesConfiguration' + } + }, + provisioningState: { + required: false, + readOnly: true, + serializedName: 'properties.provisioningState', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = WebTest; diff --git a/lib/services/applicationinsights/lib/lib/models/webTestGeolocation.js b/lib/services/applicationinsights/lib/lib/models/webTestGeolocation.js new file mode 100644 index 0000000000..c4d776f1df --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/webTestGeolocation.js @@ -0,0 +1,53 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Geo-physical location to run a web test from. You must specify one or more + * locations for the test to run from. + * + */ +class WebTestGeolocation { + /** + * Create a WebTestGeolocation. + * @member {string} [location] Location ID for the webtest to run from. + */ + constructor() { + } + + /** + * Defines the metadata of WebTestGeolocation + * + * @returns {object} metadata of WebTestGeolocation + * + */ + mapper() { + return { + required: false, + serializedName: 'WebTestGeolocation', + type: { + name: 'Composite', + className: 'WebTestGeolocation', + modelProperties: { + location: { + required: false, + serializedName: 'Id', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = WebTestGeolocation; diff --git a/lib/services/applicationinsights/lib/lib/models/webTestListResult.js b/lib/services/applicationinsights/lib/lib/models/webTestListResult.js new file mode 100644 index 0000000000..bd93e2deb4 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/webTestListResult.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * A list of 0 or more Application Insights web test definitions. + */ +class WebTestListResult extends Array { + /** + * Create a WebTestListResult. + * @member {string} [nextLink] The link to get the next part of the returned + * list of web tests, should the return set be too large for a single + * request. May be null. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of WebTestListResult + * + * @returns {object} metadata of WebTestListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'webTestListResult', + type: { + name: 'Composite', + className: 'WebTestListResult', + modelProperties: { + value: { + required: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'WebTestElementType', + type: { + name: 'Composite', + className: 'WebTest' + } + } + } + }, + nextLink: { + required: false, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = WebTestListResult; diff --git a/lib/services/applicationinsights/lib/lib/models/webTestPropertiesConfiguration.js b/lib/services/applicationinsights/lib/lib/models/webTestPropertiesConfiguration.js new file mode 100644 index 0000000000..c8772acebf --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/webTestPropertiesConfiguration.js @@ -0,0 +1,53 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * An XML configuration specification for a WebTest. + * + */ +class WebTestPropertiesConfiguration { + /** + * Create a WebTestPropertiesConfiguration. + * @member {string} [webTest] The XML specification of a WebTest to run + * against an application. + */ + constructor() { + } + + /** + * Defines the metadata of WebTestPropertiesConfiguration + * + * @returns {object} metadata of WebTestPropertiesConfiguration + * + */ + mapper() { + return { + required: false, + serializedName: 'WebTestProperties_Configuration', + type: { + name: 'Composite', + className: 'WebTestPropertiesConfiguration', + modelProperties: { + webTest: { + required: false, + serializedName: 'WebTest', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = WebTestPropertiesConfiguration; diff --git a/lib/services/applicationinsights/lib/lib/models/workItemConfiguration.js b/lib/services/applicationinsights/lib/lib/models/workItemConfiguration.js new file mode 100644 index 0000000000..f5a7ec8a9e --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/workItemConfiguration.js @@ -0,0 +1,87 @@ +/* + * 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 associated with an application insights resource. + * + */ +class WorkItemConfiguration { + /** + * Create a WorkItemConfiguration. + * @member {string} [connectorId] Connector identifier where work item is + * created + * @member {string} [configDisplayName] Configuration friendly name + * @member {boolean} [isDefault] Boolean value indicating whether + * configuration is default + * @member {string} [id] Unique Id for work item + * @member {string} [configProperties] Serialized JSON object for detailed + * properties + */ + constructor() { + } + + /** + * Defines the metadata of WorkItemConfiguration + * + * @returns {object} metadata of WorkItemConfiguration + * + */ + mapper() { + return { + required: false, + serializedName: 'WorkItemConfiguration', + type: { + name: 'Composite', + className: 'WorkItemConfiguration', + modelProperties: { + connectorId: { + required: false, + serializedName: 'ConnectorId', + type: { + name: 'String' + } + }, + configDisplayName: { + required: false, + serializedName: 'ConfigDisplayName', + type: { + name: 'String' + } + }, + isDefault: { + required: false, + serializedName: 'IsDefault', + type: { + name: 'Boolean' + } + }, + id: { + required: false, + serializedName: 'Id', + type: { + name: 'String' + } + }, + configProperties: { + required: false, + serializedName: 'ConfigProperties', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = WorkItemConfiguration; diff --git a/lib/services/applicationinsights/lib/lib/models/workItemConfigurationError.js b/lib/services/applicationinsights/lib/lib/models/workItemConfigurationError.js new file mode 100644 index 0000000000..562531bf21 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/workItemConfigurationError.js @@ -0,0 +1,75 @@ +/* + * 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'); + +/** + * Error associated with trying to get work item configuration or + * configurations + * + */ +class WorkItemConfigurationError { + /** + * Create a WorkItemConfigurationError. + * @member {string} [code] Error detail code and explanation + * @member {string} [message] Error message + * @member {object} [innererror] + * @member {string} [innererror.diagnosticcontext] Provides correlation for + * request + * @member {date} [innererror.time] Request time + */ + constructor() { + } + + /** + * Defines the metadata of WorkItemConfigurationError + * + * @returns {object} metadata of WorkItemConfigurationError + * + */ + mapper() { + return { + required: false, + serializedName: 'WorkItemConfigurationError', + type: { + name: 'Composite', + className: 'WorkItemConfigurationError', + modelProperties: { + code: { + required: false, + serializedName: 'code', + type: { + name: 'String' + } + }, + message: { + required: false, + serializedName: 'message', + type: { + name: 'String' + } + }, + innererror: { + required: false, + serializedName: 'innererror', + type: { + name: 'Composite', + className: 'InnerError' + } + } + } + } + }; + } +} + +module.exports = WorkItemConfigurationError; diff --git a/lib/services/applicationinsights/lib/lib/models/workItemCreateConfiguration.js b/lib/services/applicationinsights/lib/lib/models/workItemCreateConfiguration.js new file mode 100644 index 0000000000..f15933feb7 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/workItemCreateConfiguration.js @@ -0,0 +1,77 @@ +/* + * 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 creation payload + * + */ +class WorkItemCreateConfiguration { + /** + * Create a WorkItemCreateConfiguration. + * @member {string} [connectorId] Unique connector id + * @member {string} [connectorDataConfiguration] Serialized JSON object for + * detaile d properties + * @member {boolean} [validateOnly] Boolean indicating validate only + * @member {string} [workItemProperties] Custom work item properties + */ + constructor() { + } + + /** + * Defines the metadata of WorkItemCreateConfiguration + * + * @returns {object} metadata of WorkItemCreateConfiguration + * + */ + mapper() { + return { + required: false, + serializedName: 'WorkItemCreateConfiguration', + type: { + name: 'Composite', + className: 'WorkItemCreateConfiguration', + modelProperties: { + connectorId: { + required: false, + serializedName: 'ConnectorId', + type: { + name: 'String' + } + }, + connectorDataConfiguration: { + required: false, + serializedName: 'ConnectorDataConfiguration', + type: { + name: 'String' + } + }, + validateOnly: { + required: false, + serializedName: 'ValidateOnly', + type: { + name: 'Boolean' + } + }, + workItemProperties: { + required: false, + serializedName: 'WorkItemProperties', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = WorkItemCreateConfiguration; diff --git a/lib/services/applicationinsights/lib/lib/models/workbook.js b/lib/services/applicationinsights/lib/lib/models/workbook.js new file mode 100644 index 0000000000..1cfb66657d --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/workbook.js @@ -0,0 +1,202 @@ +/* + * 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 Application Insights workbook definition. + * + * @extends models['Resource'] + */ +class Workbook extends models['Resource'] { + /** + * Create a Workbook. + * @member {string} [kind] The kind of workbook. Choices are user and shared. + * Possible values include: 'user', 'shared' + * @member {string} workbookName The user-defined name of the workbook. + * @member {string} serializedData Configuration of this particular workbook. + * Configuration data is a string containing valid JSON + * @member {string} [version] This instance's version of the data model. This + * can change as new features are added that can be marked workbook. + * @member {string} workbookId Internally assigned unique id of the workbook + * definition. + * @member {string} 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'. Default value: 'shared' . + * @member {string} [timeModified] Date and time in UTC of the last + * modification that was made to this workbook definition. + * @member {string} category Workbook category, as defined by the user at + * creation time. + * @member {array} [workbookTags] A list of 0 or more tags that are + * associated with this workbook definition + * @member {string} userId Unique user id of the specific user that owns this + * workbook. + * @member {string} [sourceResourceId] Optional resourceId for a source + * resource. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Workbook + * + * @returns {object} metadata of Workbook + * + */ + mapper() { + return { + required: false, + serializedName: 'Workbook', + type: { + name: 'Composite', + className: 'Workbook', + 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' + } + } + } + }, + kind: { + required: false, + serializedName: 'kind', + type: { + name: 'String' + } + }, + workbookName: { + required: true, + serializedName: 'properties.name', + type: { + name: 'String' + } + }, + serializedData: { + required: true, + serializedName: 'properties.serializedData', + type: { + name: 'String' + } + }, + version: { + required: false, + serializedName: 'properties.version', + type: { + name: 'String' + } + }, + workbookId: { + required: true, + serializedName: 'properties.workbookId', + type: { + name: 'String' + } + }, + sharedTypeKind: { + required: true, + serializedName: 'properties.kind', + defaultValue: 'shared', + type: { + name: 'String' + } + }, + timeModified: { + required: false, + readOnly: true, + serializedName: 'properties.timeModified', + type: { + name: 'String' + } + }, + category: { + required: true, + serializedName: 'properties.category', + type: { + name: 'String' + } + }, + workbookTags: { + required: false, + serializedName: 'properties.tags', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + userId: { + required: true, + serializedName: 'properties.userId', + type: { + name: 'String' + } + }, + sourceResourceId: { + required: false, + serializedName: 'properties.sourceResourceId', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = Workbook; diff --git a/lib/services/applicationinsights/lib/lib/models/workbookError.js b/lib/services/applicationinsights/lib/lib/models/workbookError.js new file mode 100644 index 0000000000..f3eee37bda --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/workbookError.js @@ -0,0 +1,80 @@ +/* + * 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'); + +/** + * Error message body that will indicate why the operation failed. + * + */ +class WorkbookError { + /** + * Create a WorkbookError. + * @member {string} [code] Service-defined error code. This code serves as a + * sub-status for the HTTP error code specified in the response. + * @member {string} [message] Human-readable representation of the error. + * @member {array} [details] The list of invalid fields send in request, in + * case of validation error. + */ + constructor() { + } + + /** + * Defines the metadata of WorkbookError + * + * @returns {object} metadata of WorkbookError + * + */ + mapper() { + return { + required: false, + serializedName: 'WorkbookError', + type: { + name: 'Composite', + className: 'WorkbookError', + modelProperties: { + code: { + required: false, + serializedName: 'code', + type: { + name: 'String' + } + }, + message: { + required: false, + serializedName: 'message', + type: { + name: 'String' + } + }, + details: { + required: false, + serializedName: 'details', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ErrorFieldContractElementType', + type: { + name: 'Composite', + className: 'ErrorFieldContract' + } + } + } + } + } + } + }; + } +} + +module.exports = WorkbookError; diff --git a/lib/services/applicationinsights/lib/lib/models/workbookErrorResponse.js b/lib/services/applicationinsights/lib/lib/models/workbookErrorResponse.js new file mode 100644 index 0000000000..0a296ab14b --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/workbookErrorResponse.js @@ -0,0 +1,80 @@ +/* + * 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'); + +/** + * Error message body that will indicate why the operation failed. + * + */ +class WorkbookErrorResponse { + /** + * Create a WorkbookErrorResponse. + * @member {string} [code] Service-defined error code. This code serves as a + * sub-status for the HTTP error code specified in the response. + * @member {string} [message] Human-readable representation of the error. + * @member {array} [details] The list of invalid fields send in request, in + * case of validation error. + */ + constructor() { + } + + /** + * Defines the metadata of WorkbookErrorResponse + * + * @returns {object} metadata of WorkbookErrorResponse + * + */ + mapper() { + return { + required: false, + serializedName: 'WorkbookErrorResponse', + type: { + name: 'Composite', + className: 'WorkbookErrorResponse', + modelProperties: { + code: { + required: false, + serializedName: 'code', + type: { + name: 'String' + } + }, + message: { + required: false, + serializedName: 'message', + type: { + name: 'String' + } + }, + details: { + required: false, + serializedName: 'details', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ErrorFieldContractElementType', + type: { + name: 'Composite', + className: 'ErrorFieldContract' + } + } + } + } + } + } + }; + } +} + +module.exports = WorkbookErrorResponse; diff --git a/lib/services/applicationinsights/lib/lib/models/workbookListResult.js b/lib/services/applicationinsights/lib/lib/models/workbookListResult.js new file mode 100644 index 0000000000..97cd6a85d0 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/workbookListResult.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Workbook list result. + * + */ +class WorkbookListResult { + /** + * Create a WorkbookListResult. + * @member {array} [value] An array of workbooks. + */ + constructor() { + } + + /** + * Defines the metadata of WorkbookListResult + * + * @returns {object} metadata of WorkbookListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'WorkbookListResult', + type: { + name: 'Composite', + className: 'WorkbookListResult', + modelProperties: { + value: { + required: false, + serializedName: 'value', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'WorkbookElementType', + type: { + name: 'Composite', + className: 'Workbook' + } + } + } + } + } + } + }; + } +} + +module.exports = WorkbookListResult; diff --git a/lib/services/applicationinsights/lib/lib/models/workbooks.js b/lib/services/applicationinsights/lib/lib/models/workbooks.js new file mode 100644 index 0000000000..6e729490e2 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/models/workbooks.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Workbook list result. + * + */ +class Workbooks { + /** + * Create a Workbooks. + * @member {array} [value] An array of workbooks. + */ + constructor() { + } + + /** + * Defines the metadata of Workbooks + * + * @returns {object} metadata of Workbooks + * + */ + mapper() { + return { + required: false, + serializedName: 'Workbooks', + type: { + name: 'Composite', + className: 'Workbooks', + modelProperties: { + value: { + required: false, + serializedName: 'value', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'WorkbookElementType', + type: { + name: 'Composite', + className: 'Workbook' + } + } + } + } + } + } + }; + } +} + +module.exports = Workbooks; diff --git a/lib/services/applicationinsights/lib/lib/operations/aPIKeys.js b/lib/services/applicationinsights/lib/lib/operations/aPIKeys.js new file mode 100644 index 0000000000..580a24f80b --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/operations/aPIKeys.js @@ -0,0 +1,1055 @@ +/* + * 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 API keys of 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 {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 + * ApplicationInsightsComponentAPIKeyListResult} for more + * information. + * + * {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, 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 (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}/ApiKeys'; + 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('&'); + } + + // 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['ApplicationInsightsComponentAPIKeyListResult']().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 an API Key of 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} aPIKeyProperties Properties that need to be specified to + * create an API key of a Application Insights component. + * + * @param {string} [aPIKeyProperties.name] The name of the API Key. + * + * @param {array} [aPIKeyProperties.linkedReadProperties] The read access + * rights of this API Key. + * + * @param {array} [aPIKeyProperties.linkedWriteProperties] The write access + * rights of this API Key. + * + * @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 ApplicationInsightsComponentAPIKey} for more + * information. + * + * {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, aPIKeyProperties, 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 (aPIKeyProperties === null || aPIKeyProperties === undefined) { + throw new Error('aPIKeyProperties 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}/ApiKeys'; + 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('&'); + } + + // 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 (aPIKeyProperties !== null && aPIKeyProperties !== undefined) { + let requestModelMapper = new client.models['APIKeyRequest']().mapper(); + requestModel = client.serialize(requestModelMapper, aPIKeyProperties, 'aPIKeyProperties'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(aPIKeyProperties, 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['ApplicationInsightsComponentAPIKey']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Delete an API Key of 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} keyId The API Key ID. This is unique within a 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 ApplicationInsightsComponentAPIKey} for more + * information. + * + * {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, keyId, 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 (keyId === null || keyId === undefined || typeof keyId.valueOf() !== 'string') { + throw new Error('keyId 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}/APIKeys/{keyId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); + requestUrl = requestUrl.replace('{keyId}', encodeURIComponent(keyId)); + 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; + // 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['ApplicationInsightsComponentAPIKey']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Get the API Key for this key id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} keyId The API Key ID. This is unique within a 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 ApplicationInsightsComponentAPIKey} for more + * information. + * + * {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, keyId, 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 (keyId === null || keyId === undefined || typeof keyId.valueOf() !== 'string') { + throw new Error('keyId 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}/APIKeys/{keyId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); + requestUrl = requestUrl.replace('{keyId}', encodeURIComponent(keyId)); + 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['ApplicationInsightsComponentAPIKey']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a APIKeys. */ +class APIKeys { + /** + * Create a APIKeys. + * @param {ApplicationInsightsManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._create = _create; + this._deleteMethod = _deleteMethod; + this._get = _get; + } + + /** + * Gets a list of API keys of 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 {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 API keys of 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 {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 {ApplicationInsightsComponentAPIKeyListResult} - 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 + * ApplicationInsightsComponentAPIKeyListResult} for more + * information. + * + * {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); + } + } + + /** + * Create an API Key of 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} aPIKeyProperties Properties that need to be specified to + * create an API key of a Application Insights component. + * + * @param {string} [aPIKeyProperties.name] The name of the API Key. + * + * @param {array} [aPIKeyProperties.linkedReadProperties] The read access + * rights of this API Key. + * + * @param {array} [aPIKeyProperties.linkedWriteProperties] The write access + * rights of this API Key. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createWithHttpOperationResponse(resourceGroupName, resourceName, aPIKeyProperties, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._create(resourceGroupName, resourceName, aPIKeyProperties, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Create an API Key of 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} aPIKeyProperties Properties that need to be specified to + * create an API key of a Application Insights component. + * + * @param {string} [aPIKeyProperties.name] The name of the API Key. + * + * @param {array} [aPIKeyProperties.linkedReadProperties] The read access + * rights of this API Key. + * + * @param {array} [aPIKeyProperties.linkedWriteProperties] The write access + * rights of this API Key. + * + * @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 {ApplicationInsightsComponentAPIKey} - 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 ApplicationInsightsComponentAPIKey} for more + * information. + * + * {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, aPIKeyProperties, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._create(resourceGroupName, resourceName, aPIKeyProperties, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._create(resourceGroupName, resourceName, aPIKeyProperties, options, optionalCallback); + } + } + + /** + * Delete an API Key of 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} keyId The API Key ID. This is unique within a 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, keyId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, resourceName, keyId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Delete an API Key of 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} keyId The API Key ID. This is unique within a 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 {ApplicationInsightsComponentAPIKey} - 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 ApplicationInsightsComponentAPIKey} for more + * information. + * + * {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, keyId, 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, keyId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, resourceName, keyId, options, optionalCallback); + } + } + + /** + * Get the API Key for this key id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} keyId The API Key ID. This is unique within a 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, keyId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, resourceName, keyId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get the API Key for this key id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} keyId The API Key ID. This is unique within a 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 {ApplicationInsightsComponentAPIKey} - 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 ApplicationInsightsComponentAPIKey} for more + * information. + * + * {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, keyId, 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, keyId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, resourceName, keyId, options, optionalCallback); + } + } + +} + +module.exports = APIKeys; diff --git a/lib/services/applicationinsights/lib/lib/operations/annotations.js b/lib/services/applicationinsights/lib/lib/operations/annotations.js new file mode 100644 index 0000000000..9cbbf32d6a --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/operations/annotations.js @@ -0,0 +1,1132 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets the list of annotations for a component for given time range + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} start The start time to query from for annotations, cannot + * be older than 90 days from current date. + * + * @param {string} end The end time to query for annotations. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {array} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(resourceGroupName, resourceName, start, end, 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 (start === null || start === undefined || typeof start.valueOf() !== 'string') { + throw new Error('start cannot be null or undefined and it must be of type string.'); + } + if (end === null || end === undefined || typeof end.valueOf() !== 'string') { + throw new Error('end 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}/Annotations'; + 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)); + queryParameters.push('start=' + encodeURIComponent(start)); + queryParameters.push('end=' + encodeURIComponent(end)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['AnnotationError']().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: 'AnnotationElementType', + type: { + name: 'Composite', + className: 'Annotation' + } + } + } + }; + 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 an Annotation of 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} annotationProperties Properties that need to be specified to + * create an annotation of a Application Insights component. + * + * @param {string} [annotationProperties.annotationName] Name of annotation + * + * @param {string} [annotationProperties.category] Category of annotation, free + * form + * + * @param {date} [annotationProperties.eventTime] Time when event occurred + * + * @param {string} [annotationProperties.id] Unique Id for annotation + * + * @param {string} [annotationProperties.properties] Serialized JSON object for + * detailed properties + * + * @param {string} [annotationProperties.relatedAnnotation] Related parent + * annotation if any + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {array} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _create(resourceGroupName, resourceName, annotationProperties, 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 (annotationProperties === null || annotationProperties === undefined) { + throw new Error('annotationProperties 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}/Annotations'; + 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('&'); + } + + // 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 (annotationProperties !== null && annotationProperties !== undefined) { + let requestModelMapper = new client.models['Annotation']().mapper(); + requestModel = client.serialize(requestModelMapper, annotationProperties, 'annotationProperties'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(annotationProperties, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['AnnotationError']().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: 'AnnotationElementType', + type: { + name: 'Composite', + className: 'Annotation' + } + } + } + }; + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Delete an Annotation of 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} annotationId The unique annotation ID. This is unique within + * a 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. + * + * {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, annotationId, 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 (annotationId === null || annotationId === undefined || typeof annotationId.valueOf() !== 'string') { + throw new Error('annotationId 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}/Annotations/{annotationId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); + requestUrl = requestUrl.replace('{annotationId}', encodeURIComponent(annotationId)); + 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; + // 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: 'Object' + } + }; + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Get the annotation for given id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} annotationId The unique annotation ID. This is unique within + * a 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. + * + * {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 _get(resourceGroupName, resourceName, annotationId, 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 (annotationId === null || annotationId === undefined || typeof annotationId.valueOf() !== 'string') { + throw new Error('annotationId 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}/Annotations/{annotationId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); + requestUrl = requestUrl.replace('{annotationId}', encodeURIComponent(annotationId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['AnnotationError']().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: 'AnnotationElementType', + type: { + name: 'Composite', + className: 'Annotation' + } + } + } + }; + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a Annotations. */ +class Annotations { + /** + * Create a Annotations. + * @param {ApplicationInsightsManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._create = _create; + this._deleteMethod = _deleteMethod; + this._get = _get; + } + + /** + * Gets the list of annotations for a component for given time range + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} start The start time to query from for annotations, cannot + * be older than 90 days from current date. + * + * @param {string} end The end time to query for annotations. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(resourceGroupName, resourceName, start, end, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(resourceGroupName, resourceName, start, end, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the list of annotations for a component for given time range + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} start The start time to query from for annotations, cannot + * be older than 90 days from current date. + * + * @param {string} end The end time to query for annotations. + * + * @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 {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, start, end, 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, start, end, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(resourceGroupName, resourceName, start, end, options, optionalCallback); + } + } + + /** + * Create an Annotation of 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} annotationProperties Properties that need to be specified to + * create an annotation of a Application Insights component. + * + * @param {string} [annotationProperties.annotationName] Name of annotation + * + * @param {string} [annotationProperties.category] Category of annotation, free + * form + * + * @param {date} [annotationProperties.eventTime] Time when event occurred + * + * @param {string} [annotationProperties.id] Unique Id for annotation + * + * @param {string} [annotationProperties.properties] Serialized JSON object for + * detailed properties + * + * @param {string} [annotationProperties.relatedAnnotation] Related parent + * annotation if any + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createWithHttpOperationResponse(resourceGroupName, resourceName, annotationProperties, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._create(resourceGroupName, resourceName, annotationProperties, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Create an Annotation of 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} annotationProperties Properties that need to be specified to + * create an annotation of a Application Insights component. + * + * @param {string} [annotationProperties.annotationName] Name of annotation + * + * @param {string} [annotationProperties.category] Category of annotation, free + * form + * + * @param {date} [annotationProperties.eventTime] Time when event occurred + * + * @param {string} [annotationProperties.id] Unique Id for annotation + * + * @param {string} [annotationProperties.properties] Serialized JSON object for + * detailed properties + * + * @param {string} [annotationProperties.relatedAnnotation] Related parent + * annotation if any + * + * @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 {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. + */ + create(resourceGroupName, resourceName, annotationProperties, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._create(resourceGroupName, resourceName, annotationProperties, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._create(resourceGroupName, resourceName, annotationProperties, options, optionalCallback); + } + } + + /** + * Delete an Annotation of 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} annotationId The unique annotation ID. This is unique within + * a 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, annotationId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, resourceName, annotationId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Delete an Annotation of 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} annotationId The unique annotation ID. This is unique within + * a 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 {Object} - 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. + * + * {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, annotationId, 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, annotationId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, resourceName, annotationId, options, optionalCallback); + } + } + + /** + * Get the annotation for given id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} annotationId The unique annotation ID. This is unique within + * a 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, annotationId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, resourceName, annotationId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get the annotation for given id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} annotationId The unique annotation ID. This is unique within + * a 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 {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. + */ + get(resourceGroupName, resourceName, annotationId, 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, annotationId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, resourceName, annotationId, options, optionalCallback); + } + } + +} + +module.exports = Annotations; diff --git a/lib/services/applicationinsights/lib/lib/operations/componentAvailableFeatures.js b/lib/services/applicationinsights/lib/lib/operations/componentAvailableFeatures.js new file mode 100644 index 0000000000..4c09dca770 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/operations/componentAvailableFeatures.js @@ -0,0 +1,268 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Returns all available features of the 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 {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 + * ApplicationInsightsComponentAvailableFeatures} for more + * information. + * + * {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, 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 (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}/getavailablebillingfeatures'; + 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('&'); + } + + // 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['ApplicationInsightsComponentAvailableFeatures']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a ComponentAvailableFeatures. */ +class ComponentAvailableFeatures { + /** + * Create a ComponentAvailableFeatures. + * @param {ApplicationInsightsManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + } + + /** + * Returns all available features of the 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 {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, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(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; + }); + }); + } + + /** + * Returns all available features of the 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 {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 {ApplicationInsightsComponentAvailableFeatures} - 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 + * ApplicationInsightsComponentAvailableFeatures} for more + * information. + * + * {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, 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, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, resourceName, options, optionalCallback); + } + } + +} + +module.exports = ComponentAvailableFeatures; diff --git a/lib/services/applicationinsights/lib/lib/operations/componentCurrentBillingFeatures.js b/lib/services/applicationinsights/lib/lib/operations/componentCurrentBillingFeatures.js new file mode 100644 index 0000000000..3a51f84308 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/operations/componentCurrentBillingFeatures.js @@ -0,0 +1,592 @@ +/* + * 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; + +/** + * Returns current billing features for 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 {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 ApplicationInsightsComponentBillingFeatures} + * for more information. + * + * {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, 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 (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}/currentbillingfeatures'; + 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('&'); + } + + // 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['ApplicationInsightsComponentBillingFeatures']().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); + }); +} + +/** + * Update current billing features for 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} billingFeaturesProperties Properties that need to be + * specified to update billing features for an Application Insights component. + * + * @param {object} [billingFeaturesProperties.dataVolumeCap] An Application + * Insights component daily data volumne cap + * + * @param {number} [billingFeaturesProperties.dataVolumeCap.cap] Daily data + * volume cap in GB. + * + * @param {number} [billingFeaturesProperties.dataVolumeCap.warningThreshold] + * Reserved, not used for now. + * + * @param {boolean} + * [billingFeaturesProperties.dataVolumeCap.stopSendNotificationWhenHitThreshold] + * Reserved, not used for now. + * + * @param {boolean} + * [billingFeaturesProperties.dataVolumeCap.stopSendNotificationWhenHitCap] Do + * not send a notification email when the daily data volume cap is met. + * + * @param {array} [billingFeaturesProperties.currentBillingFeatures] Current + * enabled pricing plan. When the component is in the Enterprise plan, this + * will list both 'Basic' and 'Application Insights Enterprise'. + * + * @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 ApplicationInsightsComponentBillingFeatures} + * for more information. + * + * {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, billingFeaturesProperties, 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 (billingFeaturesProperties === null || billingFeaturesProperties === undefined) { + throw new Error('billingFeaturesProperties 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}/currentbillingfeatures'; + 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('&'); + } + + // 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 (billingFeaturesProperties !== null && billingFeaturesProperties !== undefined) { + let requestModelMapper = new client.models['ApplicationInsightsComponentBillingFeatures']().mapper(); + requestModel = client.serialize(requestModelMapper, billingFeaturesProperties, 'billingFeaturesProperties'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(billingFeaturesProperties, 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['ApplicationInsightsComponentBillingFeatures']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a ComponentCurrentBillingFeatures. */ +class ComponentCurrentBillingFeatures { + /** + * Create a ComponentCurrentBillingFeatures. + * @param {ApplicationInsightsManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._update = _update; + } + + /** + * Returns current billing features for 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 {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, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(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; + }); + }); + } + + /** + * Returns current billing features for 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 {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 {ApplicationInsightsComponentBillingFeatures} - 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 ApplicationInsightsComponentBillingFeatures} + * for more information. + * + * {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, 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, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, resourceName, options, optionalCallback); + } + } + + /** + * Update current billing features for 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} billingFeaturesProperties Properties that need to be + * specified to update billing features for an Application Insights component. + * + * @param {object} [billingFeaturesProperties.dataVolumeCap] An Application + * Insights component daily data volumne cap + * + * @param {number} [billingFeaturesProperties.dataVolumeCap.cap] Daily data + * volume cap in GB. + * + * @param {number} [billingFeaturesProperties.dataVolumeCap.warningThreshold] + * Reserved, not used for now. + * + * @param {boolean} + * [billingFeaturesProperties.dataVolumeCap.stopSendNotificationWhenHitThreshold] + * Reserved, not used for now. + * + * @param {boolean} + * [billingFeaturesProperties.dataVolumeCap.stopSendNotificationWhenHitCap] Do + * not send a notification email when the daily data volume cap is met. + * + * @param {array} [billingFeaturesProperties.currentBillingFeatures] Current + * enabled pricing plan. When the component is in the Enterprise plan, this + * will list both 'Basic' and 'Application Insights Enterprise'. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName, resourceName, billingFeaturesProperties, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(resourceGroupName, resourceName, billingFeaturesProperties, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Update current billing features for 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} billingFeaturesProperties Properties that need to be + * specified to update billing features for an Application Insights component. + * + * @param {object} [billingFeaturesProperties.dataVolumeCap] An Application + * Insights component daily data volumne cap + * + * @param {number} [billingFeaturesProperties.dataVolumeCap.cap] Daily data + * volume cap in GB. + * + * @param {number} [billingFeaturesProperties.dataVolumeCap.warningThreshold] + * Reserved, not used for now. + * + * @param {boolean} + * [billingFeaturesProperties.dataVolumeCap.stopSendNotificationWhenHitThreshold] + * Reserved, not used for now. + * + * @param {boolean} + * [billingFeaturesProperties.dataVolumeCap.stopSendNotificationWhenHitCap] Do + * not send a notification email when the daily data volume cap is met. + * + * @param {array} [billingFeaturesProperties.currentBillingFeatures] Current + * enabled pricing plan. When the component is in the Enterprise plan, this + * will list both 'Basic' and 'Application Insights Enterprise'. + * + * @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 {ApplicationInsightsComponentBillingFeatures} - 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 ApplicationInsightsComponentBillingFeatures} + * for more information. + * + * {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, billingFeaturesProperties, 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, billingFeaturesProperties, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(resourceGroupName, resourceName, billingFeaturesProperties, options, optionalCallback); + } + } + +} + +module.exports = ComponentCurrentBillingFeatures; diff --git a/lib/services/applicationinsights/lib/lib/operations/componentFeatureCapabilities.js b/lib/services/applicationinsights/lib/lib/operations/componentFeatureCapabilities.js new file mode 100644 index 0000000000..2b3873b153 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/operations/componentFeatureCapabilities.js @@ -0,0 +1,268 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Returns feature capabilites of the 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 {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 + * ApplicationInsightsComponentFeatureCapabilities} for + * more information. + * + * {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, 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 (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}/featurecapabilities'; + 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('&'); + } + + // 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['ApplicationInsightsComponentFeatureCapabilities']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a ComponentFeatureCapabilities. */ +class ComponentFeatureCapabilities { + /** + * Create a ComponentFeatureCapabilities. + * @param {ApplicationInsightsManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + } + + /** + * Returns feature capabilites of the 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 {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, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(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; + }); + }); + } + + /** + * Returns feature capabilites of the 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 {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 {ApplicationInsightsComponentFeatureCapabilities} - 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 + * ApplicationInsightsComponentFeatureCapabilities} for + * more information. + * + * {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, 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, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, resourceName, options, optionalCallback); + } + } + +} + +module.exports = ComponentFeatureCapabilities; diff --git a/lib/services/applicationinsights/lib/lib/operations/componentQuotaStatus.js b/lib/services/applicationinsights/lib/lib/operations/componentQuotaStatus.js new file mode 100644 index 0000000000..0eba541676 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/operations/componentQuotaStatus.js @@ -0,0 +1,269 @@ +/* + * 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; + +/** + * Returns daily data volume cap (quota) status for 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 {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 ApplicationInsightsComponentQuotaStatus} for + * more information. + * + * {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, 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 (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}/quotastatus'; + 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('&'); + } + + // 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['ApplicationInsightsComponentQuotaStatus']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a ComponentQuotaStatus. */ +class ComponentQuotaStatus { + /** + * Create a ComponentQuotaStatus. + * @param {ApplicationInsightsManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + } + + /** + * Returns daily data volume cap (quota) status for 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 {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, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(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; + }); + }); + } + + /** + * Returns daily data volume cap (quota) status for 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 {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 {ApplicationInsightsComponentQuotaStatus} - 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 ApplicationInsightsComponentQuotaStatus} for + * more information. + * + * {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, 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, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, resourceName, options, optionalCallback); + } + } + +} + +module.exports = ComponentQuotaStatus; diff --git a/lib/services/websiteManagement2/lib/operations/recommendations.js b/lib/services/applicationinsights/lib/lib/operations/components.js similarity index 60% rename from lib/services/websiteManagement2/lib/operations/recommendations.js rename to lib/services/applicationinsights/lib/lib/operations/components.js index 9a5449c349..104b7fdedb 100644 --- a/lib/services/websiteManagement2/lib/operations/recommendations.js +++ b/lib/services/applicationinsights/lib/lib/operations/components.js @@ -15,21 +15,10 @@ const msRestAzure = require('ms-rest-azure'); const WebResource = msRest.WebResource; /** - * @summary List all recommendations for a subscription. - * - * List all recommendations for a subscription. + * Gets a list of all Application Insights components within a subscription. * * @param {object} [options] Optional Parameters. * - * @param {boolean} [options.featured] Specify true to return only - * the most critical recommendations. The default is false, which - * returns all recommendations. - * - * @param {string} [options.filter] Filter is specified by using OData syntax. - * Example: $filter=channels eq 'Api' or channel eq 'Notification' and - * startTime eq '2014-01-01T00:00:00Z' and endTime eq '2014-12-31T23:59:59Z' - * and timeGrain eq duration'[PT1H|PT1M|P1D] - * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -40,8 +29,8 @@ 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 RecommendationCollection} for more - * information. + * See {@link ApplicationInsightsComponentListResult} for + * more information. * * {object} [request] - The HTTP Request object if an error did not occur. * @@ -57,22 +46,14 @@ function _list(options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } - let featured = (options && options.featured !== undefined) ? options.featured : undefined; - let filter = (options && options.filter !== undefined) ? options.filter : undefined; // Validate try { - if (featured !== null && featured !== undefined && typeof featured !== 'boolean') { - throw new Error('featured must be of type boolean.'); - } - if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { - throw new Error('filter 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 (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { - throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); - } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); } @@ -82,15 +63,9 @@ function _list(options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Web/recommendations'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Insights/components'; requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); let queryParameters = []; - if (featured !== null && featured !== undefined) { - queryParameters.push('featured=' + encodeURIComponent(featured.toString())); - } - if (filter !== null && filter !== undefined) { - queryParameters.push('$filter=' + filter); - } queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); @@ -133,13 +108,12 @@ function _list(options, callback) { try { parsedErrorResponse = JSON.parse(responseBody); if (parsedErrorResponse) { - let internalError = null; - if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; - error.code = internalError ? internalError.code : parsedErrorResponse.code; - error.message = internalError ? internalError.message : parsedErrorResponse.message; + if (parsedErrorResponse.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['DefaultErrorResponse']().mapper(); + let resultMapper = new client.models['CloudError']().mapper(); error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); } } catch (defaultError) { @@ -159,7 +133,7 @@ function _list(options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['RecommendationCollection']().mapper(); + let resultMapper = new client.models['ApplicationInsightsComponentListResult']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -175,9 +149,9 @@ function _list(options, callback) { } /** - * @summary Reset all recommendation opt-out settings for a subscription. + * Gets a list of Application Insights components within a resource group. * - * Reset all recommendation opt-out settings for a subscription. + * @param {string} resourceGroupName The name of the resource group. * * @param {object} [options] Optional Parameters. * @@ -190,13 +164,15 @@ function _list(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 ApplicationInsightsComponentListResult} for + * more information. * * {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 _resetAllFilters(options, callback) { +function _listByResourceGroup(resourceGroupName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -208,12 +184,15 @@ function _resetAllFilters(options, callback) { } // 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 (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); } @@ -223,7 +202,8 @@ function _resetAllFilters(options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Web/recommendations/reset'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); let queryParameters = []; queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); @@ -233,7 +213,7 @@ function _resetAllFilters(options, callback) { // Create HTTP transport objects let httpRequest = new WebResource(); - httpRequest.method = 'POST'; + httpRequest.method = 'GET'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers @@ -258,7 +238,7 @@ function _resetAllFilters(options, callback) { return callback(err); } let statusCode = response.statusCode; - if (statusCode !== 204) { + if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); @@ -286,19 +266,35 @@ function _resetAllFilters(options, callback) { // 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['ApplicationInsightsComponentListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } return callback(null, result, httpRequest, response); }); } /** - * @summary Disables the specified rule so it will not apply to a subscription - * in the future. + * Deletes an Application Insights component. * - * Disables the specified rule so it will not apply to a subscription in the - * future. + * @param {string} resourceGroupName The name of the resource group. * - * @param {string} name Rule name + * @param {string} resourceName The name of the Application Insights component + * resource. * * @param {object} [options] Optional Parameters. * @@ -317,7 +313,7 @@ function _resetAllFilters(options, callback) { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _disableRecommendationForSubscription(name, options, callback) { +function _deleteMethod(resourceGroupName, resourceName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -329,14 +325,17 @@ function _disableRecommendationForSubscription(name, options, callback) { } // Validate try { - if (name === null || name === undefined || typeof name.valueOf() !== 'string') { - throw new Error('name cannot be null or undefined and it must be of type string.'); + if (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 (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 (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 (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.'); @@ -347,9 +346,10 @@ function _disableRecommendationForSubscription(name, options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Web/recommendations/{name}/disable'; - requestUrl = requestUrl.replace('{name}', encodeURIComponent(name)); + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'; + 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) { @@ -358,7 +358,7 @@ function _disableRecommendationForSubscription(name, options, callback) { // Create HTTP transport objects let httpRequest = new WebResource(); - httpRequest.method = 'POST'; + httpRequest.method = 'DELETE'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers @@ -383,7 +383,7 @@ function _disableRecommendationForSubscription(name, options, callback) { return callback(err); } let statusCode = response.statusCode; - if (statusCode !== 200) { + if (statusCode !== 200 && statusCode !== 204) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); @@ -417,27 +417,15 @@ function _disableRecommendationForSubscription(name, options, callback) { } /** - * @summary Get past recommendations for an app, optionally specified by the - * time range. - * - * Get past recommendations for an app, optionally specified by the time range. + * Returns an Application Insights component. * - * @param {string} resourceGroupName Name of the resource group to which the - * resource belongs. + * @param {string} resourceGroupName The name of the resource group. * - * @param {string} siteName Name of the app. + * @param {string} resourceName The name of the Application Insights component + * resource. * * @param {object} [options] Optional Parameters. * - * @param {boolean} [options.expiredOnly] Specify false to return - * all recommendations. The default is true, which returns only - * expired recommendations. - * - * @param {string} [options.filter] Filter is specified by using OData syntax. - * Example: $filter=channels eq 'Api' or channel eq 'Notification' and - * startTime eq '2014-01-01T00:00:00Z' and endTime eq '2014-12-31T23:59:59Z' - * and timeGrain eq duration'[PT1H|PT1M|P1D] - * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -448,14 +436,14 @@ function _disableRecommendationForSubscription(name, options, callback) { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link RecommendationCollection} for more + * See {@link ApplicationInsightsComponent} for more * information. * * {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 _listHistoryForWebApp(resourceGroupName, siteName, options, callback) { +function _get(resourceGroupName, resourceName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -465,41 +453,19 @@ function _listHistoryForWebApp(resourceGroupName, siteName, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } - let expiredOnly = (options && options.expiredOnly !== undefined) ? options.expiredOnly : undefined; - let filter = (options && options.filter !== undefined) ? options.filter : undefined; // 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 (resourceGroupName !== null && resourceGroupName !== undefined) { - if (resourceGroupName.length > 90) - { - throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); - } - if (resourceGroupName.length < 1) - { - throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); - } - if (resourceGroupName.match(/^[-\w\._\(\)]+[^\.]$/) === null) - { - throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+[^\.]$/'); - } - } - if (siteName === null || siteName === undefined || typeof siteName.valueOf() !== 'string') { - throw new Error('siteName cannot be null or undefined and it must be of type string.'); - } - if (expiredOnly !== null && expiredOnly !== undefined && typeof expiredOnly !== 'boolean') { - throw new Error('expiredOnly must be of type boolean.'); - } - if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { - throw new Error('filter 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 (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 (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 (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.'); @@ -510,17 +476,11 @@ function _listHistoryForWebApp(resourceGroupName, siteName, options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/recommendationHistory'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'; requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); - requestUrl = requestUrl.replace('{siteName}', encodeURIComponent(siteName)); requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); let queryParameters = []; - if (expiredOnly !== null && expiredOnly !== undefined) { - queryParameters.push('expiredOnly=' + encodeURIComponent(expiredOnly.toString())); - } - if (filter !== null && filter !== undefined) { - queryParameters.push('$filter=' + filter); - } queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); @@ -563,13 +523,12 @@ function _listHistoryForWebApp(resourceGroupName, siteName, options, callback) { try { parsedErrorResponse = JSON.parse(responseBody); if (parsedErrorResponse) { - let internalError = null; - if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; - error.code = internalError ? internalError.code : parsedErrorResponse.code; - error.message = internalError ? internalError.message : parsedErrorResponse.message; + if (parsedErrorResponse.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['DefaultErrorResponse']().mapper(); + let resultMapper = new client.models['CloudError']().mapper(); error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); } } catch (defaultError) { @@ -589,7 +548,7 @@ function _listHistoryForWebApp(resourceGroupName, siteName, options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['RecommendationCollection']().mapper(); + let resultMapper = new client.models['ApplicationInsightsComponent']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -605,24 +564,48 @@ function _listHistoryForWebApp(resourceGroupName, siteName, options, callback) { } /** - * @summary Get all recommendations for an app. + * Creates (or updates) an Application Insights component. Note: You cannot + * specify a different value for InstrumentationKey nor AppId in the Put + * operation. * - * Get all recommendations for an app. + * @param {string} resourceGroupName The name of the resource group. * - * @param {string} resourceGroupName Name of the resource group to which the - * resource belongs. + * @param {string} resourceName The name of the Application Insights component + * resource. * - * @param {string} siteName Name of the app. + * @param {object} insightProperties Properties that need to be specified to + * create an Application Insights component. * - * @param {object} [options] Optional Parameters. + * @param {string} insightProperties.kind The kind of application that this + * component refers to, used to customize UI. This value is a freeform string, + * values should typically be one of the following: web, ios, other, store, + * java, phone. + * + * @param {string} insightProperties.applicationType Type of application being + * monitored. Possible values include: 'web', 'other' + * + * @param {string} [insightProperties.flowType] Used by the Application + * Insights system to determine what kind of flow this component was created + * by. This is to be set to 'Bluefield' when creating/updating a component via + * the REST API. Possible values include: 'Bluefield' + * + * @param {string} [insightProperties.requestSource] Describes what tool + * created this Application Insights component. Customers using this API should + * set this to the default 'rest'. Possible values include: 'rest' + * + * @param {string} [insightProperties.hockeyAppId] The unique application ID + * created when a new application is added to HockeyApp, used for + * communications with HockeyApp. + * + * @param {number} [insightProperties.samplingPercentage] Percentage of the + * data produced by the application being monitored that is being sampled for + * Application Insights telemetry. * - * @param {boolean} [options.featured] Specify true to return only - * the most critical recommendations. The default is false, which - * returns all recommendations. + * @param {string} insightProperties.location Resource location * - * @param {string} [options.filter] Return only channels specified in the - * filter. Filter is specified by using OData syntax. Example: $filter=channels - * eq 'Api' or channel eq 'Notification' + * @param {object} [insightProperties.tags] Resource tags + * + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -634,14 +617,14 @@ function _listHistoryForWebApp(resourceGroupName, siteName, 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 RecommendationCollection} for more + * See {@link ApplicationInsightsComponent} for more * information. * * {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 _listRecommendedRulesForWebApp(resourceGroupName, siteName, options, callback) { +function _createOrUpdate(resourceGroupName, resourceName, insightProperties, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -651,41 +634,22 @@ function _listRecommendedRulesForWebApp(resourceGroupName, siteName, options, ca if (!callback) { throw new Error('callback cannot be null.'); } - let featured = (options && options.featured !== undefined) ? options.featured : undefined; - let filter = (options && options.filter !== undefined) ? options.filter : undefined; // 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 (resourceGroupName !== null && resourceGroupName !== undefined) { - if (resourceGroupName.length > 90) - { - throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); - } - if (resourceGroupName.length < 1) - { - throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); - } - if (resourceGroupName.match(/^[-\w\._\(\)]+[^\.]$/) === null) - { - throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+[^\.]$/'); - } - } - if (siteName === null || siteName === undefined || typeof siteName.valueOf() !== 'string') { - throw new Error('siteName cannot be null or undefined and it must be of type string.'); - } - if (featured !== null && featured !== undefined && typeof featured !== 'boolean') { - throw new Error('featured must be of type boolean.'); - } - if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { - throw new Error('filter 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 (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 (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 (insightProperties === null || insightProperties === undefined) { + throw new Error('insightProperties 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.'); @@ -696,17 +660,11 @@ function _listRecommendedRulesForWebApp(resourceGroupName, siteName, options, ca // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/recommendations'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'; requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); - requestUrl = requestUrl.replace('{siteName}', encodeURIComponent(siteName)); requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); let queryParameters = []; - if (featured !== null && featured !== undefined) { - queryParameters.push('featured=' + encodeURIComponent(featured.toString())); - } - if (filter !== null && filter !== undefined) { - queryParameters.push('$filter=' + filter); - } queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); @@ -714,7 +672,7 @@ function _listRecommendedRulesForWebApp(resourceGroupName, siteName, options, ca // Create HTTP transport objects let httpRequest = new WebResource(); - httpRequest.method = 'GET'; + httpRequest.method = 'PUT'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers @@ -732,7 +690,21 @@ function _listRecommendedRulesForWebApp(resourceGroupName, siteName, options, ca } } } - httpRequest.body = null; + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (insightProperties !== null && insightProperties !== undefined) { + let requestModelMapper = new client.models['ApplicationInsightsComponent']().mapper(); + requestModel = client.serialize(requestModelMapper, insightProperties, 'insightProperties'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(insightProperties, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; // Send Request return client.pipeline(httpRequest, (err, response, responseBody) => { if (err) { @@ -749,13 +721,12 @@ function _listRecommendedRulesForWebApp(resourceGroupName, siteName, options, ca try { parsedErrorResponse = JSON.parse(responseBody); if (parsedErrorResponse) { - let internalError = null; - if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; - error.code = internalError ? internalError.code : parsedErrorResponse.code; - error.message = internalError ? internalError.message : parsedErrorResponse.message; + if (parsedErrorResponse.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['DefaultErrorResponse']().mapper(); + let resultMapper = new client.models['CloudError']().mapper(); error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); } } catch (defaultError) { @@ -775,7 +746,7 @@ function _listRecommendedRulesForWebApp(resourceGroupName, siteName, options, ca parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['RecommendationCollection']().mapper(); + let resultMapper = new client.models['ApplicationInsightsComponent']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -791,14 +762,18 @@ function _listRecommendedRulesForWebApp(resourceGroupName, siteName, options, ca } /** - * @summary Disable all recommendations for an app. + * Updates an existing component's tags. To update other fields use the + * CreateOrUpdate method. + * + * @param {string} resourceGroupName The name of the resource group. * - * Disable all recommendations for an app. + * @param {string} resourceName The name of the Application Insights component + * resource. * - * @param {string} resourceGroupName Name of the resource group to which the - * resource belongs. + * @param {object} componentTags Updated tag information to set into the + * component instance. * - * @param {string} siteName Name of the app. + * @param {object} [componentTags.tags] Resource tags * * @param {object} [options] Optional Parameters. * @@ -811,13 +786,15 @@ function _listRecommendedRulesForWebApp(resourceGroupName, siteName, options, ca * * {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 ApplicationInsightsComponent} for more + * information. * * {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 _disableAllForWebApp(resourceGroupName, siteName, options, callback) { +function _updateTags(resourceGroupName, resourceName, componentTags, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -832,28 +809,17 @@ function _disableAllForWebApp(resourceGroupName, siteName, options, callback) { 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 (resourceGroupName !== null && resourceGroupName !== undefined) { - if (resourceGroupName.length > 90) - { - throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); - } - if (resourceGroupName.length < 1) - { - throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); - } - if (resourceGroupName.match(/^[-\w\._\(\)]+[^\.]$/) === null) - { - throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+[^\.]$/'); - } - } - if (siteName === null || siteName === undefined || typeof siteName.valueOf() !== 'string') { - throw new Error('siteName 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 (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 (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 (componentTags === null || componentTags === undefined) { + throw new Error('componentTags 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.'); @@ -864,10 +830,10 @@ function _disableAllForWebApp(resourceGroupName, siteName, options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/recommendations/disable'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'; requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); - requestUrl = requestUrl.replace('{siteName}', encodeURIComponent(siteName)); 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) { @@ -876,7 +842,7 @@ function _disableAllForWebApp(resourceGroupName, siteName, options, callback) { // Create HTTP transport objects let httpRequest = new WebResource(); - httpRequest.method = 'POST'; + httpRequest.method = 'PATCH'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers @@ -894,14 +860,28 @@ function _disableAllForWebApp(resourceGroupName, siteName, options, callback) { } } } - httpRequest.body = null; + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (componentTags !== null && componentTags !== undefined) { + let requestModelMapper = new client.models['TagsResource']().mapper(); + requestModel = client.serialize(requestModelMapper, componentTags, 'componentTags'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(componentTags, 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 !== 204) { + if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); @@ -929,20 +909,44 @@ function _disableAllForWebApp(resourceGroupName, siteName, options, callback) { // 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['ApplicationInsightsComponent']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } return callback(null, result, httpRequest, response); }); } /** - * @summary Reset all recommendation opt-out settings for an app. + * Purges data in an Application Insights component by a set of user-defined + * filters. + * + * @param {string} resourceGroupName The name of the resource group. * - * Reset all recommendation opt-out settings for an app. + * @param {string} resourceName The name of the Application Insights component + * resource. * - * @param {string} resourceGroupName Name of the resource group to which the - * resource belongs. + * @param {object} body Describes the body of a request to purge data in a + * single table of an Application Insights component * - * @param {string} siteName Name of the app. + * @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 {object} [options] Optional Parameters. * @@ -955,13 +959,15 @@ function _disableAllForWebApp(resourceGroupName, siteName, 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 ComponentPurgeResponse} for more + * information. * * {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 _resetAllFiltersForWebApp(resourceGroupName, siteName, options, callback) { +function _purge(resourceGroupName, resourceName, body, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -976,28 +982,17 @@ function _resetAllFiltersForWebApp(resourceGroupName, siteName, options, callbac 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 (resourceGroupName !== null && resourceGroupName !== undefined) { - if (resourceGroupName.length > 90) - { - throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); - } - if (resourceGroupName.length < 1) - { - throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); - } - if (resourceGroupName.match(/^[-\w\._\(\)]+[^\.]$/) === null) - { - throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+[^\.]$/'); - } - } - if (siteName === null || siteName === undefined || typeof siteName.valueOf() !== 'string') { - throw new Error('siteName 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 (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 (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.'); @@ -1008,10 +1003,10 @@ function _resetAllFiltersForWebApp(resourceGroupName, siteName, options, callbac // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/recommendations/reset'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge'; requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); - requestUrl = requestUrl.replace('{siteName}', encodeURIComponent(siteName)); 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) { @@ -1038,14 +1033,28 @@ function _resetAllFiltersForWebApp(resourceGroupName, siteName, options, callbac } } } - httpRequest.body = null; + // 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 !== 204) { + if (statusCode !== 202) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); @@ -1073,32 +1082,42 @@ function _resetAllFiltersForWebApp(resourceGroupName, siteName, options, callbac // 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 = new client.models['ComponentPurgeResponse']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } return callback(null, result, httpRequest, response); }); } /** - * @summary Get a recommendation rule for an app. - * - * Get a recommendation rule for an app. + * Gets the status of a previously submitted purge using the id returned from + * the original purge request. * - * @param {string} resourceGroupName Name of the resource group to which the - * resource belongs. + * @param {string} resourceGroupName The name of the resource group. * - * @param {string} siteName Name of the app. + * @param {string} resourceName The name of the Application Insights component + * resource. * - * @param {string} name Name of the recommendation. + * @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. * - * @param {boolean} [options.updateSeen] Specify true to update - * the last-seen timestamp of the recommendation object. - * - * @param {string} [options.recommendationId] The GUID of the recommedation - * object if you query an expired one. You don't need to specify it to query an - * active entry. - * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -1109,13 +1128,14 @@ function _resetAllFiltersForWebApp(resourceGroupName, siteName, options, callbac * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link RecommendationRule} for more information. + * 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 _getRuleDetailsByWebApp(resourceGroupName, siteName, name, options, callback) { +function _getPurgeStatus(resourceGroupName, resourceName, purgeId, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -1125,44 +1145,22 @@ function _getRuleDetailsByWebApp(resourceGroupName, siteName, name, options, cal if (!callback) { throw new Error('callback cannot be null.'); } - let updateSeen = (options && options.updateSeen !== undefined) ? options.updateSeen : undefined; - let recommendationId = (options && options.recommendationId !== undefined) ? options.recommendationId : undefined; // 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 (resourceGroupName !== null && resourceGroupName !== undefined) { - if (resourceGroupName.length > 90) - { - throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); - } - if (resourceGroupName.length < 1) - { - throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); - } - if (resourceGroupName.match(/^[-\w\._\(\)]+[^\.]$/) === null) - { - throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+[^\.]$/'); - } - } - if (siteName === null || siteName === undefined || typeof siteName.valueOf() !== 'string') { - throw new Error('siteName cannot be null or undefined and it must be of type string.'); - } - if (name === null || name === undefined || typeof name.valueOf() !== 'string') { - throw new Error('name cannot be null or undefined and it must be of type string.'); - } - if (updateSeen !== null && updateSeen !== undefined && typeof updateSeen !== 'boolean') { - throw new Error('updateSeen must be of type boolean.'); - } - if (recommendationId !== null && recommendationId !== undefined && typeof recommendationId.valueOf() !== 'string') { - throw new Error('recommendationId 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 (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 (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 (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.'); @@ -1173,18 +1171,12 @@ function _getRuleDetailsByWebApp(resourceGroupName, siteName, name, options, cal // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/recommendations/{name}'; + 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('{siteName}', encodeURIComponent(siteName)); - requestUrl = requestUrl.replace('{name}', encodeURIComponent(name)); requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); + requestUrl = requestUrl.replace('{purgeId}', encodeURIComponent(purgeId)); let queryParameters = []; - if (updateSeen !== null && updateSeen !== undefined) { - queryParameters.push('updateSeen=' + encodeURIComponent(updateSeen.toString())); - } - if (recommendationId !== null && recommendationId !== undefined) { - queryParameters.push('recommendationId=' + encodeURIComponent(recommendationId)); - } queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); @@ -1227,13 +1219,12 @@ function _getRuleDetailsByWebApp(resourceGroupName, siteName, name, options, cal try { parsedErrorResponse = JSON.parse(responseBody); if (parsedErrorResponse) { - let internalError = null; - if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; - error.code = internalError ? internalError.code : parsedErrorResponse.code; - error.message = internalError ? internalError.message : parsedErrorResponse.message; + if (parsedErrorResponse.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['DefaultErrorResponse']().mapper(); + let resultMapper = new client.models['CloudError']().mapper(); error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); } } catch (defaultError) { @@ -1253,7 +1244,7 @@ function _getRuleDetailsByWebApp(resourceGroupName, siteName, name, options, cal parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['RecommendationRule']().mapper(); + let resultMapper = new client.models['ComponentPurgeStatusResponse']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -1269,16 +1260,10 @@ function _getRuleDetailsByWebApp(resourceGroupName, siteName, name, options, cal } /** - * @summary Disables the specific rule for a web site permanently. - * - * Disables the specific rule for a web site permanently. - * - * @param {string} resourceGroupName Name of the resource group to which the - * resource belongs. - * - * @param {string} siteName Site name + * Gets a list of all Application Insights components within a subscription. * - * @param {string} name Rule name + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. * * @param {object} [options] Optional Parameters. * @@ -1291,13 +1276,15 @@ function _getRuleDetailsByWebApp(resourceGroupName, siteName, name, options, cal * * {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 ApplicationInsightsComponentListResult} for + * more information. * * {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 _disableRecommendationForSite(resourceGroupName, siteName, name, options, callback) { +function _listNext(nextPageLink, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -1309,34 +1296,8 @@ function _disableRecommendationForSite(resourceGroupName, siteName, name, option } // 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 (resourceGroupName !== null && resourceGroupName !== undefined) { - if (resourceGroupName.length > 90) - { - throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); - } - if (resourceGroupName.length < 1) - { - throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); - } - if (resourceGroupName.match(/^[-\w\._\(\)]+[^\.]$/) === null) - { - throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+[^\.]$/'); - } - } - if (siteName === null || siteName === undefined || typeof siteName.valueOf() !== 'string') { - throw new Error('siteName cannot be null or undefined and it must be of type string.'); - } - if (name === null || name === undefined || typeof name.valueOf() !== 'string') { - throw new Error('name cannot be null or undefined and it must be of type string.'); - } - if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { - throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); - } - if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { - throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); @@ -1346,21 +1307,12 @@ function _disableRecommendationForSite(resourceGroupName, siteName, name, option } // Construct URL - let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/recommendations/{name}/disable'; - requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); - requestUrl = requestUrl.replace('{siteName}', encodeURIComponent(siteName)); - requestUrl = requestUrl.replace('{name}', encodeURIComponent(name)); - requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); - let queryParameters = []; - queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); - if (queryParameters.length > 0) { - requestUrl += '?' + queryParameters.join('&'); - } + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); // Create HTTP transport objects let httpRequest = new WebResource(); - httpRequest.method = 'POST'; + httpRequest.method = 'GET'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers @@ -1413,15 +1365,30 @@ function _disableRecommendationForSite(resourceGroupName, siteName, name, option // 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['ApplicationInsightsComponentListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } return callback(null, result, httpRequest, response); }); } /** - * @summary List all recommendations for a subscription. - * - * List all recommendations for a subscription. + * Gets a list of Application Insights components within a resource group. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -1438,14 +1405,14 @@ function _disableRecommendationForSite(resourceGroupName, siteName, name, option * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link RecommendationCollection} for more - * information. + * See {@link ApplicationInsightsComponentListResult} for + * more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _listNext(nextPageLink, options, callback) { +function _listByResourceGroupNext(nextPageLink, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -1508,13 +1475,12 @@ function _listNext(nextPageLink, options, callback) { try { parsedErrorResponse = JSON.parse(responseBody); if (parsedErrorResponse) { - let internalError = null; - if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; - error.code = internalError ? internalError.code : parsedErrorResponse.code; - error.message = internalError ? internalError.message : parsedErrorResponse.message; + if (parsedErrorResponse.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['DefaultErrorResponse']().mapper(); + let resultMapper = new client.models['CloudError']().mapper(); error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); } } catch (defaultError) { @@ -1534,7 +1500,7 @@ function _listNext(nextPageLink, options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['RecommendationCollection']().mapper(); + let resultMapper = new client.models['ApplicationInsightsComponentListResult']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -1549,313 +1515,37 @@ function _listNext(nextPageLink, options, callback) { }); } -/** - * @summary Get past recommendations for an app, optionally specified by the - * time range. - * - * Get past recommendations for an app, optionally specified by the time range. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link RecommendationCollection} for more - * information. - * - * {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 _listHistoryForWebAppNext(nextPageLink, options, callback) { - /* jshint validthis: true */ - let client = this.client; - if(!callback && typeof options === 'function') { - callback = options; - options = null; - } - if (!callback) { - throw new Error('callback cannot be null.'); - } - // Validate - try { - if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { - throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); - } - if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { - throw new Error('this.client.acceptLanguage must be of type string.'); - } - } catch (error) { - return callback(error); - } - - // Construct URL - let requestUrl = '{nextLink}'; - requestUrl = requestUrl.replace('{nextLink}', nextPageLink); - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'GET'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; - if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - } - if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { - httpRequest.headers['accept-language'] = this.client.acceptLanguage; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - httpRequest.body = null; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - let internalError = null; - if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; - error.code = internalError ? internalError.code : parsedErrorResponse.code; - error.message = internalError ? internalError.message : parsedErrorResponse.message; - } - if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['DefaultErrorResponse']().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['RecommendationCollection']().mapper(); - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); - return callback(deserializationError); - } - } - - return callback(null, result, httpRequest, response); - }); -} - -/** - * @summary Get all recommendations for an app. - * - * Get all recommendations for an app. - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link RecommendationCollection} for more - * information. - * - * {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 _listRecommendedRulesForWebAppNext(nextPageLink, options, callback) { - /* jshint validthis: true */ - let client = this.client; - if(!callback && typeof options === 'function') { - callback = options; - options = null; - } - if (!callback) { - throw new Error('callback cannot be null.'); - } - // Validate - try { - if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { - throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); - } - if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { - throw new Error('this.client.acceptLanguage must be of type string.'); - } - } catch (error) { - return callback(error); - } - - // Construct URL - let requestUrl = '{nextLink}'; - requestUrl = requestUrl.replace('{nextLink}', nextPageLink); - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'GET'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; - if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - } - if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { - httpRequest.headers['accept-language'] = this.client.acceptLanguage; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - httpRequest.body = null; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - let internalError = null; - if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; - error.code = internalError ? internalError.code : parsedErrorResponse.code; - error.message = internalError ? internalError.message : parsedErrorResponse.message; - } - if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['DefaultErrorResponse']().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['RecommendationCollection']().mapper(); - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); - return callback(deserializationError); - } - } - - return callback(null, result, httpRequest, response); - }); -} - -/** Class representing a Recommendations. */ -class Recommendations { +/** Class representing a Components. */ +class Components { /** - * Create a Recommendations. - * @param {WebSiteManagementClient} client Reference to the service client. + * Create a Components. + * @param {ApplicationInsightsManagementClient} client Reference to the service client. */ constructor(client) { this.client = client; this._list = _list; - this._resetAllFilters = _resetAllFilters; - this._disableRecommendationForSubscription = _disableRecommendationForSubscription; - this._listHistoryForWebApp = _listHistoryForWebApp; - this._listRecommendedRulesForWebApp = _listRecommendedRulesForWebApp; - this._disableAllForWebApp = _disableAllForWebApp; - this._resetAllFiltersForWebApp = _resetAllFiltersForWebApp; - this._getRuleDetailsByWebApp = _getRuleDetailsByWebApp; - this._disableRecommendationForSite = _disableRecommendationForSite; + this._listByResourceGroup = _listByResourceGroup; + this._deleteMethod = _deleteMethod; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + this._updateTags = _updateTags; + this._purge = _purge; + this._getPurgeStatus = _getPurgeStatus; this._listNext = _listNext; - this._listHistoryForWebAppNext = _listHistoryForWebAppNext; - this._listRecommendedRulesForWebAppNext = _listRecommendedRulesForWebAppNext; + this._listByResourceGroupNext = _listByResourceGroupNext; } /** - * @summary List all recommendations for a subscription. - * - * List all recommendations for a subscription. + * Gets a list of all Application Insights components within a subscription. * * @param {object} [options] Optional Parameters. * - * @param {boolean} [options.featured] Specify true to return only - * the most critical recommendations. The default is false, which - * returns all recommendations. - * - * @param {string} [options.filter] Filter is specified by using OData syntax. - * Example: $filter=channels eq 'Api' or channel eq 'Notification' and - * startTime eq '2014-01-01T00:00:00Z' and endTime eq '2014-12-31T23:59:59Z' - * and timeGrain eq duration'[PT1H|PT1M|P1D] - * * @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. */ @@ -1874,21 +1564,10 @@ class Recommendations { } /** - * @summary List all recommendations for a subscription. - * - * List all recommendations for a subscription. + * Gets a list of all Application Insights components within a subscription. * * @param {object} [options] Optional Parameters. * - * @param {boolean} [options.featured] Specify true to return only - * the most critical recommendations. The default is false, which - * returns all recommendations. - * - * @param {string} [options.filter] Filter is specified by using OData syntax. - * Example: $filter=channels eq 'Api' or channel eq 'Notification' and - * startTime eq '2014-01-01T00:00:00Z' and endTime eq '2014-12-31T23:59:59Z' - * and timeGrain eq duration'[PT1H|PT1M|P1D] - * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -1899,7 +1578,7 @@ class Recommendations { * * {Promise} A promise is returned * - * @resolve {RecommendationCollection} - The deserialized result object. + * @resolve {ApplicationInsightsComponentListResult} - The deserialized result object. * * @reject {Error} - The error object. * @@ -1908,8 +1587,8 @@ class Recommendations { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link RecommendationCollection} for more - * information. + * See {@link ApplicationInsightsComponentListResult} for + * more information. * * {object} [request] - The HTTP Request object if an error did not occur. * @@ -1936,9 +1615,9 @@ class Recommendations { } /** - * @summary Reset all recommendation opt-out settings for a subscription. + * Gets a list of Application Insights components within a resource group. * - * Reset all recommendation opt-out settings for a subscription. + * @param {string} resourceGroupName The name of the resource group. * * @param {object} [options] Optional Parameters. * @@ -1947,15 +1626,15 @@ class Recommendations { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ - resetAllFiltersWithHttpOperationResponse(options) { + listByResourceGroupWithHttpOperationResponse(resourceGroupName, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._resetAllFilters(options, (err, result, request, response) => { + self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -1966,9 +1645,9 @@ class Recommendations { } /** - * @summary Reset all recommendation opt-out settings for a subscription. + * Gets a list of Application Insights components within a resource group. * - * Reset all recommendation opt-out settings for a subscription. + * @param {string} resourceGroupName The name of the resource group. * * @param {object} [options] Optional Parameters. * @@ -1982,7 +1661,7 @@ class Recommendations { * * {Promise} A promise is returned * - * @resolve {null} - The deserialized result object. + * @resolve {ApplicationInsightsComponentListResult} - The deserialized result object. * * @reject {Error} - The error object. * @@ -1990,13 +1669,15 @@ class Recommendations { * * {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 ApplicationInsightsComponentListResult} for + * more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - resetAllFilters(options, optionalCallback) { + listByResourceGroup(resourceGroupName, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -2005,25 +1686,24 @@ class Recommendations { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._resetAllFilters(options, (err, result, request, response) => { + self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._resetAllFilters(options, optionalCallback); + return self._listByResourceGroup(resourceGroupName, options, optionalCallback); } } /** - * @summary Disables the specified rule so it will not apply to a subscription - * in the future. + * Deletes an Application Insights component. * - * Disables the specified rule so it will not apply to a subscription in the - * future. + * @param {string} resourceGroupName The name of the resource group. * - * @param {string} name Rule name + * @param {string} resourceName The name of the Application Insights component + * resource. * * @param {object} [options] Optional Parameters. * @@ -2036,11 +1716,11 @@ class Recommendations { * * @reject {Error} - The error object. */ - disableRecommendationForSubscriptionWithHttpOperationResponse(name, options) { + deleteMethodWithHttpOperationResponse(resourceGroupName, resourceName, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._disableRecommendationForSubscription(name, 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); } @@ -2051,13 +1731,12 @@ class Recommendations { } /** - * @summary Disables the specified rule so it will not apply to a subscription - * in the future. + * Deletes an Application Insights component. * - * Disables the specified rule so it will not apply to a subscription in the - * future. + * @param {string} resourceGroupName The name of the resource group. * - * @param {string} name Rule name + * @param {string} resourceName The name of the Application Insights component + * resource. * * @param {object} [options] Optional Parameters. * @@ -2085,7 +1764,7 @@ class Recommendations { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - disableRecommendationForSubscription(name, options, optionalCallback) { + deleteMethod(resourceGroupName, resourceName, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -2094,53 +1773,41 @@ class Recommendations { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._disableRecommendationForSubscription(name, 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._disableRecommendationForSubscription(name, options, optionalCallback); + return self._deleteMethod(resourceGroupName, resourceName, options, optionalCallback); } } /** - * @summary Get past recommendations for an app, optionally specified by the - * time range. - * - * Get past recommendations for an app, optionally specified by the time range. + * Returns an Application Insights component. * - * @param {string} resourceGroupName Name of the resource group to which the - * resource belongs. + * @param {string} resourceGroupName The name of the resource group. * - * @param {string} siteName Name of the app. + * @param {string} resourceName The name of the Application Insights component + * resource. * * @param {object} [options] Optional Parameters. * - * @param {boolean} [options.expiredOnly] Specify false to return - * all recommendations. The default is true, which returns only - * expired recommendations. - * - * @param {string} [options.filter] Filter is specified by using OData syntax. - * Example: $filter=channels eq 'Api' or channel eq 'Notification' and - * startTime eq '2014-01-01T00:00:00Z' and endTime eq '2014-12-31T23:59:59Z' - * and timeGrain eq duration'[PT1H|PT1M|P1D] - * * @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. */ - listHistoryForWebAppWithHttpOperationResponse(resourceGroupName, siteName, options) { + getWithHttpOperationResponse(resourceGroupName, resourceName, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._listHistoryForWebApp(resourceGroupName, siteName, 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); } @@ -2151,27 +1818,15 @@ class Recommendations { } /** - * @summary Get past recommendations for an app, optionally specified by the - * time range. + * Returns an Application Insights component. * - * Get past recommendations for an app, optionally specified by the time range. + * @param {string} resourceGroupName The name of the resource group. * - * @param {string} resourceGroupName Name of the resource group to which the - * resource belongs. - * - * @param {string} siteName Name of the app. + * @param {string} resourceName The name of the Application Insights component + * resource. * * @param {object} [options] Optional Parameters. * - * @param {boolean} [options.expiredOnly] Specify false to return - * all recommendations. The default is true, which returns only - * expired recommendations. - * - * @param {string} [options.filter] Filter is specified by using OData syntax. - * Example: $filter=channels eq 'Api' or channel eq 'Notification' and - * startTime eq '2014-01-01T00:00:00Z' and endTime eq '2014-12-31T23:59:59Z' - * and timeGrain eq duration'[PT1H|PT1M|P1D] - * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -2182,7 +1837,7 @@ class Recommendations { * * {Promise} A promise is returned * - * @resolve {RecommendationCollection} - The deserialized result object. + * @resolve {ApplicationInsightsComponent} - The deserialized result object. * * @reject {Error} - The error object. * @@ -2191,14 +1846,14 @@ class Recommendations { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link RecommendationCollection} for more + * See {@link ApplicationInsightsComponent} for more * information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - listHistoryForWebApp(resourceGroupName, siteName, options, optionalCallback) { + get(resourceGroupName, resourceName, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -2207,135 +1862,58 @@ class Recommendations { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._listHistoryForWebApp(resourceGroupName, siteName, 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._listHistoryForWebApp(resourceGroupName, siteName, options, optionalCallback); + return self._get(resourceGroupName, resourceName, options, optionalCallback); } } /** - * @summary Get all recommendations for an app. + * Creates (or updates) an Application Insights component. Note: You cannot + * specify a different value for InstrumentationKey nor AppId in the Put + * operation. * - * Get all recommendations for an app. + * @param {string} resourceGroupName The name of the resource group. * - * @param {string} resourceGroupName Name of the resource group to which the - * resource belongs. + * @param {string} resourceName The name of the Application Insights component + * resource. * - * @param {string} siteName Name of the app. + * @param {object} insightProperties Properties that need to be specified to + * create an Application Insights component. * - * @param {object} [options] Optional Parameters. + * @param {string} insightProperties.kind The kind of application that this + * component refers to, used to customize UI. This value is a freeform string, + * values should typically be one of the following: web, ios, other, store, + * java, phone. * - * @param {boolean} [options.featured] Specify true to return only - * the most critical recommendations. The default is false, which - * returns all recommendations. + * @param {string} insightProperties.applicationType Type of application being + * monitored. Possible values include: 'web', 'other' * - * @param {string} [options.filter] Return only channels specified in the - * filter. Filter is specified by using OData syntax. Example: $filter=channels - * eq 'Api' or channel eq 'Notification' + * @param {string} [insightProperties.flowType] Used by the Application + * Insights system to determine what kind of flow this component was created + * by. This is to be set to 'Bluefield' when creating/updating a component via + * the REST API. Possible values include: 'Bluefield' * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @param {string} [insightProperties.requestSource] Describes what tool + * created this Application Insights component. Customers using this API should + * set this to the default 'rest'. Possible values include: 'rest' * - * @reject {Error} - The error object. - */ - listRecommendedRulesForWebAppWithHttpOperationResponse(resourceGroupName, siteName, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._listRecommendedRulesForWebApp(resourceGroupName, siteName, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * @summary Get all recommendations for an app. - * - * Get all recommendations for an app. - * - * @param {string} resourceGroupName Name of the resource group to which the - * resource belongs. - * - * @param {string} siteName Name of the app. - * - * @param {object} [options] Optional Parameters. - * - * @param {boolean} [options.featured] Specify true to return only - * the most critical recommendations. The default is false, which - * returns all recommendations. - * - * @param {string} [options.filter] Return only channels specified in the - * filter. Filter is specified by using OData syntax. Example: $filter=channels - * eq 'Api' or channel eq 'Notification' - * - * @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 {RecommendationCollection} - 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 RecommendationCollection} for more - * information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - listRecommendedRulesForWebApp(resourceGroupName, siteName, 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._listRecommendedRulesForWebApp(resourceGroupName, siteName, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._listRecommendedRulesForWebApp(resourceGroupName, siteName, options, optionalCallback); - } - } - - /** - * @summary Disable all recommendations for an app. + * @param {string} [insightProperties.hockeyAppId] The unique application ID + * created when a new application is added to HockeyApp, used for + * communications with HockeyApp. * - * Disable all recommendations for an app. + * @param {number} [insightProperties.samplingPercentage] Percentage of the + * data produced by the application being monitored that is being sampled for + * Application Insights telemetry. * - * @param {string} resourceGroupName Name of the resource group to which the - * resource belongs. + * @param {string} insightProperties.location Resource location * - * @param {string} siteName Name of the app. + * @param {object} [insightProperties.tags] Resource tags * * @param {object} [options] Optional Parameters. * @@ -2344,15 +1922,15 @@ class Recommendations { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ - disableAllForWebAppWithHttpOperationResponse(resourceGroupName, siteName, options) { + createOrUpdateWithHttpOperationResponse(resourceGroupName, resourceName, insightProperties, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._disableAllForWebApp(resourceGroupName, siteName, options, (err, result, request, response) => { + self._createOrUpdate(resourceGroupName, resourceName, insightProperties, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -2363,105 +1941,46 @@ class Recommendations { } /** - * @summary Disable all recommendations for an app. - * - * Disable all recommendations for an app. + * Creates (or updates) an Application Insights component. Note: You cannot + * specify a different value for InstrumentationKey nor AppId in the Put + * operation. * - * @param {string} resourceGroupName Name of the resource group to which the - * resource belongs. - * - * @param {string} siteName Name of the app. - * - * @param {object} [options] Optional Parameters. + * @param {string} resourceGroupName The name of the resource group. * - * @param {object} [options.customHeaders] Headers that will be added to the - * request + * @param {string} resourceName The name of the Application Insights component + * resource. * - * @param {function} [optionalCallback] - The optional callback. + * @param {object} insightProperties Properties that need to be specified to + * create an Application Insights component. * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. + * @param {string} insightProperties.kind The kind of application that this + * component refers to, used to customize UI. This value is a freeform string, + * values should typically be one of the following: web, ios, other, store, + * java, phone. * - * {Promise} A promise is returned + * @param {string} insightProperties.applicationType Type of application being + * monitored. Possible values include: 'web', 'other' * - * @resolve {null} - The deserialized result object. + * @param {string} [insightProperties.flowType] Used by the Application + * Insights system to determine what kind of flow this component was created + * by. This is to be set to 'Bluefield' when creating/updating a component via + * the REST API. Possible values include: 'Bluefield' * - * @reject {Error} - The error object. + * @param {string} [insightProperties.requestSource] Describes what tool + * created this Application Insights component. Customers using this API should + * set this to the default 'rest'. Possible values include: 'rest' * - * {function} optionalCallback(err, result, request, response) + * @param {string} [insightProperties.hockeyAppId] The unique application ID + * created when a new application is added to HockeyApp, used for + * communications with HockeyApp. * - * {Error} err - The Error object if an error occurred, null otherwise. + * @param {number} [insightProperties.samplingPercentage] Percentage of the + * data produced by the application being monitored that is being sampled for + * Application Insights telemetry. * - * {null} [result] - The deserialized result object if an error did not occur. + * @param {string} insightProperties.location Resource location * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - disableAllForWebApp(resourceGroupName, siteName, 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._disableAllForWebApp(resourceGroupName, siteName, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._disableAllForWebApp(resourceGroupName, siteName, options, optionalCallback); - } - } - - /** - * @summary Reset all recommendation opt-out settings for an app. - * - * Reset all recommendation opt-out settings for an app. - * - * @param {string} resourceGroupName Name of the resource group to which the - * resource belongs. - * - * @param {string} siteName Name of the app. - * - * @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. - */ - resetAllFiltersForWebAppWithHttpOperationResponse(resourceGroupName, siteName, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._resetAllFiltersForWebApp(resourceGroupName, siteName, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * @summary Reset all recommendation opt-out settings for an app. - * - * Reset all recommendation opt-out settings for an app. - * - * @param {string} resourceGroupName Name of the resource group to which the - * resource belongs. - * - * @param {string} siteName Name of the app. + * @param {object} [insightProperties.tags] Resource tags * * @param {object} [options] Optional Parameters. * @@ -2475,7 +1994,7 @@ class Recommendations { * * {Promise} A promise is returned * - * @resolve {null} - The deserialized result object. + * @resolve {ApplicationInsightsComponent} - The deserialized result object. * * @reject {Error} - The error object. * @@ -2483,13 +2002,15 @@ class Recommendations { * * {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 ApplicationInsightsComponent} for more + * information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - resetAllFiltersForWebApp(resourceGroupName, siteName, options, optionalCallback) { + createOrUpdate(resourceGroupName, resourceName, insightProperties, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -2498,52 +2019,47 @@ class Recommendations { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._resetAllFiltersForWebApp(resourceGroupName, siteName, options, (err, result, request, response) => { + self._createOrUpdate(resourceGroupName, resourceName, insightProperties, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._resetAllFiltersForWebApp(resourceGroupName, siteName, options, optionalCallback); + return self._createOrUpdate(resourceGroupName, resourceName, insightProperties, options, optionalCallback); } } /** - * @summary Get a recommendation rule for an app. + * Updates an existing component's tags. To update other fields use the + * CreateOrUpdate method. * - * Get a recommendation rule for an app. + * @param {string} resourceGroupName The name of the resource group. * - * @param {string} resourceGroupName Name of the resource group to which the - * resource belongs. + * @param {string} resourceName The name of the Application Insights component + * resource. * - * @param {string} siteName Name of the app. + * @param {object} componentTags Updated tag information to set into the + * component instance. * - * @param {string} name Name of the recommendation. + * @param {object} [componentTags.tags] Resource tags * * @param {object} [options] Optional Parameters. * - * @param {boolean} [options.updateSeen] Specify true to update - * the last-seen timestamp of the recommendation object. - * - * @param {string} [options.recommendationId] The GUID of the recommedation - * object if you query an expired one. You don't need to specify it to query an - * active entry. - * * @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. */ - getRuleDetailsByWebAppWithHttpOperationResponse(resourceGroupName, siteName, name, options) { + updateTagsWithHttpOperationResponse(resourceGroupName, resourceName, componentTags, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._getRuleDetailsByWebApp(resourceGroupName, siteName, name, options, (err, result, request, response) => { + self._updateTags(resourceGroupName, resourceName, componentTags, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -2554,26 +2070,21 @@ class Recommendations { } /** - * @summary Get a recommendation rule for an app. + * Updates an existing component's tags. To update other fields use the + * CreateOrUpdate method. * - * Get a recommendation rule for an app. + * @param {string} resourceGroupName The name of the resource group. * - * @param {string} resourceGroupName Name of the resource group to which the - * resource belongs. + * @param {string} resourceName The name of the Application Insights component + * resource. * - * @param {string} siteName Name of the app. + * @param {object} componentTags Updated tag information to set into the + * component instance. * - * @param {string} name Name of the recommendation. + * @param {object} [componentTags.tags] Resource tags * * @param {object} [options] Optional Parameters. * - * @param {boolean} [options.updateSeen] Specify true to update - * the last-seen timestamp of the recommendation object. - * - * @param {string} [options.recommendationId] The GUID of the recommedation - * object if you query an expired one. You don't need to specify it to query an - * active entry. - * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -2584,7 +2095,7 @@ class Recommendations { * * {Promise} A promise is returned * - * @resolve {RecommendationRule} - The deserialized result object. + * @resolve {ApplicationInsightsComponent} - The deserialized result object. * * @reject {Error} - The error object. * @@ -2593,13 +2104,14 @@ class Recommendations { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link RecommendationRule} for more information. + * See {@link ApplicationInsightsComponent} for more + * information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - getRuleDetailsByWebApp(resourceGroupName, siteName, name, options, optionalCallback) { + updateTags(resourceGroupName, resourceName, componentTags, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -2608,28 +2120,33 @@ class Recommendations { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._getRuleDetailsByWebApp(resourceGroupName, siteName, name, options, (err, result, request, response) => { + self._updateTags(resourceGroupName, resourceName, componentTags, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._getRuleDetailsByWebApp(resourceGroupName, siteName, name, options, optionalCallback); + return self._updateTags(resourceGroupName, resourceName, componentTags, options, optionalCallback); } } /** - * @summary Disables the specific rule for a web site permanently. + * Purges data in an Application Insights component by a set of user-defined + * filters. + * + * @param {string} resourceGroupName The name of the resource group. * - * Disables the specific rule for a web site permanently. + * @param {string} resourceName The name of the Application Insights component + * resource. * - * @param {string} resourceGroupName Name of the resource group to which the - * resource belongs. + * @param {object} body Describes the body of a request to purge data in a + * single table of an Application Insights component * - * @param {string} siteName Site name + * @param {string} body.table Table from which to purge data. * - * @param {string} name Rule name + * @param {array} body.filters The set of columns and filters (queries) to run + * over them to purge the resulting data. * * @param {object} [options] Optional Parameters. * @@ -2638,15 +2155,15 @@ class Recommendations { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ - disableRecommendationForSiteWithHttpOperationResponse(resourceGroupName, siteName, name, options) { + purgeWithHttpOperationResponse(resourceGroupName, resourceName, body, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._disableRecommendationForSite(resourceGroupName, siteName, name, options, (err, result, request, response) => { + self._purge(resourceGroupName, resourceName, body, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -2657,16 +2174,21 @@ class Recommendations { } /** - * @summary Disables the specific rule for a web site permanently. + * Purges data in an Application Insights component by a set of user-defined + * filters. * - * Disables the specific rule for a web site permanently. + * @param {string} resourceGroupName The name of the resource group. * - * @param {string} resourceGroupName Name of the resource group to which the - * resource belongs. + * @param {string} resourceName The name of the Application Insights component + * resource. * - * @param {string} siteName Site name + * @param {object} body Describes the body of a request to purge data in a + * single table of an Application Insights component * - * @param {string} name Rule name + * @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 {object} [options] Optional Parameters. * @@ -2680,7 +2202,7 @@ class Recommendations { * * {Promise} A promise is returned * - * @resolve {null} - The deserialized result object. + * @resolve {ComponentPurgeResponse} - The deserialized result object. * * @reject {Error} - The error object. * @@ -2688,13 +2210,15 @@ class Recommendations { * * {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 ComponentPurgeResponse} for more + * information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - disableRecommendationForSite(resourceGroupName, siteName, name, options, optionalCallback) { + purge(resourceGroupName, resourceName, body, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -2703,24 +2227,28 @@ class Recommendations { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._disableRecommendationForSite(resourceGroupName, siteName, name, options, (err, result, request, response) => { + self._purge(resourceGroupName, resourceName, body, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._disableRecommendationForSite(resourceGroupName, siteName, name, options, optionalCallback); + return self._purge(resourceGroupName, resourceName, body, options, optionalCallback); } } /** - * @summary List all recommendations for a subscription. + * Gets the status of a previously submitted purge using the id returned from + * the original purge request. * - * List all recommendations for a subscription. + * @param {string} resourceGroupName The name of the resource group. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @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. * @@ -2729,15 +2257,15 @@ class Recommendations { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ - listNextWithHttpOperationResponse(nextPageLink, options) { + getPurgeStatusWithHttpOperationResponse(resourceGroupName, resourceName, purgeId, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._listNext(nextPageLink, 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); } @@ -2748,12 +2276,16 @@ class Recommendations { } /** - * @summary List all recommendations for a subscription. + * Gets the status of a previously submitted purge using the id returned from + * the original purge request. * - * List all recommendations for a subscription. + * @param {string} resourceGroupName The name of the resource group. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @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. * @@ -2767,7 +2299,7 @@ class Recommendations { * * {Promise} A promise is returned * - * @resolve {RecommendationCollection} - The deserialized result object. + * @resolve {ComponentPurgeStatusResponse} - The deserialized result object. * * @reject {Error} - The error object. * @@ -2776,14 +2308,14 @@ class Recommendations { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link RecommendationCollection} for more + * 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. */ - listNext(nextPageLink, options, optionalCallback) { + getPurgeStatus(resourceGroupName, resourceName, purgeId, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -2792,22 +2324,19 @@ class Recommendations { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._listNext(nextPageLink, 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._listNext(nextPageLink, options, optionalCallback); + return self._getPurgeStatus(resourceGroupName, resourceName, purgeId, options, optionalCallback); } } /** - * @summary Get past recommendations for an app, optionally specified by the - * time range. - * - * Get past recommendations for an app, optionally specified by the time range. + * Gets a list of all Application Insights components within a subscription. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -2819,15 +2348,15 @@ class Recommendations { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ - listHistoryForWebAppNextWithHttpOperationResponse(nextPageLink, options) { + listNextWithHttpOperationResponse(nextPageLink, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._listHistoryForWebAppNext(nextPageLink, options, (err, result, request, response) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -2838,10 +2367,7 @@ class Recommendations { } /** - * @summary Get past recommendations for an app, optionally specified by the - * time range. - * - * Get past recommendations for an app, optionally specified by the time range. + * Gets a list of all Application Insights components within a subscription. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -2858,7 +2384,7 @@ class Recommendations { * * {Promise} A promise is returned * - * @resolve {RecommendationCollection} - The deserialized result object. + * @resolve {ApplicationInsightsComponentListResult} - The deserialized result object. * * @reject {Error} - The error object. * @@ -2867,14 +2393,14 @@ class Recommendations { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link RecommendationCollection} for more - * information. + * See {@link ApplicationInsightsComponentListResult} for + * more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - listHistoryForWebAppNext(nextPageLink, options, optionalCallback) { + listNext(nextPageLink, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -2883,21 +2409,19 @@ class Recommendations { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._listHistoryForWebAppNext(nextPageLink, options, (err, result, request, response) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._listHistoryForWebAppNext(nextPageLink, options, optionalCallback); + return self._listNext(nextPageLink, options, optionalCallback); } } /** - * @summary Get all recommendations for an app. - * - * Get all recommendations for an app. + * Gets a list of Application Insights components within a resource group. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -2909,15 +2433,15 @@ class Recommendations { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ - listRecommendedRulesForWebAppNextWithHttpOperationResponse(nextPageLink, options) { + listByResourceGroupNextWithHttpOperationResponse(nextPageLink, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._listRecommendedRulesForWebAppNext(nextPageLink, options, (err, result, request, response) => { + self._listByResourceGroupNext(nextPageLink, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -2928,9 +2452,7 @@ class Recommendations { } /** - * @summary Get all recommendations for an app. - * - * Get all recommendations for an app. + * Gets a list of Application Insights components within a resource group. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -2947,7 +2469,7 @@ class Recommendations { * * {Promise} A promise is returned * - * @resolve {RecommendationCollection} - The deserialized result object. + * @resolve {ApplicationInsightsComponentListResult} - The deserialized result object. * * @reject {Error} - The error object. * @@ -2956,14 +2478,14 @@ class Recommendations { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link RecommendationCollection} for more - * information. + * See {@link ApplicationInsightsComponentListResult} for + * more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - listRecommendedRulesForWebAppNext(nextPageLink, options, optionalCallback) { + listByResourceGroupNext(nextPageLink, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -2972,17 +2494,17 @@ class Recommendations { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._listRecommendedRulesForWebAppNext(nextPageLink, options, (err, result, request, response) => { + self._listByResourceGroupNext(nextPageLink, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._listRecommendedRulesForWebAppNext(nextPageLink, options, optionalCallback); + return self._listByResourceGroupNext(nextPageLink, options, optionalCallback); } } } -module.exports = Recommendations; +module.exports = Components; diff --git a/lib/services/applicationinsights/lib/lib/operations/exportConfigurations.js b/lib/services/applicationinsights/lib/lib/operations/exportConfigurations.js new file mode 100644 index 0000000000..a37dc460ef --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/operations/exportConfigurations.js @@ -0,0 +1,1505 @@ +/* + * 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 Continuous Export configuration of 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 {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, 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 (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}/exportconfiguration'; + 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('&'); + } + + // 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: 'ApplicationInsightsComponentExportConfigurationElementType', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentExportConfiguration' + } + } + } + }; + 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 Continuous Export configuration of 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} exportProperties Properties that need to be specified to + * create a Continuous Export configuration of a Application Insights + * component. + * + * @param {string} [exportProperties.recordTypes] The document types to be + * exported, as comma separated values. Allowed values include 'Requests', + * 'Event', 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', + * 'PerformanceCounters', 'Availability', 'Messages'. + * + * @param {string} [exportProperties.destinationType] The Continuous Export + * destination type. This has to be 'Blob'. + * + * @param {string} [exportProperties.destinationAddress] The SAS URL for the + * destination storage container. It must grant write permission. + * + * @param {string} [exportProperties.isEnabled] Set to 'true' to create a + * Continuous Export configuration as enabled, otherwise set it to 'false'. + * + * @param {string} [exportProperties.notificationQueueEnabled] Deprecated + * + * @param {string} [exportProperties.notificationQueueUri] Deprecated + * + * @param {string} [exportProperties.destinationStorageSubscriptionId] The + * subscription ID of the destination storage container. + * + * @param {string} [exportProperties.destinationStorageLocationId] The location + * ID of the destination storage container. + * + * @param {string} [exportProperties.destinationAccountId] The name of + * destination storage account. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {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 _create(resourceGroupName, resourceName, exportProperties, 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 (exportProperties === null || exportProperties === undefined) { + throw new Error('exportProperties 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}/exportconfiguration'; + 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('&'); + } + + // 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 (exportProperties !== null && exportProperties !== undefined) { + let requestModelMapper = new client.models['ApplicationInsightsComponentExportRequest']().mapper(); + requestModel = client.serialize(requestModelMapper, exportProperties, 'exportProperties'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(exportProperties, 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 = { + required: false, + serializedName: 'parsedResponse', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ApplicationInsightsComponentExportConfigurationElementType', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentExportConfiguration' + } + } + } + }; + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Delete a Continuous Export configuration of 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} exportId The Continuous Export configuration ID. This is + * unique within a 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 + * ApplicationInsightsComponentExportConfiguration} for + * more information. + * + * {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, exportId, 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 (exportId === null || exportId === undefined || typeof exportId.valueOf() !== 'string') { + throw new Error('exportId 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}/exportconfiguration/{exportId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); + requestUrl = requestUrl.replace('{exportId}', encodeURIComponent(exportId)); + 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; + // 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['ApplicationInsightsComponentExportConfiguration']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Get the Continuous Export configuration for this export id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} exportId The Continuous Export configuration ID. This is + * unique within a 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 + * ApplicationInsightsComponentExportConfiguration} for + * more information. + * + * {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, exportId, 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 (exportId === null || exportId === undefined || typeof exportId.valueOf() !== 'string') { + throw new Error('exportId 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}/exportconfiguration/{exportId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); + requestUrl = requestUrl.replace('{exportId}', encodeURIComponent(exportId)); + 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['ApplicationInsightsComponentExportConfiguration']().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); + }); +} + +/** + * Update the Continuous Export configuration for this export id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} exportId The Continuous Export configuration ID. This is + * unique within a Application Insights component. + * + * @param {object} exportProperties Properties that need to be specified to + * update the Continuous Export configuration. + * + * @param {string} [exportProperties.recordTypes] The document types to be + * exported, as comma separated values. Allowed values include 'Requests', + * 'Event', 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', + * 'PerformanceCounters', 'Availability', 'Messages'. + * + * @param {string} [exportProperties.destinationType] The Continuous Export + * destination type. This has to be 'Blob'. + * + * @param {string} [exportProperties.destinationAddress] The SAS URL for the + * destination storage container. It must grant write permission. + * + * @param {string} [exportProperties.isEnabled] Set to 'true' to create a + * Continuous Export configuration as enabled, otherwise set it to 'false'. + * + * @param {string} [exportProperties.notificationQueueEnabled] Deprecated + * + * @param {string} [exportProperties.notificationQueueUri] Deprecated + * + * @param {string} [exportProperties.destinationStorageSubscriptionId] The + * subscription ID of the destination storage container. + * + * @param {string} [exportProperties.destinationStorageLocationId] The location + * ID of the destination storage container. + * + * @param {string} [exportProperties.destinationAccountId] The name of + * destination storage account. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link + * ApplicationInsightsComponentExportConfiguration} for + * more information. + * + * {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, exportId, exportProperties, 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 (exportId === null || exportId === undefined || typeof exportId.valueOf() !== 'string') { + throw new Error('exportId cannot be null or undefined and it must be of type string.'); + } + if (exportProperties === null || exportProperties === undefined) { + throw new Error('exportProperties 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}/exportconfiguration/{exportId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); + requestUrl = requestUrl.replace('{exportId}', encodeURIComponent(exportId)); + 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 (exportProperties !== null && exportProperties !== undefined) { + let requestModelMapper = new client.models['ApplicationInsightsComponentExportRequest']().mapper(); + requestModel = client.serialize(requestModelMapper, exportProperties, 'exportProperties'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(exportProperties, 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['ApplicationInsightsComponentExportConfiguration']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a ExportConfigurations. */ +class ExportConfigurations { + /** + * Create a ExportConfigurations. + * @param {ApplicationInsightsManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._create = _create; + this._deleteMethod = _deleteMethod; + this._get = _get; + this._update = _update; + } + + /** + * Gets a list of Continuous Export configuration of 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 {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 Continuous Export configuration of 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 {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); + } + } + + /** + * Create a Continuous Export configuration of 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} exportProperties Properties that need to be specified to + * create a Continuous Export configuration of a Application Insights + * component. + * + * @param {string} [exportProperties.recordTypes] The document types to be + * exported, as comma separated values. Allowed values include 'Requests', + * 'Event', 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', + * 'PerformanceCounters', 'Availability', 'Messages'. + * + * @param {string} [exportProperties.destinationType] The Continuous Export + * destination type. This has to be 'Blob'. + * + * @param {string} [exportProperties.destinationAddress] The SAS URL for the + * destination storage container. It must grant write permission. + * + * @param {string} [exportProperties.isEnabled] Set to 'true' to create a + * Continuous Export configuration as enabled, otherwise set it to 'false'. + * + * @param {string} [exportProperties.notificationQueueEnabled] Deprecated + * + * @param {string} [exportProperties.notificationQueueUri] Deprecated + * + * @param {string} [exportProperties.destinationStorageSubscriptionId] The + * subscription ID of the destination storage container. + * + * @param {string} [exportProperties.destinationStorageLocationId] The location + * ID of the destination storage container. + * + * @param {string} [exportProperties.destinationAccountId] The name of + * destination storage account. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createWithHttpOperationResponse(resourceGroupName, resourceName, exportProperties, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._create(resourceGroupName, resourceName, exportProperties, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Create a Continuous Export configuration of 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} exportProperties Properties that need to be specified to + * create a Continuous Export configuration of a Application Insights + * component. + * + * @param {string} [exportProperties.recordTypes] The document types to be + * exported, as comma separated values. Allowed values include 'Requests', + * 'Event', 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', + * 'PerformanceCounters', 'Availability', 'Messages'. + * + * @param {string} [exportProperties.destinationType] The Continuous Export + * destination type. This has to be 'Blob'. + * + * @param {string} [exportProperties.destinationAddress] The SAS URL for the + * destination storage container. It must grant write permission. + * + * @param {string} [exportProperties.isEnabled] Set to 'true' to create a + * Continuous Export configuration as enabled, otherwise set it to 'false'. + * + * @param {string} [exportProperties.notificationQueueEnabled] Deprecated + * + * @param {string} [exportProperties.notificationQueueUri] Deprecated + * + * @param {string} [exportProperties.destinationStorageSubscriptionId] The + * subscription ID of the destination storage container. + * + * @param {string} [exportProperties.destinationStorageLocationId] The location + * ID of the destination storage container. + * + * @param {string} [exportProperties.destinationAccountId] The name of + * destination storage account. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {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. + */ + create(resourceGroupName, resourceName, exportProperties, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._create(resourceGroupName, resourceName, exportProperties, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._create(resourceGroupName, resourceName, exportProperties, options, optionalCallback); + } + } + + /** + * Delete a Continuous Export configuration of 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} exportId The Continuous Export configuration ID. This is + * unique within a 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, exportId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, resourceName, exportId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Delete a Continuous Export configuration of 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} exportId The Continuous Export configuration ID. This is + * unique within a 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 {ApplicationInsightsComponentExportConfiguration} - 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 + * ApplicationInsightsComponentExportConfiguration} for + * more information. + * + * {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, exportId, 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, exportId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, resourceName, exportId, options, optionalCallback); + } + } + + /** + * Get the Continuous Export configuration for this export id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} exportId The Continuous Export configuration ID. This is + * unique within a 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, exportId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, resourceName, exportId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get the Continuous Export configuration for this export id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} exportId The Continuous Export configuration ID. This is + * unique within a 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 {ApplicationInsightsComponentExportConfiguration} - 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 + * ApplicationInsightsComponentExportConfiguration} for + * more information. + * + * {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, exportId, 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, exportId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, resourceName, exportId, options, optionalCallback); + } + } + + /** + * Update the Continuous Export configuration for this export id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} exportId The Continuous Export configuration ID. This is + * unique within a Application Insights component. + * + * @param {object} exportProperties Properties that need to be specified to + * update the Continuous Export configuration. + * + * @param {string} [exportProperties.recordTypes] The document types to be + * exported, as comma separated values. Allowed values include 'Requests', + * 'Event', 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', + * 'PerformanceCounters', 'Availability', 'Messages'. + * + * @param {string} [exportProperties.destinationType] The Continuous Export + * destination type. This has to be 'Blob'. + * + * @param {string} [exportProperties.destinationAddress] The SAS URL for the + * destination storage container. It must grant write permission. + * + * @param {string} [exportProperties.isEnabled] Set to 'true' to create a + * Continuous Export configuration as enabled, otherwise set it to 'false'. + * + * @param {string} [exportProperties.notificationQueueEnabled] Deprecated + * + * @param {string} [exportProperties.notificationQueueUri] Deprecated + * + * @param {string} [exportProperties.destinationStorageSubscriptionId] The + * subscription ID of the destination storage container. + * + * @param {string} [exportProperties.destinationStorageLocationId] The location + * ID of the destination storage container. + * + * @param {string} [exportProperties.destinationAccountId] The name of + * destination storage account. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName, resourceName, exportId, exportProperties, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(resourceGroupName, resourceName, exportId, exportProperties, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Update the Continuous Export configuration for this export id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} exportId The Continuous Export configuration ID. This is + * unique within a Application Insights component. + * + * @param {object} exportProperties Properties that need to be specified to + * update the Continuous Export configuration. + * + * @param {string} [exportProperties.recordTypes] The document types to be + * exported, as comma separated values. Allowed values include 'Requests', + * 'Event', 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', + * 'PerformanceCounters', 'Availability', 'Messages'. + * + * @param {string} [exportProperties.destinationType] The Continuous Export + * destination type. This has to be 'Blob'. + * + * @param {string} [exportProperties.destinationAddress] The SAS URL for the + * destination storage container. It must grant write permission. + * + * @param {string} [exportProperties.isEnabled] Set to 'true' to create a + * Continuous Export configuration as enabled, otherwise set it to 'false'. + * + * @param {string} [exportProperties.notificationQueueEnabled] Deprecated + * + * @param {string} [exportProperties.notificationQueueUri] Deprecated + * + * @param {string} [exportProperties.destinationStorageSubscriptionId] The + * subscription ID of the destination storage container. + * + * @param {string} [exportProperties.destinationStorageLocationId] The location + * ID of the destination storage container. + * + * @param {string} [exportProperties.destinationAccountId] The name of + * destination storage account. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ApplicationInsightsComponentExportConfiguration} - 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 + * ApplicationInsightsComponentExportConfiguration} for + * more information. + * + * {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, exportId, exportProperties, 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, exportId, exportProperties, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(resourceGroupName, resourceName, exportId, exportProperties, options, optionalCallback); + } + } + +} + +module.exports = ExportConfigurations; diff --git a/lib/services/applicationinsights/lib/lib/operations/favorite.js b/lib/services/applicationinsights/lib/lib/operations/favorite.js new file mode 100644 index 0000000000..d5e8163654 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/operations/favorite.js @@ -0,0 +1,1234 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Get a single 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 Favorite. */ +class Favorite { + /** + * Create a Favorite. + * @param {ApplicationInsightsManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._add = _add; + this._update = _update; + this._deleteMethod = _deleteMethod; + } + + /** + * 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. + */ + 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; + }); + }); + } + + /** + * 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} [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. + */ + 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. + * + * @reject {Error} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName, resourceName, favoriteId, favoriteProperties, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + 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); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * 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} [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. + */ + 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 + * + * @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, 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._deleteMethod(resourceGroupName, resourceName, favoriteId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, resourceName, favoriteId, options, optionalCallback); + } + } + +} + +module.exports = Favorite; diff --git a/lib/services/applicationinsights/lib/lib/operations/favorites.js b/lib/services/applicationinsights/lib/lib/operations/favorites.js new file mode 100644 index 0000000000..b72dd84a07 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/operations/favorites.js @@ -0,0 +1,356 @@ +/* + * 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 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} 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, 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 favoriteType = (options && options.favoriteType !== undefined) ? options.favoriteType : 'shared'; + let sourceType = (options && options.sourceType !== undefined) ? options.sourceType : undefined; + let canFetchContent = (options && options.canFetchContent !== undefined) ? options.canFetchContent : undefined; + let tags = (options && options.tags !== undefined) ? options.tags : undefined; + // 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 (favoriteType) { + let allowedValues = [ 'shared', 'user' ]; + if (!allowedValues.some( function(item) { return item === favoriteType; })) { + throw new Error(favoriteType + ' is not a valid value. The valid values are: ' + allowedValues); + } + } + if (sourceType !== null && sourceType !== undefined && typeof sourceType.valueOf() !== 'string') { + throw new Error('sourceType must be of type string.'); + } + if (canFetchContent !== null && canFetchContent !== undefined && typeof canFetchContent !== 'boolean') { + throw new Error('canFetchContent must be of type boolean.'); + } + if (Array.isArray(tags)) { + for (let i = 0; i < tags.length; i++) { + if (tags[i] !== null && tags[i] !== undefined && typeof tags[i].valueOf() !== 'string') { + throw new Error('tags[i] 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'; + 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 (favoriteType !== null && favoriteType !== undefined) { + queryParameters.push('favoriteType=' + encodeURIComponent(favoriteType)); + } + if (sourceType !== null && sourceType !== undefined) { + queryParameters.push('sourceType=' + encodeURIComponent(sourceType)); + } + if (canFetchContent !== null && canFetchContent !== undefined) { + queryParameters.push('canFetchContent=' + encodeURIComponent(canFetchContent.toString())); + } + if (tags !== null && tags !== undefined) { + queryParameters.push('tags=' + encodeURIComponent(tags.join(','))); + } + 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: 'ApplicationInsightsComponentFavoriteElementType', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentFavorite' + } + } + } + }; + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a Favorites. */ +class Favorites { + /** + * Create a Favorites. + * @param {ApplicationInsightsManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + } + + /** + * 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); + } + } + +} + +module.exports = Favorites; diff --git a/lib/services/applicationinsights/lib/lib/operations/index.d.ts b/lib/services/applicationinsights/lib/lib/operations/index.d.ts new file mode 100644 index 0000000000..29d0386ff3 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/operations/index.d.ts @@ -0,0 +1,4638 @@ +/* + * 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. +*/ + +import { ServiceClientOptions, RequestOptions, ServiceCallback, HttpOperationResponse } from 'ms-rest'; +import * as models from '../models'; + + +/** + * @class + * Operations + * __NOTE__: An instance of this class is automatically created for an + * instance of the ApplicationInsightsManagementClient. + */ +export interface Operations { + + + /** + * Lists all of the available insights REST API operations. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all of the available insights REST API operations. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {OperationListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {OperationListResult} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all of the available insights REST API operations. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all of the available insights REST API operations. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {OperationListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {OperationListResult} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextPageLink: string, callback: ServiceCallback): void; + listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * Annotations + * __NOTE__: An instance of this class is automatically created for an + * instance of the ApplicationInsightsManagementClient. + */ +export interface Annotations { + + + /** + * Gets the list of annotations for a component for given time range + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} start The start time to query from for annotations, cannot + * be older than 90 days from current date. + * + * @param {string} end The end time to query for annotations. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(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 + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} start The start time to query from for annotations, cannot + * be older than 90 days from current date. + * + * @param {string} end The end time to query for annotations. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Array} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(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; + + + /** + * Create an Annotation of 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} annotationProperties Properties that need to be specified to + * create an annotation of a Application Insights component. + * + * @param {string} [annotationProperties.annotationName] Name of annotation + * + * @param {string} [annotationProperties.category] Category of annotation, free + * form + * + * @param {date} [annotationProperties.eventTime] Time when event occurred + * + * @param {string} [annotationProperties.id] Unique Id for annotation + * + * @param {string} [annotationProperties.properties] Serialized JSON object for + * detailed properties + * + * @param {string} [annotationProperties.relatedAnnotation] Related parent + * annotation if any + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createWithHttpOperationResponse(resourceGroupName: string, resourceName: string, annotationProperties: models.Annotation, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Create an Annotation of 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} annotationProperties Properties that need to be specified to + * create an annotation of a Application Insights component. + * + * @param {string} [annotationProperties.annotationName] Name of annotation + * + * @param {string} [annotationProperties.category] Category of annotation, free + * form + * + * @param {date} [annotationProperties.eventTime] Time when event occurred + * + * @param {string} [annotationProperties.id] Unique Id for annotation + * + * @param {string} [annotationProperties.properties] Serialized JSON object for + * detailed properties + * + * @param {string} [annotationProperties.relatedAnnotation] Related parent + * annotation if any + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Array} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + create(resourceGroupName: string, resourceName: string, annotationProperties: models.Annotation, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + create(resourceGroupName: string, resourceName: string, annotationProperties: models.Annotation, callback: ServiceCallback): void; + create(resourceGroupName: string, resourceName: string, annotationProperties: models.Annotation, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Delete an Annotation of 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} annotationId The unique annotation ID. This is unique within + * a 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|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, resourceName: string, annotationId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Delete an Annotation of 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} annotationId The unique annotation ID. This is unique within + * a Application Insights component. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Object} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Object} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName: string, resourceName: string, annotationId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, resourceName: string, annotationId: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, resourceName: string, annotationId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get the annotation for given id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} annotationId The unique annotation ID. This is unique within + * a 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|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, resourceName: string, annotationId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the annotation for given id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} annotationId The unique annotation ID. This is unique within + * a Application Insights component. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Array} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, resourceName: string, annotationId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, resourceName: string, annotationId: string, callback: ServiceCallback): void; + get(resourceGroupName: string, resourceName: string, annotationId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * APIKeys + * __NOTE__: An instance of this class is automatically created for an + * instance of the ApplicationInsightsManagementClient. + */ +export interface APIKeys { + + + /** + * Gets a list of API keys of 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(resourceGroupName: string, resourceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a list of API keys of 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponentAPIKeyListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponentAPIKeyListResult} [result] - The deserialized result object if an error did not occur. + * See {@link + * ApplicationInsightsComponentAPIKeyListResult} 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; + + + /** + * Create an API Key of 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} aPIKeyProperties Properties that need to be specified to + * create an API key of a Application Insights component. + * + * @param {string} [aPIKeyProperties.name] The name of the API Key. + * + * @param {array} [aPIKeyProperties.linkedReadProperties] The read access + * rights of this API Key. + * + * @param {array} [aPIKeyProperties.linkedWriteProperties] The write access + * rights of this API Key. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createWithHttpOperationResponse(resourceGroupName: string, resourceName: string, aPIKeyProperties: models.APIKeyRequest, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Create an API Key of 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} aPIKeyProperties Properties that need to be specified to + * create an API key of a Application Insights component. + * + * @param {string} [aPIKeyProperties.name] The name of the API Key. + * + * @param {array} [aPIKeyProperties.linkedReadProperties] The read access + * rights of this API Key. + * + * @param {array} [aPIKeyProperties.linkedWriteProperties] The write access + * rights of this API Key. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponentAPIKey} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponentAPIKey} [result] - The deserialized result object if an error did not occur. + * See {@link ApplicationInsightsComponentAPIKey} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + create(resourceGroupName: string, resourceName: string, aPIKeyProperties: models.APIKeyRequest, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + create(resourceGroupName: string, resourceName: string, aPIKeyProperties: models.APIKeyRequest, callback: ServiceCallback): void; + create(resourceGroupName: string, resourceName: string, aPIKeyProperties: models.APIKeyRequest, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Delete an API Key of 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} keyId The API Key ID. This is unique within a 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|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, resourceName: string, keyId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Delete an API Key of 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} keyId The API Key ID. This is unique within a Application + * Insights component. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponentAPIKey} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponentAPIKey} [result] - The deserialized result object if an error did not occur. + * See {@link ApplicationInsightsComponentAPIKey} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName: string, resourceName: string, keyId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, resourceName: string, keyId: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, resourceName: string, keyId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get the API Key for this key id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} keyId The API Key ID. This is unique within a 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|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, resourceName: string, keyId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the API Key for this key id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} keyId The API Key ID. This is unique within a Application + * Insights component. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponentAPIKey} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponentAPIKey} [result] - The deserialized result object if an error did not occur. + * See {@link ApplicationInsightsComponentAPIKey} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, resourceName: string, keyId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, resourceName: string, keyId: string, callback: ServiceCallback): void; + get(resourceGroupName: string, resourceName: string, keyId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ExportConfigurations + * __NOTE__: An instance of this class is automatically created for an + * instance of the ApplicationInsightsManagementClient. + */ +export interface ExportConfigurations { + + + /** + * Gets a list of Continuous Export configuration of 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(resourceGroupName: string, resourceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a list of Continuous Export configuration of 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Array} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(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; + + + /** + * Create a Continuous Export configuration of 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} exportProperties Properties that need to be specified to + * create a Continuous Export configuration of a Application Insights + * component. + * + * @param {string} [exportProperties.recordTypes] The document types to be + * exported, as comma separated values. Allowed values include 'Requests', + * 'Event', 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', + * 'PerformanceCounters', 'Availability', 'Messages'. + * + * @param {string} [exportProperties.destinationType] The Continuous Export + * destination type. This has to be 'Blob'. + * + * @param {string} [exportProperties.destinationAddress] The SAS URL for the + * destination storage container. It must grant write permission. + * + * @param {string} [exportProperties.isEnabled] Set to 'true' to create a + * Continuous Export configuration as enabled, otherwise set it to 'false'. + * + * @param {string} [exportProperties.notificationQueueEnabled] Deprecated + * + * @param {string} [exportProperties.notificationQueueUri] Deprecated + * + * @param {string} [exportProperties.destinationStorageSubscriptionId] The + * subscription ID of the destination storage container. + * + * @param {string} [exportProperties.destinationStorageLocationId] The location + * ID of the destination storage container. + * + * @param {string} [exportProperties.destinationAccountId] The name of + * destination storage account. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createWithHttpOperationResponse(resourceGroupName: string, resourceName: string, exportProperties: models.ApplicationInsightsComponentExportRequest, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Create a Continuous Export configuration of 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} exportProperties Properties that need to be specified to + * create a Continuous Export configuration of a Application Insights + * component. + * + * @param {string} [exportProperties.recordTypes] The document types to be + * exported, as comma separated values. Allowed values include 'Requests', + * 'Event', 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', + * 'PerformanceCounters', 'Availability', 'Messages'. + * + * @param {string} [exportProperties.destinationType] The Continuous Export + * destination type. This has to be 'Blob'. + * + * @param {string} [exportProperties.destinationAddress] The SAS URL for the + * destination storage container. It must grant write permission. + * + * @param {string} [exportProperties.isEnabled] Set to 'true' to create a + * Continuous Export configuration as enabled, otherwise set it to 'false'. + * + * @param {string} [exportProperties.notificationQueueEnabled] Deprecated + * + * @param {string} [exportProperties.notificationQueueUri] Deprecated + * + * @param {string} [exportProperties.destinationStorageSubscriptionId] The + * subscription ID of the destination storage container. + * + * @param {string} [exportProperties.destinationStorageLocationId] The location + * ID of the destination storage container. + * + * @param {string} [exportProperties.destinationAccountId] The name of + * destination storage account. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Array} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + create(resourceGroupName: string, resourceName: string, exportProperties: models.ApplicationInsightsComponentExportRequest, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + create(resourceGroupName: string, resourceName: string, exportProperties: models.ApplicationInsightsComponentExportRequest, callback: ServiceCallback): void; + create(resourceGroupName: string, resourceName: string, exportProperties: models.ApplicationInsightsComponentExportRequest, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Delete a Continuous Export configuration of 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} exportId The Continuous Export configuration ID. This is + * unique within a 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|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, resourceName: string, exportId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Delete a Continuous Export configuration of 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} exportId The Continuous Export configuration ID. This is + * unique within a Application Insights component. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponentExportConfiguration} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponentExportConfiguration} [result] - The deserialized result object if an error did not occur. + * See {@link + * ApplicationInsightsComponentExportConfiguration} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName: string, resourceName: string, exportId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, resourceName: string, exportId: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, resourceName: string, exportId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get the Continuous Export configuration for this export id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} exportId The Continuous Export configuration ID. This is + * unique within a 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|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, resourceName: string, exportId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the Continuous Export configuration for this export id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} exportId The Continuous Export configuration ID. This is + * unique within a Application Insights component. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponentExportConfiguration} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponentExportConfiguration} [result] - The deserialized result object if an error did not occur. + * See {@link + * ApplicationInsightsComponentExportConfiguration} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, resourceName: string, exportId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, resourceName: string, exportId: string, callback: ServiceCallback): void; + get(resourceGroupName: string, resourceName: string, exportId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Update the Continuous Export configuration for this export id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} exportId The Continuous Export configuration ID. This is + * unique within a Application Insights component. + * + * @param {object} exportProperties Properties that need to be specified to + * update the Continuous Export configuration. + * + * @param {string} [exportProperties.recordTypes] The document types to be + * exported, as comma separated values. Allowed values include 'Requests', + * 'Event', 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', + * 'PerformanceCounters', 'Availability', 'Messages'. + * + * @param {string} [exportProperties.destinationType] The Continuous Export + * destination type. This has to be 'Blob'. + * + * @param {string} [exportProperties.destinationAddress] The SAS URL for the + * destination storage container. It must grant write permission. + * + * @param {string} [exportProperties.isEnabled] Set to 'true' to create a + * Continuous Export configuration as enabled, otherwise set it to 'false'. + * + * @param {string} [exportProperties.notificationQueueEnabled] Deprecated + * + * @param {string} [exportProperties.notificationQueueUri] Deprecated + * + * @param {string} [exportProperties.destinationStorageSubscriptionId] The + * subscription ID of the destination storage container. + * + * @param {string} [exportProperties.destinationStorageLocationId] The location + * ID of the destination storage container. + * + * @param {string} [exportProperties.destinationAccountId] The name of + * destination storage account. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName: string, resourceName: string, exportId: string, exportProperties: models.ApplicationInsightsComponentExportRequest, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Update the Continuous Export configuration for this export id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} exportId The Continuous Export configuration ID. This is + * unique within a Application Insights component. + * + * @param {object} exportProperties Properties that need to be specified to + * update the Continuous Export configuration. + * + * @param {string} [exportProperties.recordTypes] The document types to be + * exported, as comma separated values. Allowed values include 'Requests', + * 'Event', 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', + * 'PerformanceCounters', 'Availability', 'Messages'. + * + * @param {string} [exportProperties.destinationType] The Continuous Export + * destination type. This has to be 'Blob'. + * + * @param {string} [exportProperties.destinationAddress] The SAS URL for the + * destination storage container. It must grant write permission. + * + * @param {string} [exportProperties.isEnabled] Set to 'true' to create a + * Continuous Export configuration as enabled, otherwise set it to 'false'. + * + * @param {string} [exportProperties.notificationQueueEnabled] Deprecated + * + * @param {string} [exportProperties.notificationQueueUri] Deprecated + * + * @param {string} [exportProperties.destinationStorageSubscriptionId] The + * subscription ID of the destination storage container. + * + * @param {string} [exportProperties.destinationStorageLocationId] The location + * ID of the destination storage container. + * + * @param {string} [exportProperties.destinationAccountId] The name of + * destination storage account. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponentExportConfiguration} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponentExportConfiguration} [result] - The deserialized result object if an error did not occur. + * See {@link + * ApplicationInsightsComponentExportConfiguration} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + update(resourceGroupName: string, resourceName: string, exportId: string, exportProperties: models.ApplicationInsightsComponentExportRequest, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, resourceName: string, exportId: string, exportProperties: models.ApplicationInsightsComponentExportRequest, callback: ServiceCallback): void; + update(resourceGroupName: string, resourceName: string, exportId: string, exportProperties: models.ApplicationInsightsComponentExportRequest, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ComponentCurrentBillingFeatures + * __NOTE__: An instance of this class is automatically created for an + * instance of the ApplicationInsightsManagementClient. + */ +export interface ComponentCurrentBillingFeatures { + + + /** + * Returns current billing features for 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, resourceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Returns current billing features for 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponentBillingFeatures} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponentBillingFeatures} [result] - The deserialized result object if an error did not occur. + * See {@link ApplicationInsightsComponentBillingFeatures} + * for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, resourceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, resourceName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, resourceName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Update current billing features for 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} billingFeaturesProperties Properties that need to be + * specified to update billing features for an Application Insights component. + * + * @param {object} [billingFeaturesProperties.dataVolumeCap] An Application + * Insights component daily data volumne cap + * + * @param {number} [billingFeaturesProperties.dataVolumeCap.cap] Daily data + * volume cap in GB. + * + * @param {number} [billingFeaturesProperties.dataVolumeCap.warningThreshold] + * Reserved, not used for now. + * + * @param {boolean} + * [billingFeaturesProperties.dataVolumeCap.stopSendNotificationWhenHitThreshold] + * Reserved, not used for now. + * + * @param {boolean} + * [billingFeaturesProperties.dataVolumeCap.stopSendNotificationWhenHitCap] Do + * not send a notification email when the daily data volume cap is met. + * + * @param {array} [billingFeaturesProperties.currentBillingFeatures] Current + * enabled pricing plan. When the component is in the Enterprise plan, this + * will list both 'Basic' and 'Application Insights Enterprise'. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName: string, resourceName: string, billingFeaturesProperties: models.ApplicationInsightsComponentBillingFeatures, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Update current billing features for 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} billingFeaturesProperties Properties that need to be + * specified to update billing features for an Application Insights component. + * + * @param {object} [billingFeaturesProperties.dataVolumeCap] An Application + * Insights component daily data volumne cap + * + * @param {number} [billingFeaturesProperties.dataVolumeCap.cap] Daily data + * volume cap in GB. + * + * @param {number} [billingFeaturesProperties.dataVolumeCap.warningThreshold] + * Reserved, not used for now. + * + * @param {boolean} + * [billingFeaturesProperties.dataVolumeCap.stopSendNotificationWhenHitThreshold] + * Reserved, not used for now. + * + * @param {boolean} + * [billingFeaturesProperties.dataVolumeCap.stopSendNotificationWhenHitCap] Do + * not send a notification email when the daily data volume cap is met. + * + * @param {array} [billingFeaturesProperties.currentBillingFeatures] Current + * enabled pricing plan. When the component is in the Enterprise plan, this + * will list both 'Basic' and 'Application Insights Enterprise'. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponentBillingFeatures} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponentBillingFeatures} [result] - The deserialized result object if an error did not occur. + * See {@link ApplicationInsightsComponentBillingFeatures} + * for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + update(resourceGroupName: string, resourceName: string, billingFeaturesProperties: models.ApplicationInsightsComponentBillingFeatures, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, resourceName: string, billingFeaturesProperties: models.ApplicationInsightsComponentBillingFeatures, callback: ServiceCallback): void; + update(resourceGroupName: string, resourceName: string, billingFeaturesProperties: models.ApplicationInsightsComponentBillingFeatures, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ComponentQuotaStatus + * __NOTE__: An instance of this class is automatically created for an + * instance of the ApplicationInsightsManagementClient. + */ +export interface ComponentQuotaStatus { + + + /** + * Returns daily data volume cap (quota) status for 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, resourceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Returns daily data volume cap (quota) status for 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponentQuotaStatus} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponentQuotaStatus} [result] - The deserialized result object if an error did not occur. + * See {@link ApplicationInsightsComponentQuotaStatus} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, resourceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, resourceName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, resourceName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ComponentFeatureCapabilities + * __NOTE__: An instance of this class is automatically created for an + * instance of the ApplicationInsightsManagementClient. + */ +export interface ComponentFeatureCapabilities { + + + /** + * Returns feature capabilites of the 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, resourceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Returns feature capabilites of the 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponentFeatureCapabilities} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponentFeatureCapabilities} [result] - The deserialized result object if an error did not occur. + * See {@link + * ApplicationInsightsComponentFeatureCapabilities} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, resourceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, resourceName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, resourceName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ComponentAvailableFeatures + * __NOTE__: An instance of this class is automatically created for an + * instance of the ApplicationInsightsManagementClient. + */ +export interface ComponentAvailableFeatures { + + + /** + * Returns all available features of the 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, resourceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Returns all available features of the 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponentAvailableFeatures} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponentAvailableFeatures} [result] - The deserialized result object if an error did not occur. + * See {@link + * ApplicationInsightsComponentAvailableFeatures} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, resourceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, resourceName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, resourceName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ProactiveDetectionConfigurations + * __NOTE__: An instance of this class is automatically created for an + * instance of the ApplicationInsightsManagementClient. + */ +export interface ProactiveDetectionConfigurations { + + + /** + * Gets a list of ProactiveDetection configurations of 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(resourceGroupName: string, resourceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a list of ProactiveDetection configurations of 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Array} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(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; + + + /** + * Get the ProactiveDetection configuration for this configuration id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} configurationId The ProactiveDetection configuration ID. + * This is unique within a 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|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, resourceName: string, configurationId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the ProactiveDetection configuration for this configuration id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} configurationId The ProactiveDetection configuration ID. + * This is unique within a Application Insights component. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponentProactiveDetectionConfiguration} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponentProactiveDetectionConfiguration} [result] - The deserialized result object if an error did not occur. + * See {@link + * ApplicationInsightsComponentProactiveDetectionConfiguration} + * for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, resourceName: string, configurationId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, resourceName: string, configurationId: string, callback: ServiceCallback): void; + get(resourceGroupName: string, resourceName: string, configurationId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Update the ProactiveDetection configuration for this configuration id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} configurationId The ProactiveDetection configuration ID. + * This is unique within a Application Insights component. + * + * @param {object} proactiveDetectionProperties Properties that need to be + * specified to update the ProactiveDetection configuration. + * + * @param {string} [proactiveDetectionProperties.name] The rule name + * + * @param {boolean} [proactiveDetectionProperties.enabled] A flag that + * indicates whether this rule is enabled by the user + * + * @param {boolean} + * [proactiveDetectionProperties.sendEmailsToSubscriptionOwners] A flag that + * indicated whether notifications on this rule should be sent to subscription + * owners + * + * @param {array} [proactiveDetectionProperties.customEmails] Custom email + * addresses for this rule notifications + * + * @param {string} [proactiveDetectionProperties.lastUpdatedTime] The last time + * this rule was updated + * + * @param {object} [proactiveDetectionProperties.ruleDefinitions] Static + * definitions of the ProactiveDetection configuration rule (same values for + * all components). + * + * @param {string} [proactiveDetectionProperties.ruleDefinitions.name] The rule + * name + * + * @param {string} [proactiveDetectionProperties.ruleDefinitions.displayName] + * The rule name as it is displayed in UI + * + * @param {string} [proactiveDetectionProperties.ruleDefinitions.description] + * The rule description + * + * @param {string} [proactiveDetectionProperties.ruleDefinitions.helpUrl] URL + * which displays aditional info about the proactive detection rule + * + * @param {boolean} [proactiveDetectionProperties.ruleDefinitions.isHidden] A + * flag indicating whether the rule is hidden (from the UI) + * + * @param {boolean} + * [proactiveDetectionProperties.ruleDefinitions.isEnabledByDefault] A flag + * indicating whether the rule is enabled by default + * + * @param {boolean} [proactiveDetectionProperties.ruleDefinitions.isInPreview] + * A flag indicating whether the rule is in preview + * + * @param {boolean} + * [proactiveDetectionProperties.ruleDefinitions.supportsEmailNotifications] A + * flag indicating whether email notifications are supported for detections for + * this rule + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName: string, resourceName: string, configurationId: string, proactiveDetectionProperties: models.ApplicationInsightsComponentProactiveDetectionConfiguration, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Update the ProactiveDetection configuration for this configuration id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} configurationId The ProactiveDetection configuration ID. + * This is unique within a Application Insights component. + * + * @param {object} proactiveDetectionProperties Properties that need to be + * specified to update the ProactiveDetection configuration. + * + * @param {string} [proactiveDetectionProperties.name] The rule name + * + * @param {boolean} [proactiveDetectionProperties.enabled] A flag that + * indicates whether this rule is enabled by the user + * + * @param {boolean} + * [proactiveDetectionProperties.sendEmailsToSubscriptionOwners] A flag that + * indicated whether notifications on this rule should be sent to subscription + * owners + * + * @param {array} [proactiveDetectionProperties.customEmails] Custom email + * addresses for this rule notifications + * + * @param {string} [proactiveDetectionProperties.lastUpdatedTime] The last time + * this rule was updated + * + * @param {object} [proactiveDetectionProperties.ruleDefinitions] Static + * definitions of the ProactiveDetection configuration rule (same values for + * all components). + * + * @param {string} [proactiveDetectionProperties.ruleDefinitions.name] The rule + * name + * + * @param {string} [proactiveDetectionProperties.ruleDefinitions.displayName] + * The rule name as it is displayed in UI + * + * @param {string} [proactiveDetectionProperties.ruleDefinitions.description] + * The rule description + * + * @param {string} [proactiveDetectionProperties.ruleDefinitions.helpUrl] URL + * which displays aditional info about the proactive detection rule + * + * @param {boolean} [proactiveDetectionProperties.ruleDefinitions.isHidden] A + * flag indicating whether the rule is hidden (from the UI) + * + * @param {boolean} + * [proactiveDetectionProperties.ruleDefinitions.isEnabledByDefault] A flag + * indicating whether the rule is enabled by default + * + * @param {boolean} [proactiveDetectionProperties.ruleDefinitions.isInPreview] + * A flag indicating whether the rule is in preview + * + * @param {boolean} + * [proactiveDetectionProperties.ruleDefinitions.supportsEmailNotifications] A + * flag indicating whether email notifications are supported for detections for + * this rule + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponentProactiveDetectionConfiguration} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponentProactiveDetectionConfiguration} [result] - The deserialized result object if an error did not occur. + * See {@link + * ApplicationInsightsComponentProactiveDetectionConfiguration} + * for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + update(resourceGroupName: string, resourceName: string, configurationId: string, proactiveDetectionProperties: models.ApplicationInsightsComponentProactiveDetectionConfiguration, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, resourceName: string, configurationId: string, proactiveDetectionProperties: models.ApplicationInsightsComponentProactiveDetectionConfiguration, callback: ServiceCallback): void; + update(resourceGroupName: string, resourceName: string, configurationId: string, proactiveDetectionProperties: models.ApplicationInsightsComponentProactiveDetectionConfiguration, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * Components + * __NOTE__: An instance of this class is automatically created for an + * instance of the ApplicationInsightsManagementClient. + */ +export interface Components { + + + /** + * Gets a list of all Application Insights components within a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a list of all Application Insights components within a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponentListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponentListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ApplicationInsightsComponentListResult} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets a list of Application Insights components within a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByResourceGroupWithHttpOperationResponse(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a list of Application Insights components within a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponentListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponentListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ApplicationInsightsComponentListResult} 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, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByResourceGroup(resourceGroupName: string, callback: ServiceCallback): void; + listByResourceGroup(resourceGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, resourceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName: string, resourceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, resourceName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, resourceName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Returns 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, resourceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Returns 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponent} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponent} [result] - The deserialized result object if an error did not occur. + * See {@link ApplicationInsightsComponent} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, resourceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, resourceName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, resourceName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Creates (or updates) an Application Insights component. Note: You cannot + * specify a different value for InstrumentationKey nor AppId in the Put + * operation. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {object} insightProperties Properties that need to be specified to + * create an Application Insights component. + * + * @param {string} insightProperties.kind The kind of application that this + * component refers to, used to customize UI. This value is a freeform string, + * values should typically be one of the following: web, ios, other, store, + * java, phone. + * + * @param {string} insightProperties.applicationType Type of application being + * monitored. Possible values include: 'web', 'other' + * + * @param {string} [insightProperties.flowType] Used by the Application + * Insights system to determine what kind of flow this component was created + * by. This is to be set to 'Bluefield' when creating/updating a component via + * the REST API. Possible values include: 'Bluefield' + * + * @param {string} [insightProperties.requestSource] Describes what tool + * created this Application Insights component. Customers using this API should + * set this to the default 'rest'. Possible values include: 'rest' + * + * @param {string} [insightProperties.hockeyAppId] The unique application ID + * created when a new application is added to HockeyApp, used for + * communications with HockeyApp. + * + * @param {number} [insightProperties.samplingPercentage] Percentage of the + * data produced by the application being monitored that is being sampled for + * Application Insights telemetry. + * + * @param {string} insightProperties.location Resource location + * + * @param {object} [insightProperties.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, resourceName: string, insightProperties: models.ApplicationInsightsComponent, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Creates (or updates) an Application Insights component. Note: You cannot + * specify a different value for InstrumentationKey nor AppId in the Put + * operation. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {object} insightProperties Properties that need to be specified to + * create an Application Insights component. + * + * @param {string} insightProperties.kind The kind of application that this + * component refers to, used to customize UI. This value is a freeform string, + * values should typically be one of the following: web, ios, other, store, + * java, phone. + * + * @param {string} insightProperties.applicationType Type of application being + * monitored. Possible values include: 'web', 'other' + * + * @param {string} [insightProperties.flowType] Used by the Application + * Insights system to determine what kind of flow this component was created + * by. This is to be set to 'Bluefield' when creating/updating a component via + * the REST API. Possible values include: 'Bluefield' + * + * @param {string} [insightProperties.requestSource] Describes what tool + * created this Application Insights component. Customers using this API should + * set this to the default 'rest'. Possible values include: 'rest' + * + * @param {string} [insightProperties.hockeyAppId] The unique application ID + * created when a new application is added to HockeyApp, used for + * communications with HockeyApp. + * + * @param {number} [insightProperties.samplingPercentage] Percentage of the + * data produced by the application being monitored that is being sampled for + * Application Insights telemetry. + * + * @param {string} insightProperties.location Resource location + * + * @param {object} [insightProperties.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponent} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponent} [result] - The deserialized result object if an error did not occur. + * See {@link ApplicationInsightsComponent} 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. + */ + createOrUpdate(resourceGroupName: string, resourceName: string, insightProperties: models.ApplicationInsightsComponent, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, resourceName: string, insightProperties: models.ApplicationInsightsComponent, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, resourceName: string, insightProperties: models.ApplicationInsightsComponent, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Updates an existing component's tags. To update other fields use the + * CreateOrUpdate method. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {object} componentTags Updated tag information to set into the + * component instance. + * + * @param {object} [componentTags.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + updateTagsWithHttpOperationResponse(resourceGroupName: string, resourceName: string, componentTags: models.TagsResource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Updates an existing component's tags. To update other fields use the + * CreateOrUpdate method. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {object} componentTags Updated tag information to set into the + * component instance. + * + * @param {object} [componentTags.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponent} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponent} [result] - The deserialized result object if an error did not occur. + * See {@link ApplicationInsightsComponent} 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. + */ + updateTags(resourceGroupName: string, resourceName: string, componentTags: models.TagsResource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + updateTags(resourceGroupName: string, resourceName: string, componentTags: models.TagsResource, callback: ServiceCallback): void; + updateTags(resourceGroupName: string, resourceName: string, componentTags: models.TagsResource, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Purges data in an Application Insights component by a set of user-defined + * filters. + * + * @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 {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + 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 + * filters. + * + * @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 {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ComponentPurgeResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {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; + + + /** + * Gets the status of a previously submitted purge using the id returned from + * the original purge request. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @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. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getPurgeStatusWithHttpOperationResponse(resourceGroupName: string, resourceName: string, purgeId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the status of a previously submitted purge using the id returned from + * the original purge request. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @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. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ComponentPurgeStatusResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {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. + */ + 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; + + + /** + * Gets a list of all Application Insights components within a subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a list of all Application Insights components within a subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponentListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponentListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ApplicationInsightsComponentListResult} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextPageLink: string, callback: ServiceCallback): void; + listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets a list of Application Insights components within a resource group. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByResourceGroupNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a list of Application Insights components within a resource group. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponentListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponentListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ApplicationInsightsComponentListResult} 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. + */ + listByResourceGroupNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByResourceGroupNext(nextPageLink: string, callback: ServiceCallback): void; + listByResourceGroupNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * WorkItemConfigurations + * __NOTE__: An instance of this class is automatically created for an + * instance of the ApplicationInsightsManagementClient. + */ +export interface WorkItemConfigurations { + + + /** + * Gets the list work item configurations that exist for the application + * + * @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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(resourceGroupName: string, resourceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the list work item configurations that exist for the application + * + * @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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Array} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(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; + + + /** + * Create a work item configuration for 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} workItemConfigurationProperties Properties that need to be + * specified to create a work item configuration of a Application Insights + * component. + * + * @param {string} [workItemConfigurationProperties.connectorId] Unique + * connector id + * + * @param {string} [workItemConfigurationProperties.connectorDataConfiguration] + * Serialized JSON object for detaile d properties + * + * @param {boolean} [workItemConfigurationProperties.validateOnly] Boolean + * indicating validate only + * + * @param {string} [workItemConfigurationProperties.workItemProperties] Custom + * work item properties + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createWithHttpOperationResponse(resourceGroupName: string, resourceName: string, workItemConfigurationProperties: models.WorkItemCreateConfiguration, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Create a work item configuration for 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} workItemConfigurationProperties Properties that need to be + * specified to create a work item configuration of a Application Insights + * component. + * + * @param {string} [workItemConfigurationProperties.connectorId] Unique + * connector id + * + * @param {string} [workItemConfigurationProperties.connectorDataConfiguration] + * Serialized JSON object for detaile d properties + * + * @param {boolean} [workItemConfigurationProperties.validateOnly] Boolean + * indicating validate only + * + * @param {string} [workItemConfigurationProperties.workItemProperties] Custom + * work item properties + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {WorkItemConfiguration} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {WorkItemConfiguration} [result] - The deserialized result object if an error did not occur. + * See {@link WorkItemConfiguration} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + create(resourceGroupName: string, resourceName: string, workItemConfigurationProperties: models.WorkItemCreateConfiguration, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + create(resourceGroupName: string, resourceName: string, workItemConfigurationProperties: models.WorkItemCreateConfiguration, callback: ServiceCallback): void; + create(resourceGroupName: string, resourceName: string, workItemConfigurationProperties: models.WorkItemCreateConfiguration, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets default work item configurations that exist for the application + * + * @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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getDefaultWithHttpOperationResponse(resourceGroupName: string, resourceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets default work item configurations that exist for the application + * + * @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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {WorkItemConfiguration} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {WorkItemConfiguration} [result] - The deserialized result object if an error did not occur. + * See {@link WorkItemConfiguration} 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. + */ + getDefault(resourceGroupName: string, resourceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getDefault(resourceGroupName: string, resourceName: string, callback: ServiceCallback): void; + getDefault(resourceGroupName: string, resourceName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Delete an workitem configuration of 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} workItemConfigId The unique work item configuration Id. This + * can be either friendly name of connector as defined in connector + * configuration + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, resourceName: string, workItemConfigId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Delete an workitem configuration of 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} workItemConfigId The unique work item configuration Id. This + * can be either friendly name of connector as defined in connector + * configuration + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Object} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Object} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName: string, resourceName: string, workItemConfigId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, resourceName: string, workItemConfigId: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, resourceName: string, workItemConfigId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * Favorites + * __NOTE__: An instance of this class is automatically created for an + * instance of the ApplicationInsightsManagementClient. + */ +export interface Favorites { + + + /** + * 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|ServiceError} - The error object. + */ + listWithHttpOperationResponse(resourceGroupName: string, resourceName: string, options?: { favoriteType? : string, sourceType? : string, canFetchContent? : boolean, tags? : string[], customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * 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 {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Array} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(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 { + + + /** + * 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|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, resourceName: string, favoriteId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * 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 {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponentFavorite} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponentFavorite} [result] - The deserialized result object if an error did not occur. + * See {@link ApplicationInsightsComponentFavorite} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, resourceName: string, favoriteId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, resourceName: string, favoriteId: string, callback: ServiceCallback): void; + get(resourceGroupName: string, resourceName: string, favoriteId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * 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|ServiceError} - The error object. + */ + addWithHttpOperationResponse(resourceGroupName: string, resourceName: string, favoriteId: string, favoriteProperties: models.ApplicationInsightsComponentFavorite, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * 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 {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponentFavorite} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponentFavorite} [result] - The deserialized result object if an error did not occur. + * See {@link ApplicationInsightsComponentFavorite} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + add(resourceGroupName: string, resourceName: string, favoriteId: string, favoriteProperties: models.ApplicationInsightsComponentFavorite, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + add(resourceGroupName: string, resourceName: string, favoriteId: string, favoriteProperties: models.ApplicationInsightsComponentFavorite, callback: ServiceCallback): void; + add(resourceGroupName: string, resourceName: string, favoriteId: string, favoriteProperties: models.ApplicationInsightsComponentFavorite, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * 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. + * + * @reject {Error|ServiceError} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName: string, resourceName: string, favoriteId: string, favoriteProperties: models.ApplicationInsightsComponentFavorite, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * 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 {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsComponentFavorite} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsComponentFavorite} [result] - The deserialized result object if an error did not occur. + * See {@link ApplicationInsightsComponentFavorite} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + update(resourceGroupName: string, resourceName: string, favoriteId: string, favoriteProperties: models.ApplicationInsightsComponentFavorite, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, resourceName: string, favoriteId: string, favoriteProperties: models.ApplicationInsightsComponentFavorite, callback: ServiceCallback): void; + update(resourceGroupName: string, resourceName: string, favoriteId: string, favoriteProperties: models.ApplicationInsightsComponentFavorite, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * 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|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, resourceName: string, favoriteId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * 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 {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName: string, resourceName: string, favoriteId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, resourceName: string, favoriteId: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, resourceName: string, favoriteId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * WebTestLocations + * __NOTE__: An instance of this class is automatically created for an + * instance of the ApplicationInsightsManagementClient. + */ +export interface WebTestLocations { + + + /** + * Gets a list of web test locations available to this 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(resourceGroupName: string, resourceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a list of web test locations available to this 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 {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ApplicationInsightsWebTestLocationsListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ApplicationInsightsWebTestLocationsListResult} [result] - The deserialized result object if an error did not occur. + * See {@link + * ApplicationInsightsWebTestLocationsListResult} 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; +} + +/** + * @class + * WebTests + * __NOTE__: An instance of this class is automatically created for an + * instance of the ApplicationInsightsManagementClient. + */ +export interface WebTests { + + + /** + * Get all Application Insights web tests defined within a specified resource + * group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByResourceGroupWithHttpOperationResponse(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get all Application Insights web tests defined within a specified resource + * group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {WebTestListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {WebTestListResult} [result] - The deserialized result object if an error did not occur. + * See {@link WebTestListResult} 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, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByResourceGroup(resourceGroupName: string, callback: ServiceCallback): void; + listByResourceGroup(resourceGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get a specific Application Insights web test definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} webTestName The name of the Application Insights webtest + * resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, webTestName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get a specific Application Insights web test definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} webTestName The name of the Application Insights webtest + * resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {WebTest} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {WebTest} [result] - The deserialized result object if an error did not occur. + * See {@link WebTest} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, webTestName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, webTestName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, webTestName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Creates or updates an Application Insights web test definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} webTestName The name of the Application Insights webtest + * resource. + * + * @param {object} webTestDefinition Properties that need to be specified to + * create or update an Application Insights web test definition. + * + * @param {string} [webTestDefinition.kind] The kind of web test that this web + * test watches. Choices are ping and multistep. Possible values include: + * 'ping', 'multistep' + * + * @param {string} webTestDefinition.syntheticMonitorId Unique ID of this + * WebTest. This is typically the same value as the Name field. + * + * @param {string} webTestDefinition.webTestName User defined name if this + * WebTest. + * + * @param {string} [webTestDefinition.description] Purpose/user defined + * descriptive test for this WebTest. + * + * @param {boolean} [webTestDefinition.enabled] Is the test actively being + * monitored. + * + * @param {number} [webTestDefinition.frequency] Interval in seconds between + * test runs for this WebTest. Default value is 300. + * + * @param {number} [webTestDefinition.timeout] Seconds until this WebTest will + * timeout and fail. Default value is 30. + * + * @param {string} webTestDefinition.webTestKind The kind of web test this is, + * valid choices are ping and multistep. Possible values include: 'ping', + * 'multistep' + * + * @param {boolean} [webTestDefinition.retryEnabled] Allow for retries should + * this WebTest fail. + * + * @param {array} webTestDefinition.locations A list of where to physically run + * the tests from to give global coverage for accessibility of your + * application. + * + * @param {object} [webTestDefinition.configuration] An XML configuration + * specification for a WebTest. + * + * @param {string} [webTestDefinition.configuration.webTest] The XML + * specification of a WebTest to run against an application. + * + * @param {string} webTestDefinition.location Resource location + * + * @param {object} [webTestDefinition.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, webTestName: string, webTestDefinition: models.WebTest, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Creates or updates an Application Insights web test definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} webTestName The name of the Application Insights webtest + * resource. + * + * @param {object} webTestDefinition Properties that need to be specified to + * create or update an Application Insights web test definition. + * + * @param {string} [webTestDefinition.kind] The kind of web test that this web + * test watches. Choices are ping and multistep. Possible values include: + * 'ping', 'multistep' + * + * @param {string} webTestDefinition.syntheticMonitorId Unique ID of this + * WebTest. This is typically the same value as the Name field. + * + * @param {string} webTestDefinition.webTestName User defined name if this + * WebTest. + * + * @param {string} [webTestDefinition.description] Purpose/user defined + * descriptive test for this WebTest. + * + * @param {boolean} [webTestDefinition.enabled] Is the test actively being + * monitored. + * + * @param {number} [webTestDefinition.frequency] Interval in seconds between + * test runs for this WebTest. Default value is 300. + * + * @param {number} [webTestDefinition.timeout] Seconds until this WebTest will + * timeout and fail. Default value is 30. + * + * @param {string} webTestDefinition.webTestKind The kind of web test this is, + * valid choices are ping and multistep. Possible values include: 'ping', + * 'multistep' + * + * @param {boolean} [webTestDefinition.retryEnabled] Allow for retries should + * this WebTest fail. + * + * @param {array} webTestDefinition.locations A list of where to physically run + * the tests from to give global coverage for accessibility of your + * application. + * + * @param {object} [webTestDefinition.configuration] An XML configuration + * specification for a WebTest. + * + * @param {string} [webTestDefinition.configuration.webTest] The XML + * specification of a WebTest to run against an application. + * + * @param {string} webTestDefinition.location Resource location + * + * @param {object} [webTestDefinition.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {WebTest} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {WebTest} [result] - The deserialized result object if an error did not occur. + * See {@link WebTest} 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. + */ + createOrUpdate(resourceGroupName: string, webTestName: string, webTestDefinition: models.WebTest, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, webTestName: string, webTestDefinition: models.WebTest, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, webTestName: string, webTestDefinition: models.WebTest, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Creates or updates an Application Insights web test definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} webTestName The name of the Application Insights webtest + * resource. + * + * @param {object} webTestTags Updated tag information to set into the web test + * instance. + * + * @param {object} [webTestTags.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + updateTagsWithHttpOperationResponse(resourceGroupName: string, webTestName: string, webTestTags: models.TagsResource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Creates or updates an Application Insights web test definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} webTestName The name of the Application Insights webtest + * resource. + * + * @param {object} webTestTags Updated tag information to set into the web test + * instance. + * + * @param {object} [webTestTags.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {WebTest} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {WebTest} [result] - The deserialized result object if an error did not occur. + * See {@link WebTest} 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. + */ + updateTags(resourceGroupName: string, webTestName: string, webTestTags: models.TagsResource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + updateTags(resourceGroupName: string, webTestName: string, webTestTags: models.TagsResource, callback: ServiceCallback): void; + updateTags(resourceGroupName: string, webTestName: string, webTestTags: models.TagsResource, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes an Application Insights web test. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} webTestName The name of the Application Insights webtest + * resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, webTestName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes an Application Insights web test. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} webTestName The name of the Application Insights webtest + * resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName: string, webTestName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, webTestName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, webTestName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get all Application Insights web test alerts definitioned within a + * subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get all Application Insights web test alerts definitioned within a + * subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {WebTestListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {WebTestListResult} [result] - The deserialized result object if an error did not occur. + * See {@link WebTestListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get all Application Insights web tests defined within a specified resource + * group. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByResourceGroupNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get all Application Insights web tests defined within a specified resource + * group. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {WebTestListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {WebTestListResult} [result] - The deserialized result object if an error did not occur. + * See {@link WebTestListResult} 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. + */ + listByResourceGroupNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByResourceGroupNext(nextPageLink: string, callback: ServiceCallback): void; + listByResourceGroupNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get all Application Insights web test alerts definitioned within a + * subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get all Application Insights web test alerts definitioned within a + * subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {WebTestListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {WebTestListResult} [result] - The deserialized result object if an error did not occur. + * See {@link WebTestListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextPageLink: string, callback: ServiceCallback): void; + listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * WorkbooksOperations + * __NOTE__: An instance of this class is automatically created for an + * instance of the ApplicationInsightsManagementClient. + */ +export interface WorkbooksOperations { + + + /** + * Get all Workbooks defined within a specified resource group and category. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} location The name of location where workbook is stored. + * + * @param {string} category Category of workbook to return. Possible values + * include: 'workbook', 'TSG', 'performance', 'retention' + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.tags] Tags presents on each workbook returned. + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable workbook. If false, only return + * summary content for workbooks. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByResourceGroupWithHttpOperationResponse(resourceGroupName: string, location: string, category: string, options?: { tags? : string[], canFetchContent? : boolean, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get all Workbooks defined within a specified resource group and category. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} location The name of location where workbook is stored. + * + * @param {string} category Category of workbook to return. Possible values + * include: 'workbook', 'TSG', 'performance', 'retention' + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.tags] Tags presents on each workbook returned. + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable workbook. If false, only return + * summary content for workbooks. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Workbooks} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Workbooks} [result] - The deserialized result object if an error did not occur. + * See {@link Workbooks} 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, location: string, category: string, options?: { tags? : string[], canFetchContent? : boolean, customHeaders? : { [headerName: string]: string; } }): Promise; + listByResourceGroup(resourceGroupName: string, location: string, category: string, callback: ServiceCallback): void; + listByResourceGroup(resourceGroupName: string, location: 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 { + + + /** + * Delete a workbook. + * + * @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 + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, resourceName: string, location: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Delete a workbook. + * + * @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 + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName: string, resourceName: string, location: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, resourceName: string, location: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, resourceName: string, location: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * 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} 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. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, resourceName: string, workbookProperties: models.Workbook, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * 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} 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. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Workbook} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Workbook} [result] - The deserialized result object if an error did not occur. + * See {@link Workbook} 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. + */ + createOrUpdate(resourceGroupName: string, resourceName: string, workbookProperties: models.Workbook, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, resourceName: string, workbookProperties: models.Workbook, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, resourceName: string, workbookProperties: models.Workbook, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * 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 {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. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName: string, resourceName: string, workbookProperties: models.Workbook, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * 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 {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. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Workbook} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Workbook} [result] - The deserialized result object if an error did not occur. + * See {@link Workbook} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + update(resourceGroupName: string, resourceName: string, workbookProperties: models.Workbook, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, resourceName: string, workbookProperties: models.Workbook, callback: ServiceCallback): void; + update(resourceGroupName: string, resourceName: string, workbookProperties: models.Workbook, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get a single workbook by its resourceName. + * + * @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 + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceName: string, location: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get a single workbook by its resourceName. + * + * @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 + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Workbook} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Workbook} [result] - The deserialized result object if an error did not occur. + * See {@link Workbook} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceName: string, location: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceName: string, location: string, callback: ServiceCallback): void; + get(resourceName: string, location: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets a list of workbooks by sourceId. + * + * @param {string} sourceId Azure Resource Id that will fetch all linked + * workbooks. + * + * @param {string} category Category of workbook to return. Possible values + * include: 'workbook', 'TSG', 'performance', 'retention' + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.tags] Tags presents on each workbook returned. + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable workbook. If false, only return + * summary content for workbooks. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(sourceId: string, category: string, options?: { tags? : string[], canFetchContent? : boolean, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a list of workbooks by sourceId. + * + * @param {string} sourceId Azure Resource Id that will fetch all linked + * workbooks. + * + * @param {string} category Category of workbook to return. Possible values + * include: 'workbook', 'TSG', 'performance', 'retention' + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.tags] Tags presents on each workbook returned. + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable workbook. If false, only return + * summary content for workbooks. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Array} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(sourceId: string, category: string, options?: { tags? : string[], canFetchContent? : boolean, customHeaders? : { [headerName: string]: string; } }): Promise; + list(sourceId: string, category: string, callback: ServiceCallback): void; + list(sourceId: string, category: string, options: { tags? : string[], canFetchContent? : boolean, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} diff --git a/lib/services/applicationinsights/lib/lib/operations/index.js b/lib/services/applicationinsights/lib/lib/operations/index.js new file mode 100644 index 0000000000..51825288b4 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/operations/index.js @@ -0,0 +1,33 @@ +/* + * 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. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +exports.Operations = require('./operations'); +exports.Annotations = require('./annotations'); +exports.APIKeys = require('./aPIKeys'); +exports.ExportConfigurations = require('./exportConfigurations'); +exports.ComponentCurrentBillingFeatures = require('./componentCurrentBillingFeatures'); +exports.ComponentQuotaStatus = require('./componentQuotaStatus'); +exports.ComponentFeatureCapabilities = require('./componentFeatureCapabilities'); +exports.ComponentAvailableFeatures = require('./componentAvailableFeatures'); +exports.ProactiveDetectionConfigurations = require('./proactiveDetectionConfigurations'); +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.WorkbooksOperations = require('./workbooksOperations'); +exports.WorkbookOperations = require('./workbookOperations'); diff --git a/lib/services/applicationinsights/lib/lib/operations/operations.js b/lib/services/applicationinsights/lib/lib/operations/operations.js new file mode 100644 index 0000000000..4647867740 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/operations/operations.js @@ -0,0 +1,451 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists all of the available insights REST API operations. + * + * @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 OperationListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Insights/operations'; + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['OperationListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists all of the available insights REST API operations. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {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 OperationListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['OperationListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a Operations. */ +class Operations { + /** + * Create a Operations. + * @param {ApplicationInsightsManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listNext = _listNext; + } + + /** + * Lists all of the available insights REST API operations. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all of the available insights REST API operations. + * + * @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 {OperationListResult} - 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 OperationListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(options, optionalCallback); + } + } + + /** + * Lists all of the available insights REST API operations. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all of the available insights REST API operations. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {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 {OperationListResult} - 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 OperationListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = Operations; diff --git a/lib/services/applicationinsights/lib/lib/operations/proactiveDetectionConfigurations.js b/lib/services/applicationinsights/lib/lib/operations/proactiveDetectionConfigurations.js new file mode 100644 index 0000000000..ab34c6bfd4 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/operations/proactiveDetectionConfigurations.js @@ -0,0 +1,950 @@ +/* + * 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 ProactiveDetection configurations of 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 {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, 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 (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}/ProactiveDetectionConfigs'; + 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('&'); + } + + // 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: 'ApplicationInsightsComponentProactiveDetectionConfigurationElementType', + type: { + name: 'Composite', + className: 'ApplicationInsightsComponentProactiveDetectionConfiguration' + } + } + } + }; + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Get the ProactiveDetection configuration for this configuration id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} configurationId The ProactiveDetection configuration ID. + * This is unique within a 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 + * ApplicationInsightsComponentProactiveDetectionConfiguration} + * for more information. + * + * {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, configurationId, 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 (configurationId === null || configurationId === undefined || typeof configurationId.valueOf() !== 'string') { + throw new Error('configurationId 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}/ProactiveDetectionConfigs/{ConfigurationId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); + requestUrl = requestUrl.replace('{ConfigurationId}', encodeURIComponent(configurationId)); + 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['ApplicationInsightsComponentProactiveDetectionConfiguration']().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); + }); +} + +/** + * Update the ProactiveDetection configuration for this configuration id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} configurationId The ProactiveDetection configuration ID. + * This is unique within a Application Insights component. + * + * @param {object} proactiveDetectionProperties Properties that need to be + * specified to update the ProactiveDetection configuration. + * + * @param {string} [proactiveDetectionProperties.name] The rule name + * + * @param {boolean} [proactiveDetectionProperties.enabled] A flag that + * indicates whether this rule is enabled by the user + * + * @param {boolean} + * [proactiveDetectionProperties.sendEmailsToSubscriptionOwners] A flag that + * indicated whether notifications on this rule should be sent to subscription + * owners + * + * @param {array} [proactiveDetectionProperties.customEmails] Custom email + * addresses for this rule notifications + * + * @param {string} [proactiveDetectionProperties.lastUpdatedTime] The last time + * this rule was updated + * + * @param {object} [proactiveDetectionProperties.ruleDefinitions] Static + * definitions of the ProactiveDetection configuration rule (same values for + * all components). + * + * @param {string} [proactiveDetectionProperties.ruleDefinitions.name] The rule + * name + * + * @param {string} [proactiveDetectionProperties.ruleDefinitions.displayName] + * The rule name as it is displayed in UI + * + * @param {string} [proactiveDetectionProperties.ruleDefinitions.description] + * The rule description + * + * @param {string} [proactiveDetectionProperties.ruleDefinitions.helpUrl] URL + * which displays aditional info about the proactive detection rule + * + * @param {boolean} [proactiveDetectionProperties.ruleDefinitions.isHidden] A + * flag indicating whether the rule is hidden (from the UI) + * + * @param {boolean} + * [proactiveDetectionProperties.ruleDefinitions.isEnabledByDefault] A flag + * indicating whether the rule is enabled by default + * + * @param {boolean} [proactiveDetectionProperties.ruleDefinitions.isInPreview] + * A flag indicating whether the rule is in preview + * + * @param {boolean} + * [proactiveDetectionProperties.ruleDefinitions.supportsEmailNotifications] A + * flag indicating whether email notifications are supported for detections for + * this rule + * + * @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 + * ApplicationInsightsComponentProactiveDetectionConfiguration} + * for more information. + * + * {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, configurationId, proactiveDetectionProperties, 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 (configurationId === null || configurationId === undefined || typeof configurationId.valueOf() !== 'string') { + throw new Error('configurationId cannot be null or undefined and it must be of type string.'); + } + if (proactiveDetectionProperties === null || proactiveDetectionProperties === undefined) { + throw new Error('proactiveDetectionProperties 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}/ProactiveDetectionConfigs/{ConfigurationId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); + requestUrl = requestUrl.replace('{ConfigurationId}', encodeURIComponent(configurationId)); + 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 (proactiveDetectionProperties !== null && proactiveDetectionProperties !== undefined) { + let requestModelMapper = new client.models['ApplicationInsightsComponentProactiveDetectionConfiguration']().mapper(); + requestModel = client.serialize(requestModelMapper, proactiveDetectionProperties, 'proactiveDetectionProperties'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(proactiveDetectionProperties, 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['ApplicationInsightsComponentProactiveDetectionConfiguration']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a ProactiveDetectionConfigurations. */ +class ProactiveDetectionConfigurations { + /** + * Create a ProactiveDetectionConfigurations. + * @param {ApplicationInsightsManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._get = _get; + this._update = _update; + } + + /** + * Gets a list of ProactiveDetection configurations of 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 {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 ProactiveDetection configurations of 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 {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 the ProactiveDetection configuration for this configuration id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} configurationId The ProactiveDetection configuration ID. + * This is unique within a 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, configurationId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, resourceName, configurationId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get the ProactiveDetection configuration for this configuration id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} configurationId The ProactiveDetection configuration ID. + * This is unique within a 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 {ApplicationInsightsComponentProactiveDetectionConfiguration} - 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 + * ApplicationInsightsComponentProactiveDetectionConfiguration} + * for more information. + * + * {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, configurationId, 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, configurationId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, resourceName, configurationId, options, optionalCallback); + } + } + + /** + * Update the ProactiveDetection configuration for this configuration id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} configurationId The ProactiveDetection configuration ID. + * This is unique within a Application Insights component. + * + * @param {object} proactiveDetectionProperties Properties that need to be + * specified to update the ProactiveDetection configuration. + * + * @param {string} [proactiveDetectionProperties.name] The rule name + * + * @param {boolean} [proactiveDetectionProperties.enabled] A flag that + * indicates whether this rule is enabled by the user + * + * @param {boolean} + * [proactiveDetectionProperties.sendEmailsToSubscriptionOwners] A flag that + * indicated whether notifications on this rule should be sent to subscription + * owners + * + * @param {array} [proactiveDetectionProperties.customEmails] Custom email + * addresses for this rule notifications + * + * @param {string} [proactiveDetectionProperties.lastUpdatedTime] The last time + * this rule was updated + * + * @param {object} [proactiveDetectionProperties.ruleDefinitions] Static + * definitions of the ProactiveDetection configuration rule (same values for + * all components). + * + * @param {string} [proactiveDetectionProperties.ruleDefinitions.name] The rule + * name + * + * @param {string} [proactiveDetectionProperties.ruleDefinitions.displayName] + * The rule name as it is displayed in UI + * + * @param {string} [proactiveDetectionProperties.ruleDefinitions.description] + * The rule description + * + * @param {string} [proactiveDetectionProperties.ruleDefinitions.helpUrl] URL + * which displays aditional info about the proactive detection rule + * + * @param {boolean} [proactiveDetectionProperties.ruleDefinitions.isHidden] A + * flag indicating whether the rule is hidden (from the UI) + * + * @param {boolean} + * [proactiveDetectionProperties.ruleDefinitions.isEnabledByDefault] A flag + * indicating whether the rule is enabled by default + * + * @param {boolean} [proactiveDetectionProperties.ruleDefinitions.isInPreview] + * A flag indicating whether the rule is in preview + * + * @param {boolean} + * [proactiveDetectionProperties.ruleDefinitions.supportsEmailNotifications] A + * flag indicating whether email notifications are supported for detections for + * this rule + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName, resourceName, configurationId, proactiveDetectionProperties, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(resourceGroupName, resourceName, configurationId, proactiveDetectionProperties, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Update the ProactiveDetection configuration for this configuration id. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {string} configurationId The ProactiveDetection configuration ID. + * This is unique within a Application Insights component. + * + * @param {object} proactiveDetectionProperties Properties that need to be + * specified to update the ProactiveDetection configuration. + * + * @param {string} [proactiveDetectionProperties.name] The rule name + * + * @param {boolean} [proactiveDetectionProperties.enabled] A flag that + * indicates whether this rule is enabled by the user + * + * @param {boolean} + * [proactiveDetectionProperties.sendEmailsToSubscriptionOwners] A flag that + * indicated whether notifications on this rule should be sent to subscription + * owners + * + * @param {array} [proactiveDetectionProperties.customEmails] Custom email + * addresses for this rule notifications + * + * @param {string} [proactiveDetectionProperties.lastUpdatedTime] The last time + * this rule was updated + * + * @param {object} [proactiveDetectionProperties.ruleDefinitions] Static + * definitions of the ProactiveDetection configuration rule (same values for + * all components). + * + * @param {string} [proactiveDetectionProperties.ruleDefinitions.name] The rule + * name + * + * @param {string} [proactiveDetectionProperties.ruleDefinitions.displayName] + * The rule name as it is displayed in UI + * + * @param {string} [proactiveDetectionProperties.ruleDefinitions.description] + * The rule description + * + * @param {string} [proactiveDetectionProperties.ruleDefinitions.helpUrl] URL + * which displays aditional info about the proactive detection rule + * + * @param {boolean} [proactiveDetectionProperties.ruleDefinitions.isHidden] A + * flag indicating whether the rule is hidden (from the UI) + * + * @param {boolean} + * [proactiveDetectionProperties.ruleDefinitions.isEnabledByDefault] A flag + * indicating whether the rule is enabled by default + * + * @param {boolean} [proactiveDetectionProperties.ruleDefinitions.isInPreview] + * A flag indicating whether the rule is in preview + * + * @param {boolean} + * [proactiveDetectionProperties.ruleDefinitions.supportsEmailNotifications] A + * flag indicating whether email notifications are supported for detections for + * this rule + * + * @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 {ApplicationInsightsComponentProactiveDetectionConfiguration} - 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 + * ApplicationInsightsComponentProactiveDetectionConfiguration} + * for more information. + * + * {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, configurationId, proactiveDetectionProperties, 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, configurationId, proactiveDetectionProperties, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(resourceGroupName, resourceName, configurationId, proactiveDetectionProperties, options, optionalCallback); + } + } + +} + +module.exports = ProactiveDetectionConfigurations; diff --git a/lib/services/applicationinsights/lib/lib/operations/webTestLocations.js b/lib/services/applicationinsights/lib/lib/operations/webTestLocations.js new file mode 100644 index 0000000000..c89e7dd3f0 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/operations/webTestLocations.js @@ -0,0 +1,271 @@ +/* + * 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 web test locations available to this 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 {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 + * ApplicationInsightsWebTestLocationsListResult} for more + * information. + * + * {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, 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 (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}/syntheticmonitorlocations'; + 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('&'); + } + + // 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['ApplicationInsightsWebTestLocationsListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a WebTestLocations. */ +class WebTestLocations { + /** + * Create a WebTestLocations. + * @param {ApplicationInsightsManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + } + + /** + * Gets a list of web test locations available to this 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 {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 web test locations available to this 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 {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 {ApplicationInsightsWebTestLocationsListResult} - 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 + * ApplicationInsightsWebTestLocationsListResult} for more + * information. + * + * {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); + } + } + +} + +module.exports = WebTestLocations; diff --git a/lib/services/applicationinsights/lib/lib/operations/webTests.js b/lib/services/applicationinsights/lib/lib/operations/webTests.js new file mode 100644 index 0000000000..7f9a557bdf --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/operations/webTests.js @@ -0,0 +1,2007 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Get all Application Insights web tests defined within a specified resource + * group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @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 WebTestListResult} for more information. + * + * {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(resourceGroupName, 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 (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/webtests'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['WebTestListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Get a specific Application Insights web test definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} webTestName The name of the Application Insights webtest + * resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link WebTest} for more information. + * + * {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, webTestName, 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 (webTestName === null || webTestName === undefined || typeof webTestName.valueOf() !== 'string') { + throw new Error('webTestName 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/webtests/{webTestName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{webTestName}', encodeURIComponent(webTestName)); + 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['WebTest']().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); + }); +} + +/** + * Creates or updates an Application Insights web test definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} webTestName The name of the Application Insights webtest + * resource. + * + * @param {object} webTestDefinition Properties that need to be specified to + * create or update an Application Insights web test definition. + * + * @param {string} [webTestDefinition.kind] The kind of web test that this web + * test watches. Choices are ping and multistep. Possible values include: + * 'ping', 'multistep' + * + * @param {string} webTestDefinition.syntheticMonitorId Unique ID of this + * WebTest. This is typically the same value as the Name field. + * + * @param {string} webTestDefinition.webTestName User defined name if this + * WebTest. + * + * @param {string} [webTestDefinition.description] Purpose/user defined + * descriptive test for this WebTest. + * + * @param {boolean} [webTestDefinition.enabled] Is the test actively being + * monitored. + * + * @param {number} [webTestDefinition.frequency] Interval in seconds between + * test runs for this WebTest. Default value is 300. + * + * @param {number} [webTestDefinition.timeout] Seconds until this WebTest will + * timeout and fail. Default value is 30. + * + * @param {string} webTestDefinition.webTestKind The kind of web test this is, + * valid choices are ping and multistep. Possible values include: 'ping', + * 'multistep' + * + * @param {boolean} [webTestDefinition.retryEnabled] Allow for retries should + * this WebTest fail. + * + * @param {array} webTestDefinition.locations A list of where to physically run + * the tests from to give global coverage for accessibility of your + * application. + * + * @param {object} [webTestDefinition.configuration] An XML configuration + * specification for a WebTest. + * + * @param {string} [webTestDefinition.configuration.webTest] The XML + * specification of a WebTest to run against an application. + * + * @param {string} webTestDefinition.location Resource location + * + * @param {object} [webTestDefinition.tags] Resource tags + * + * @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 WebTest} for more information. + * + * {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 _createOrUpdate(resourceGroupName, webTestName, webTestDefinition, 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 (webTestName === null || webTestName === undefined || typeof webTestName.valueOf() !== 'string') { + throw new Error('webTestName cannot be null or undefined and it must be of type string.'); + } + if (webTestDefinition === null || webTestDefinition === undefined) { + throw new Error('webTestDefinition 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/webtests/{webTestName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{webTestName}', encodeURIComponent(webTestName)); + 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 (webTestDefinition !== null && webTestDefinition !== undefined) { + let requestModelMapper = new client.models['WebTest']().mapper(); + requestModel = client.serialize(requestModelMapper, webTestDefinition, 'webTestDefinition'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(webTestDefinition, 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['WebTest']().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); + }); +} + +/** + * Creates or updates an Application Insights web test definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} webTestName The name of the Application Insights webtest + * resource. + * + * @param {object} webTestTags Updated tag information to set into the web test + * instance. + * + * @param {object} [webTestTags.tags] Resource tags + * + * @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 WebTest} for more information. + * + * {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 _updateTags(resourceGroupName, webTestName, webTestTags, 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 (webTestName === null || webTestName === undefined || typeof webTestName.valueOf() !== 'string') { + throw new Error('webTestName cannot be null or undefined and it must be of type string.'); + } + if (webTestTags === null || webTestTags === undefined) { + throw new Error('webTestTags 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/webtests/{webTestName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{webTestName}', encodeURIComponent(webTestName)); + 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 (webTestTags !== null && webTestTags !== undefined) { + let requestModelMapper = new client.models['TagsResource']().mapper(); + requestModel = client.serialize(requestModelMapper, webTestTags, 'webTestTags'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(webTestTags, 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['WebTest']().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 an Application Insights web test. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} webTestName The name of the Application Insights webtest + * resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {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, webTestName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (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 (webTestName === null || webTestName === undefined || typeof webTestName.valueOf() !== 'string') { + throw new Error('webTestName cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{webTestName}', encodeURIComponent(webTestName)); + 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 && statusCode !== 204) { + 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); + }); +} + +/** + * Get all Application Insights web test alerts definitioned within a + * subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link WebTestListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Insights/webtests'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['WebTestListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Get all Application Insights web tests defined within a specified resource + * group. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link WebTestListResult} for more information. + * + * {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 _listByResourceGroupNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['WebTestListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Get all Application Insights web test alerts definitioned within a + * subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link WebTestListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['WebTestListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a WebTests. */ +class WebTests { + /** + * Create a WebTests. + * @param {ApplicationInsightsManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._listByResourceGroup = _listByResourceGroup; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + this._updateTags = _updateTags; + this._deleteMethod = _deleteMethod; + this._list = _list; + this._listByResourceGroupNext = _listByResourceGroupNext; + this._listNext = _listNext; + } + + /** + * Get all Application Insights web tests defined within a specified resource + * group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @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. + */ + listByResourceGroupWithHttpOperationResponse(resourceGroupName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get all Application Insights web tests defined within a specified resource + * group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @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 {WebTestListResult} - 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 WebTestListResult} for more information. + * + * {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(resourceGroupName, 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._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByResourceGroup(resourceGroupName, options, optionalCallback); + } + } + + /** + * Get a specific Application Insights web test definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} webTestName The name of the Application Insights webtest + * resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, webTestName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, webTestName, 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 specific Application Insights web test definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} webTestName The name of the Application Insights webtest + * resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {WebTest} - 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 WebTest} for more information. + * + * {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, webTestName, 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, webTestName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, webTestName, options, optionalCallback); + } + } + + /** + * Creates or updates an Application Insights web test definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} webTestName The name of the Application Insights webtest + * resource. + * + * @param {object} webTestDefinition Properties that need to be specified to + * create or update an Application Insights web test definition. + * + * @param {string} [webTestDefinition.kind] The kind of web test that this web + * test watches. Choices are ping and multistep. Possible values include: + * 'ping', 'multistep' + * + * @param {string} webTestDefinition.syntheticMonitorId Unique ID of this + * WebTest. This is typically the same value as the Name field. + * + * @param {string} webTestDefinition.webTestName User defined name if this + * WebTest. + * + * @param {string} [webTestDefinition.description] Purpose/user defined + * descriptive test for this WebTest. + * + * @param {boolean} [webTestDefinition.enabled] Is the test actively being + * monitored. + * + * @param {number} [webTestDefinition.frequency] Interval in seconds between + * test runs for this WebTest. Default value is 300. + * + * @param {number} [webTestDefinition.timeout] Seconds until this WebTest will + * timeout and fail. Default value is 30. + * + * @param {string} webTestDefinition.webTestKind The kind of web test this is, + * valid choices are ping and multistep. Possible values include: 'ping', + * 'multistep' + * + * @param {boolean} [webTestDefinition.retryEnabled] Allow for retries should + * this WebTest fail. + * + * @param {array} webTestDefinition.locations A list of where to physically run + * the tests from to give global coverage for accessibility of your + * application. + * + * @param {object} [webTestDefinition.configuration] An XML configuration + * specification for a WebTest. + * + * @param {string} [webTestDefinition.configuration.webTest] The XML + * specification of a WebTest to run against an application. + * + * @param {string} webTestDefinition.location Resource location + * + * @param {object} [webTestDefinition.tags] Resource tags + * + * @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. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName, webTestName, webTestDefinition, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, webTestName, webTestDefinition, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Creates or updates an Application Insights web test definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} webTestName The name of the Application Insights webtest + * resource. + * + * @param {object} webTestDefinition Properties that need to be specified to + * create or update an Application Insights web test definition. + * + * @param {string} [webTestDefinition.kind] The kind of web test that this web + * test watches. Choices are ping and multistep. Possible values include: + * 'ping', 'multistep' + * + * @param {string} webTestDefinition.syntheticMonitorId Unique ID of this + * WebTest. This is typically the same value as the Name field. + * + * @param {string} webTestDefinition.webTestName User defined name if this + * WebTest. + * + * @param {string} [webTestDefinition.description] Purpose/user defined + * descriptive test for this WebTest. + * + * @param {boolean} [webTestDefinition.enabled] Is the test actively being + * monitored. + * + * @param {number} [webTestDefinition.frequency] Interval in seconds between + * test runs for this WebTest. Default value is 300. + * + * @param {number} [webTestDefinition.timeout] Seconds until this WebTest will + * timeout and fail. Default value is 30. + * + * @param {string} webTestDefinition.webTestKind The kind of web test this is, + * valid choices are ping and multistep. Possible values include: 'ping', + * 'multistep' + * + * @param {boolean} [webTestDefinition.retryEnabled] Allow for retries should + * this WebTest fail. + * + * @param {array} webTestDefinition.locations A list of where to physically run + * the tests from to give global coverage for accessibility of your + * application. + * + * @param {object} [webTestDefinition.configuration] An XML configuration + * specification for a WebTest. + * + * @param {string} [webTestDefinition.configuration.webTest] The XML + * specification of a WebTest to run against an application. + * + * @param {string} webTestDefinition.location Resource location + * + * @param {object} [webTestDefinition.tags] Resource tags + * + * @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 {WebTest} - 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 WebTest} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName, webTestName, webTestDefinition, 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._createOrUpdate(resourceGroupName, webTestName, webTestDefinition, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, webTestName, webTestDefinition, options, optionalCallback); + } + } + + /** + * Creates or updates an Application Insights web test definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} webTestName The name of the Application Insights webtest + * resource. + * + * @param {object} webTestTags Updated tag information to set into the web test + * instance. + * + * @param {object} [webTestTags.tags] Resource tags + * + * @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. + */ + updateTagsWithHttpOperationResponse(resourceGroupName, webTestName, webTestTags, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._updateTags(resourceGroupName, webTestName, webTestTags, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Creates or updates an Application Insights web test definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} webTestName The name of the Application Insights webtest + * resource. + * + * @param {object} webTestTags Updated tag information to set into the web test + * instance. + * + * @param {object} [webTestTags.tags] Resource tags + * + * @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 {WebTest} - 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 WebTest} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + updateTags(resourceGroupName, webTestName, webTestTags, 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._updateTags(resourceGroupName, webTestName, webTestTags, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._updateTags(resourceGroupName, webTestName, webTestTags, options, optionalCallback); + } + } + + /** + * Deletes an Application Insights web test. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} webTestName The name of the Application Insights webtest + * resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, webTestName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, webTestName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Deletes an Application Insights web test. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} webTestName The name of the Application Insights webtest + * resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {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, webTestName, 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, webTestName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, webTestName, options, optionalCallback); + } + } + + /** + * Get all Application Insights web test alerts definitioned within a + * subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get all Application Insights web test alerts definitioned within a + * subscription. + * + * @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 {WebTestListResult} - 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 WebTestListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(options, optionalCallback); + } + } + + /** + * Get all Application Insights web tests defined within a specified resource + * group. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByResourceGroupNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByResourceGroupNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get all Application Insights web tests defined within a specified resource + * group. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {WebTestListResult} - 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 WebTestListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByResourceGroupNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByResourceGroupNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByResourceGroupNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Get all Application Insights web test alerts definitioned within a + * subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get all Application Insights web test alerts definitioned within a + * subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {WebTestListResult} - 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 WebTestListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = WebTests; diff --git a/lib/services/applicationinsights/lib/lib/operations/workItemConfigurations.js b/lib/services/applicationinsights/lib/lib/operations/workItemConfigurations.js new file mode 100644 index 0000000000..12cf0121a1 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/operations/workItemConfigurations.js @@ -0,0 +1,1067 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets the list work item configurations that exist for the application + * + * @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 {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, 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 (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}/WorkItemConfigs'; + 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('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['WorkItemConfigurationError']().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: 'WorkItemConfigurationElementType', + type: { + name: 'Composite', + className: 'WorkItemConfiguration' + } + } + } + }; + 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 work item configuration for 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} workItemConfigurationProperties Properties that need to be + * specified to create a work item configuration of a Application Insights + * component. + * + * @param {string} [workItemConfigurationProperties.connectorId] Unique + * connector id + * + * @param {string} [workItemConfigurationProperties.connectorDataConfiguration] + * Serialized JSON object for detaile d properties + * + * @param {boolean} [workItemConfigurationProperties.validateOnly] Boolean + * indicating validate only + * + * @param {string} [workItemConfigurationProperties.workItemProperties] Custom + * work item properties + * + * @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 WorkItemConfiguration} for more information. + * + * {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, workItemConfigurationProperties, 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 (workItemConfigurationProperties === null || workItemConfigurationProperties === undefined) { + throw new Error('workItemConfigurationProperties 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}/WorkItemConfigs'; + 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('&'); + } + + // 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 (workItemConfigurationProperties !== null && workItemConfigurationProperties !== undefined) { + let requestModelMapper = new client.models['WorkItemCreateConfiguration']().mapper(); + requestModel = client.serialize(requestModelMapper, workItemConfigurationProperties, 'workItemConfigurationProperties'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(workItemConfigurationProperties, 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['WorkItemConfiguration']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets default work item configurations that exist for the application + * + * @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 {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 WorkItemConfiguration} for more information. + * + * {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 _getDefault(resourceGroupName, resourceName, 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 (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}/DefaultWorkItemConfig'; + 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('&'); + } + + // 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['WorkItemConfiguration']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Delete an workitem configuration of 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} workItemConfigId The unique work item configuration Id. This + * can be either friendly name of connector as defined in connector + * configuration + * + * @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. + * + * {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, workItemConfigId, 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 (workItemConfigId === null || workItemConfigId === undefined || typeof workItemConfigId.valueOf() !== 'string') { + throw new Error('workItemConfigId 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}/WorkItemConfigs/{workItemConfigId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); + requestUrl = requestUrl.replace('{workItemConfigId}', encodeURIComponent(workItemConfigId)); + 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; + // 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: 'Object' + } + }; + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a WorkItemConfigurations. */ +class WorkItemConfigurations { + /** + * Create a WorkItemConfigurations. + * @param {ApplicationInsightsManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._create = _create; + this._getDefault = _getDefault; + this._deleteMethod = _deleteMethod; + } + + /** + * Gets the list work item configurations that exist for the application + * + * @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 {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 the list work item configurations that exist for the application + * + * @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 {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); + } + } + + /** + * Create a work item configuration for 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} workItemConfigurationProperties Properties that need to be + * specified to create a work item configuration of a Application Insights + * component. + * + * @param {string} [workItemConfigurationProperties.connectorId] Unique + * connector id + * + * @param {string} [workItemConfigurationProperties.connectorDataConfiguration] + * Serialized JSON object for detaile d properties + * + * @param {boolean} [workItemConfigurationProperties.validateOnly] Boolean + * indicating validate only + * + * @param {string} [workItemConfigurationProperties.workItemProperties] Custom + * work item properties + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createWithHttpOperationResponse(resourceGroupName, resourceName, workItemConfigurationProperties, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._create(resourceGroupName, resourceName, workItemConfigurationProperties, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Create a work item configuration for 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} workItemConfigurationProperties Properties that need to be + * specified to create a work item configuration of a Application Insights + * component. + * + * @param {string} [workItemConfigurationProperties.connectorId] Unique + * connector id + * + * @param {string} [workItemConfigurationProperties.connectorDataConfiguration] + * Serialized JSON object for detaile d properties + * + * @param {boolean} [workItemConfigurationProperties.validateOnly] Boolean + * indicating validate only + * + * @param {string} [workItemConfigurationProperties.workItemProperties] Custom + * work item properties + * + * @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 {WorkItemConfiguration} - 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 WorkItemConfiguration} for more information. + * + * {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, workItemConfigurationProperties, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._create(resourceGroupName, resourceName, workItemConfigurationProperties, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._create(resourceGroupName, resourceName, workItemConfigurationProperties, options, optionalCallback); + } + } + + /** + * Gets default work item configurations that exist for the application + * + * @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 {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. + */ + getDefaultWithHttpOperationResponse(resourceGroupName, resourceName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._getDefault(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 default work item configurations that exist for the application + * + * @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 {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 {WorkItemConfiguration} - 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 WorkItemConfiguration} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + getDefault(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._getDefault(resourceGroupName, resourceName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._getDefault(resourceGroupName, resourceName, options, optionalCallback); + } + } + + /** + * Delete an workitem configuration of 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} workItemConfigId The unique work item configuration Id. This + * can be either friendly name of connector as defined in connector + * configuration + * + * @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, workItemConfigId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, resourceName, workItemConfigId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Delete an workitem configuration of 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} workItemConfigId The unique work item configuration Id. This + * can be either friendly name of connector as defined in connector + * configuration + * + * @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 {Object} - 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. + * + * {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, workItemConfigId, 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, workItemConfigId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, resourceName, workItemConfigId, options, optionalCallback); + } + } + +} + +module.exports = WorkItemConfigurations; diff --git a/lib/services/applicationinsights/lib/lib/operations/workbookOperations.js b/lib/services/applicationinsights/lib/lib/operations/workbookOperations.js new file mode 100644 index 0000000000..bc273d8528 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/operations/workbookOperations.js @@ -0,0 +1,1542 @@ +/* + * 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; + +/** + * Delete a workbook. + * + * @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 + * 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, location, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (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 (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}/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('&'); + } + + // 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 !== 201 && statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['WorkbookError']().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); + }); +} + +/** + * 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} 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. + * + * @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 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 _createOrUpdate(resourceGroupName, resourceName, workbookProperties, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (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 (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.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + 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('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 (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) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['WorkbookError']().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['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); + } + } + // 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); + }); +} + +/** + * 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 {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. + * + * @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 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 _update(resourceGroupName, resourceName, workbookProperties, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (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 (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.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + 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('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 (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) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['WorkbookError']().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['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); + }); +} + +/** + * Get a single workbook by its resourceName. + * + * @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 + * 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 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 _get(resourceName, location, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (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 (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/microsoft.insights/workbooks/{resourceName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + 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('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['WorkbookError']().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['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); + }); +} + +/** + * Gets a list of workbooks by sourceId. + * + * @param {string} sourceId Azure Resource Id that will fetch all linked + * workbooks. + * + * @param {string} category Category of workbook to return. Possible values + * include: 'workbook', 'TSG', 'performance', 'retention' + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.tags] Tags presents on each workbook returned. + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable workbook. If false, only return + * summary content for workbooks. + * + * @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(sourceId, category, 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 tags = (options && options.tags !== undefined) ? options.tags : undefined; + let canFetchContent = (options && options.canFetchContent !== undefined) ? options.canFetchContent : 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 (sourceId === null || sourceId === undefined || typeof sourceId.valueOf() !== 'string') { + throw new Error('sourceId 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.'); + } + if (Array.isArray(tags)) { + for (let i = 0; i < tags.length; i++) { + if (tags[i] !== null && tags[i] !== undefined && typeof tags[i].valueOf() !== 'string') { + throw new Error('tags[i] must be of type string.'); + } + } + } + if (canFetchContent !== null && canFetchContent !== undefined && typeof canFetchContent !== 'boolean') { + throw new Error('canFetchContent must be of type boolean.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/microsoft.insights/workbooks'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('sourceId=' + encodeURIComponent(sourceId)); + queryParameters.push('category=' + encodeURIComponent(category)); + if (tags !== null && tags !== undefined) { + queryParameters.push('tags=' + encodeURIComponent(tags.join(','))); + } + if (canFetchContent !== null && canFetchContent !== undefined) { + queryParameters.push('canFetchContent=' + encodeURIComponent(canFetchContent.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['WorkbookError']().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: 'WorkbookElementType', + type: { + name: 'Composite', + className: 'Workbook' + } + } + } + }; + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a WorkbookOperations. */ +class WorkbookOperations { + /** + * Create a WorkbookOperations. + * @param {ApplicationInsightsManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._deleteMethod = _deleteMethod; + this._createOrUpdate = _createOrUpdate; + this._update = _update; + this._get = _get; + this._list = _list; + } + + /** + * Delete a workbook. + * + * @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 + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, resourceName, location, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, resourceName, location, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Delete a workbook. + * + * @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 + * 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, location, 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, location, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, resourceName, location, options, optionalCallback); + } + } + + /** + * 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} 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. + * + * @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. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName, resourceName, workbookProperties, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, resourceName, workbookProperties, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * 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} 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. + * + * @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 {Workbook} - 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 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. + */ + createOrUpdate(resourceGroupName, resourceName, workbookProperties, 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._createOrUpdate(resourceGroupName, resourceName, workbookProperties, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, resourceName, workbookProperties, options, optionalCallback); + } + } + + /** + * 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 {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. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName, resourceName, workbookProperties, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(resourceGroupName, resourceName, workbookProperties, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * 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 {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. + * + * @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 {Workbook} - 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 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. + */ + update(resourceGroupName, resourceName, workbookProperties, 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, workbookProperties, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(resourceGroupName, resourceName, workbookProperties, options, optionalCallback); + } + } + + /** + * Get a single workbook by its resourceName. + * + * @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 + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceName, location, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceName, location, 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 workbook by its resourceName. + * + * @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 + * 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 {Workbook} - 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 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. + */ + get(resourceName, location, 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(resourceName, location, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceName, location, options, optionalCallback); + } + } + + /** + * Gets a list of workbooks by sourceId. + * + * @param {string} sourceId Azure Resource Id that will fetch all linked + * workbooks. + * + * @param {string} category Category of workbook to return. Possible values + * include: 'workbook', 'TSG', 'performance', 'retention' + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.tags] Tags presents on each workbook returned. + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable workbook. If false, only return + * summary content for workbooks. + * + * @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(sourceId, category, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(sourceId, category, 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 workbooks by sourceId. + * + * @param {string} sourceId Azure Resource Id that will fetch all linked + * workbooks. + * + * @param {string} category Category of workbook to return. Possible values + * include: 'workbook', 'TSG', 'performance', 'retention' + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.tags] Tags presents on each workbook returned. + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable workbook. If false, only return + * summary content for workbooks. + * + * @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(sourceId, category, 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(sourceId, category, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(sourceId, category, options, optionalCallback); + } + } + +} + +module.exports = WorkbookOperations; diff --git a/lib/services/applicationinsights/lib/lib/operations/workbooks.js b/lib/services/applicationinsights/lib/lib/operations/workbooks.js new file mode 100644 index 0000000000..efbad01641 --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/operations/workbooks.js @@ -0,0 +1,2767 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Get all Workbooks defined within a specified resource group and category. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} location The name of location where workbook is stored. + * + * @param {string} category Category of workbook to return. Possible values + * include: 'workbook', 'TSG', 'performance', 'retention' + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.tags] Tags presents on each workbook returned. + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable workbook. If false, only return + * summary content for workbooks. + * + * @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 WorkbookListResult} for more information. + * + * {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(resourceGroupName, location, category, 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 tags = (options && options.tags !== undefined) ? options.tags : undefined; + let canFetchContent = (options && options.canFetchContent !== undefined) ? options.canFetchContent : 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 (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 (category === null || category === undefined || typeof category.valueOf() !== 'string') { + throw new Error('category cannot be null or undefined and it must be of type string.'); + } + if (Array.isArray(tags)) { + for (let i = 0; i < tags.length; i++) { + if (tags[i] !== null && tags[i] !== undefined && typeof tags[i].valueOf() !== 'string') { + throw new Error('tags[i] must be of type string.'); + } + } + } + if (canFetchContent !== null && canFetchContent !== undefined && typeof canFetchContent !== 'boolean') { + throw new Error('canFetchContent must be of type boolean.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/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(','))); + } + if (canFetchContent !== null && canFetchContent !== undefined) { + queryParameters.push('canFetchContent=' + encodeURIComponent(canFetchContent.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['WorkbookErrorResponse']().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['WorkbookListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Delete a workbook. + * + * @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 + * 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, location, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (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 (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}/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('&'); + } + + // 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 && statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['WorkbookErrorResponse']().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); + }); +} + +/** + * 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} 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. + * + * @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 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 _create(resourceGroupName, resourceName, workbookProperties, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (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 (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.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + 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('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 (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) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['WorkbookErrorResponse']().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['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. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @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. + * + * @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 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 _update(resourceGroupName, resourceName, workbookProperties, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (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 (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.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + 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('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 (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) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['WorkbookErrorResponse']().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['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); + }); +} + +/** + * Get a single workbook by its resourceName. + * + * @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 + * 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 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 _get(resourceName, location, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (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 (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/microsoft.insights/workbooks/{resourceName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + 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('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['WorkbookErrorResponse']().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['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); + }); +} + +/** + * Gets a list of workbooks. + * + * @param {string} sourceId Azure Resource Id that will fetch all linked + * workbooks. + * + * @param {string} category Category of workbook to return. Possible values + * include: 'workbook', 'TSG', 'performance', 'retention' + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.tags] Tags presents on each workbook returned. + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable workbook. If false, only return + * summary content for workbooks. + * + * @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(sourceId, category, 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 tags = (options && options.tags !== undefined) ? options.tags : undefined; + let canFetchContent = (options && options.canFetchContent !== undefined) ? options.canFetchContent : 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 (sourceId === null || sourceId === undefined || typeof sourceId.valueOf() !== 'string') { + throw new Error('sourceId 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.'); + } + if (Array.isArray(tags)) { + for (let i = 0; i < tags.length; i++) { + if (tags[i] !== null && tags[i] !== undefined && typeof tags[i].valueOf() !== 'string') { + throw new Error('tags[i] must be of type string.'); + } + } + } + if (canFetchContent !== null && canFetchContent !== undefined && typeof canFetchContent !== 'boolean') { + throw new Error('canFetchContent must be of type boolean.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/microsoft.insights/workbooks/links'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('sourceId=' + encodeURIComponent(sourceId)); + queryParameters.push('category=' + encodeURIComponent(category)); + if (tags !== null && tags !== undefined) { + queryParameters.push('tags=' + encodeURIComponent(tags.join(','))); + } + if (canFetchContent !== null && canFetchContent !== undefined) { + queryParameters.push('canFetchContent=' + encodeURIComponent(canFetchContent.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['WorkbookErrorResponse']().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: 'WorkbookElementType', + type: { + name: 'Composite', + className: 'Workbook' + } + } + } + }; + 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 link. + * + * @param {object} linkProperties Properties that need to be specified to + * create a workbook link. + * + * @param {string} [linkProperties.sourceId] The source Azure resource id + * + * @param {string} [linkProperties.targetId] The workbook Azure resource id + * + * @param {string} [linkProperties.category] The category of workbook + * + * @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 _createLink(linkProperties, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (linkProperties === null || linkProperties === undefined) { + throw new Error('linkProperties 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}/providers/microsoft.insights/workbooks/links'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = '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 (linkProperties !== null && linkProperties !== undefined) { + let requestModelMapper = new client.models['LinkProperties']().mapper(); + requestModel = client.serialize(requestModelMapper, linkProperties, 'linkProperties'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(linkProperties, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['WorkbookErrorResponse']().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); + }); +} + +/** + * Updates a workbook that has already been added. + * + * @param {object} linkProperties Properties that need to be specified to + * create a workbook link. + * + * @param {string} [linkProperties.sourceId] The source Azure resource id + * + * @param {string} [linkProperties.targetId] The workbook Azure resource id + * + * @param {string} [linkProperties.category] The category of workbook + * + * @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 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 _updateLink(linkProperties, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (linkProperties === null || linkProperties === undefined) { + throw new Error('linkProperties 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}/providers/microsoft.insights/workbooks/links'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = '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 (linkProperties !== null && linkProperties !== undefined) { + let requestModelMapper = new client.models['LinkProperties']().mapper(); + requestModel = client.serialize(requestModelMapper, linkProperties, 'linkProperties'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(linkProperties, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['WorkbookErrorResponse']().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['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); + }); +} + +/** + * Delete a link between a source resource and workbook resource. + * + * @param {string} resourceId Azure Resource Id or any target workbook resource + * id. + * + * @param {string} category Category of workbook to return. Possible values + * include: 'workbook', 'TSG', 'performance', 'retention' + * + * @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 _deleteLink(resourceId, category, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (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 (category === null || category === undefined || typeof category.valueOf() !== 'string') { + throw new Error('category cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/microsoft.insights/workbooks/links'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('resourceId=' + encodeURIComponent(resourceId)); + queryParameters.push('category=' + encodeURIComponent(category)); + 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 && statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['WorkbookErrorResponse']().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); + }); +} + +/** + * Gets a workbook link by a workbook resource name. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable workbook. If false, only return + * summary content for workbooks. + * + * @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 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 _listBySourceId(resourceName, 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 canFetchContent = (options && options.canFetchContent !== undefined) ? options.canFetchContent : 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 (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 (canFetchContent !== null && canFetchContent !== undefined && typeof canFetchContent !== 'boolean') { + throw new Error('canFetchContent must be of type boolean.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/microsoft.insights/workbooks/{resourceName}/links'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName)); + let queryParameters = []; + if (canFetchContent !== null && canFetchContent !== undefined) { + queryParameters.push('canFetchContent=' + encodeURIComponent(canFetchContent.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['WorkbookErrorResponse']().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['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); + }); +} + +/** Class representing a Workbooks. */ +class Workbooks { + /** + * Create a Workbooks. + * @param {ApplicationInsightsManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._listByResourceGroup = _listByResourceGroup; + this._deleteMethod = _deleteMethod; + this._create = _create; + this._update = _update; + this._get = _get; + this._list = _list; + this._createLink = _createLink; + this._updateLink = _updateLink; + this._deleteLink = _deleteLink; + this._listBySourceId = _listBySourceId; + } + + /** + * Get all Workbooks defined within a specified resource group and category. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} location The name of location where workbook is stored. + * + * @param {string} category Category of workbook to return. Possible values + * include: 'workbook', 'TSG', 'performance', 'retention' + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.tags] Tags presents on each workbook returned. + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable workbook. If false, only return + * summary content for workbooks. + * + * @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. + */ + listByResourceGroupWithHttpOperationResponse(resourceGroupName, location, category, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByResourceGroup(resourceGroupName, location, category, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get all Workbooks defined within a specified resource group and category. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} location The name of location where workbook is stored. + * + * @param {string} category Category of workbook to return. Possible values + * include: 'workbook', 'TSG', 'performance', 'retention' + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.tags] Tags presents on each workbook returned. + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable workbook. If false, only return + * summary content for workbooks. + * + * @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 {WorkbookListResult} - 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 WorkbookListResult} for more information. + * + * {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(resourceGroupName, location, category, 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._listByResourceGroup(resourceGroupName, location, category, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByResourceGroup(resourceGroupName, location, category, options, optionalCallback); + } + } + + /** + * Delete a workbook. + * + * @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 + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, resourceName, location, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, resourceName, location, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Delete a workbook. + * + * @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 + * 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, location, 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, location, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, resourceName, location, options, optionalCallback); + } + } + + /** + * 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} 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. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createWithHttpOperationResponse(resourceGroupName, resourceName, workbookProperties, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._create(resourceGroupName, resourceName, workbookProperties, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * 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} 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. + * + * @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 {Workbook} - 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 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. + */ + create(resourceGroupName, resourceName, workbookProperties, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._create(resourceGroupName, resourceName, workbookProperties, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._create(resourceGroupName, resourceName, workbookProperties, options, optionalCallback); + } + } + + /** + * 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 {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. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName, resourceName, workbookProperties, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(resourceGroupName, resourceName, workbookProperties, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * 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 {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. + * + * @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 {Workbook} - 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 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. + */ + update(resourceGroupName, resourceName, workbookProperties, 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, workbookProperties, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(resourceGroupName, resourceName, workbookProperties, options, optionalCallback); + } + } + + /** + * Get a single workbook by its resourceName. + * + * @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 + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceName, location, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceName, location, 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 workbook by its resourceName. + * + * @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 + * 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 {Workbook} - 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 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. + */ + get(resourceName, location, 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(resourceName, location, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceName, location, options, optionalCallback); + } + } + + /** + * Gets a list of workbooks. + * + * @param {string} sourceId Azure Resource Id that will fetch all linked + * workbooks. + * + * @param {string} category Category of workbook to return. Possible values + * include: 'workbook', 'TSG', 'performance', 'retention' + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.tags] Tags presents on each workbook returned. + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable workbook. If false, only return + * summary content for workbooks. + * + * @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(sourceId, category, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(sourceId, category, 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 workbooks. + * + * @param {string} sourceId Azure Resource Id that will fetch all linked + * workbooks. + * + * @param {string} category Category of workbook to return. Possible values + * include: 'workbook', 'TSG', 'performance', 'retention' + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.tags] Tags presents on each workbook returned. + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable workbook. If false, only return + * summary content for workbooks. + * + * @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(sourceId, category, 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(sourceId, category, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(sourceId, category, options, optionalCallback); + } + } + + /** + * Create a new workbook link. + * + * @param {object} linkProperties Properties that need to be specified to + * create a workbook link. + * + * @param {string} [linkProperties.sourceId] The source Azure resource id + * + * @param {string} [linkProperties.targetId] The workbook Azure resource id + * + * @param {string} [linkProperties.category] The category of workbook + * + * @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. + */ + createLinkWithHttpOperationResponse(linkProperties, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createLink(linkProperties, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Create a new workbook link. + * + * @param {object} linkProperties Properties that need to be specified to + * create a workbook link. + * + * @param {string} [linkProperties.sourceId] The source Azure resource id + * + * @param {string} [linkProperties.targetId] The workbook Azure resource id + * + * @param {string} [linkProperties.category] The category of workbook + * + * @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 {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. + */ + createLink(linkProperties, 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._createLink(linkProperties, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createLink(linkProperties, options, optionalCallback); + } + } + + /** + * Updates a workbook that has already been added. + * + * @param {object} linkProperties Properties that need to be specified to + * create a workbook link. + * + * @param {string} [linkProperties.sourceId] The source Azure resource id + * + * @param {string} [linkProperties.targetId] The workbook Azure resource id + * + * @param {string} [linkProperties.category] The category of workbook + * + * @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. + */ + updateLinkWithHttpOperationResponse(linkProperties, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._updateLink(linkProperties, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Updates a workbook that has already been added. + * + * @param {object} linkProperties Properties that need to be specified to + * create a workbook link. + * + * @param {string} [linkProperties.sourceId] The source Azure resource id + * + * @param {string} [linkProperties.targetId] The workbook Azure resource id + * + * @param {string} [linkProperties.category] The category of workbook + * + * @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 {Workbook} - 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 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. + */ + updateLink(linkProperties, 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._updateLink(linkProperties, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._updateLink(linkProperties, options, optionalCallback); + } + } + + /** + * Delete a link between a source resource and workbook resource. + * + * @param {string} resourceId Azure Resource Id or any target workbook resource + * id. + * + * @param {string} category Category of workbook to return. Possible values + * include: 'workbook', 'TSG', 'performance', 'retention' + * + * @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. + */ + deleteLinkWithHttpOperationResponse(resourceId, category, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteLink(resourceId, category, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Delete a link between a source resource and workbook resource. + * + * @param {string} resourceId Azure Resource Id or any target workbook resource + * id. + * + * @param {string} category Category of workbook to return. Possible values + * include: 'workbook', 'TSG', 'performance', 'retention' + * + * @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 {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. + */ + deleteLink(resourceId, category, 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._deleteLink(resourceId, category, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteLink(resourceId, category, options, optionalCallback); + } + } + + /** + * Gets a workbook link by a workbook resource name. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable workbook. If false, only return + * summary content for workbooks. + * + * @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. + */ + listBySourceIdWithHttpOperationResponse(resourceName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listBySourceId(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 workbook link by a workbook resource name. + * + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable workbook. If false, only return + * summary content for workbooks. + * + * @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 {Workbook} - 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 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. + */ + listBySourceId(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._listBySourceId(resourceName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listBySourceId(resourceName, options, optionalCallback); + } + } + +} + +module.exports = Workbooks; diff --git a/lib/services/applicationinsights/lib/lib/operations/workbooksOperations.js b/lib/services/applicationinsights/lib/lib/operations/workbooksOperations.js new file mode 100644 index 0000000000..7e0c06433d --- /dev/null +++ b/lib/services/applicationinsights/lib/lib/operations/workbooksOperations.js @@ -0,0 +1,311 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Get all Workbooks defined within a specified resource group and category. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} location The name of location where workbook is stored. + * + * @param {string} category Category of workbook to return. Possible values + * include: 'workbook', 'TSG', 'performance', 'retention' + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.tags] Tags presents on each workbook returned. + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable workbook. If false, only return + * summary content for workbooks. + * + * @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 Workbooks} for more information. + * + * {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(resourceGroupName, location, category, 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 tags = (options && options.tags !== undefined) ? options.tags : undefined; + let canFetchContent = (options && options.canFetchContent !== undefined) ? options.canFetchContent : 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 (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 (category === null || category === undefined || typeof category.valueOf() !== 'string') { + throw new Error('category cannot be null or undefined and it must be of type string.'); + } + if (Array.isArray(tags)) { + for (let i = 0; i < tags.length; i++) { + if (tags[i] !== null && tags[i] !== undefined && typeof tags[i].valueOf() !== 'string') { + throw new Error('tags[i] must be of type string.'); + } + } + } + if (canFetchContent !== null && canFetchContent !== undefined && typeof canFetchContent !== 'boolean') { + throw new Error('canFetchContent must be of type boolean.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/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(','))); + } + if (canFetchContent !== null && canFetchContent !== undefined) { + queryParameters.push('canFetchContent=' + encodeURIComponent(canFetchContent.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['WorkbookError']().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['Workbooks']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a WorkbooksOperations. */ +class WorkbooksOperations { + /** + * Create a WorkbooksOperations. + * @param {ApplicationInsightsManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._listByResourceGroup = _listByResourceGroup; + } + + /** + * Get all Workbooks defined within a specified resource group and category. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} location The name of location where workbook is stored. + * + * @param {string} category Category of workbook to return. Possible values + * include: 'workbook', 'TSG', 'performance', 'retention' + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.tags] Tags presents on each workbook returned. + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable workbook. If false, only return + * summary content for workbooks. + * + * @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. + */ + listByResourceGroupWithHttpOperationResponse(resourceGroupName, location, category, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByResourceGroup(resourceGroupName, location, category, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get all Workbooks defined within a specified resource group and category. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} location The name of location where workbook is stored. + * + * @param {string} category Category of workbook to return. Possible values + * include: 'workbook', 'TSG', 'performance', 'retention' + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.tags] Tags presents on each workbook returned. + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable workbook. If false, only return + * summary content for workbooks. + * + * @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 {Workbooks} - 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 Workbooks} for more information. + * + * {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(resourceGroupName, location, category, 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._listByResourceGroup(resourceGroupName, location, category, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByResourceGroup(resourceGroupName, location, category, options, optionalCallback); + } + } + +} + +module.exports = WorkbooksOperations; 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/index.d.ts b/lib/services/applicationinsights/lib/models/index.d.ts index 4709787126..2e33a87dc4 100644 --- a/lib/services/applicationinsights/lib/models/index.d.ts +++ b/lib/services/applicationinsights/lib/models/index.d.ts @@ -1015,18 +1015,6 @@ export interface Workbook extends WorkbookResource { 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. @@ -1093,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. @@ -1117,6 +1115,16 @@ export interface ApplicationInsightsComponentListResult extends Array { +} + /** * @class * Initializes a new instance of the ApplicationInsightsWebTestLocationsListResult class. @@ -1141,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 47cebc05d9..155639f1bd 100644 --- a/lib/services/applicationinsights/lib/models/index.js +++ b/lib/services/applicationinsights/lib/models/index.js @@ -57,12 +57,14 @@ exports.ApplicationInsightsComponentAnalyticsItemProperties = require('./applica 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/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/workbookErrorResponse.js b/lib/services/applicationinsights/lib/models/workbookErrorResponse.js new file mode 100644 index 0000000000..0a296ab14b --- /dev/null +++ b/lib/services/applicationinsights/lib/models/workbookErrorResponse.js @@ -0,0 +1,80 @@ +/* + * 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'); + +/** + * Error message body that will indicate why the operation failed. + * + */ +class WorkbookErrorResponse { + /** + * Create a WorkbookErrorResponse. + * @member {string} [code] Service-defined error code. This code serves as a + * sub-status for the HTTP error code specified in the response. + * @member {string} [message] Human-readable representation of the error. + * @member {array} [details] The list of invalid fields send in request, in + * case of validation error. + */ + constructor() { + } + + /** + * Defines the metadata of WorkbookErrorResponse + * + * @returns {object} metadata of WorkbookErrorResponse + * + */ + mapper() { + return { + required: false, + serializedName: 'WorkbookErrorResponse', + type: { + name: 'Composite', + className: 'WorkbookErrorResponse', + modelProperties: { + code: { + required: false, + serializedName: 'code', + type: { + name: 'String' + } + }, + message: { + required: false, + serializedName: 'message', + type: { + name: 'String' + } + }, + details: { + required: false, + serializedName: 'details', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ErrorFieldContractElementType', + type: { + name: 'Composite', + className: 'ErrorFieldContract' + } + } + } + } + } + } + }; + } +} + +module.exports = WorkbookErrorResponse; diff --git a/lib/services/applicationinsights/lib/models/workbookListResult.js b/lib/services/applicationinsights/lib/models/workbookListResult.js new file mode 100644 index 0000000000..97cd6a85d0 --- /dev/null +++ b/lib/services/applicationinsights/lib/models/workbookListResult.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Workbook list result. + * + */ +class WorkbookListResult { + /** + * Create a WorkbookListResult. + * @member {array} [value] An array of workbooks. + */ + constructor() { + } + + /** + * Defines the metadata of WorkbookListResult + * + * @returns {object} metadata of WorkbookListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'WorkbookListResult', + type: { + name: 'Composite', + className: 'WorkbookListResult', + modelProperties: { + value: { + required: false, + serializedName: 'value', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'WorkbookElementType', + type: { + name: 'Composite', + className: 'Workbook' + } + } + } + } + } + } + }; + } +} + +module.exports = WorkbookListResult; diff --git a/lib/services/applicationinsights/lib/models/workbookPayload.js b/lib/services/applicationinsights/lib/models/workbookPayload.js new file mode 100644 index 0000000000..7731a3e848 --- /dev/null +++ b/lib/services/applicationinsights/lib/models/workbookPayload.js @@ -0,0 +1,94 @@ +/* + * 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'); + +/** + * This wraps either Workbook definition or LinkReource properties. + * + */ +class WorkbookPayload { + /** + * Create a WorkbookPayload. + * @member {object} [workbook] Workbook properties. If provided, it will be + * used to create new workbook. + * @member {string} [workbook.kind] The kind of workbook. Choices are user + * and shared. Possible values include: 'user', 'shared' + * @member {string} [workbook.workbookName] The user-defined name of the + * workbook. + * @member {string} [workbook.serializedData] Configuration of this + * particular workbook. Configuration data is a string containing valid JSON + * @member {string} [workbook.version] This instance's version of the data + * model. This can change as new features are added that can be marked + * workbook. + * @member {string} [workbook.workbookId] Internally assigned unique id of + * the workbook definition. + * @member {string} [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' + * @member {string} [workbook.timeModified] Date and time in UTC of the last + * modification that was made to this workbook definition. + * @member {string} [workbook.category] Workbook category, as defined by the + * user at creation time. + * @member {array} [workbook.workbookTags] A list of 0 or more tags that are + * associated with this workbook definition + * @member {string} [workbook.userId] Unique user id of the specific user + * that owns this workbook. + * @member {string} [workbook.sourceResourceId] Optional resourceId for a + * source resource. + * @member {object} [linkResource] LinkProperties. If provided, it will be + * used to create a link. + * @member {string} [linkResource.sourceId] The source Azure resource id + * @member {string} [linkResource.targetId] The workbook Azure resource id + * @member {string} [linkResource.category] The category of workbook + */ + constructor() { + } + + /** + * Defines the metadata of WorkbookPayload + * + * @returns {object} metadata of WorkbookPayload + * + */ + mapper() { + return { + required: false, + serializedName: 'WorkbookPayload', + type: { + name: 'Composite', + className: 'WorkbookPayload', + modelProperties: { + workbook: { + required: false, + serializedName: 'workbook', + type: { + name: 'Composite', + className: 'Workbook' + } + }, + linkResource: { + required: false, + serializedName: 'linkResource', + type: { + name: 'Composite', + className: 'LinkProperties' + } + } + } + } + }; + } +} + +module.exports = WorkbookPayload; 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/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 85da99467c..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; /** @@ -2630,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 @@ -2656,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. * @@ -2664,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; /** @@ -2994,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 { /** @@ -4179,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 { /** @@ -4582,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 { /** @@ -4610,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. @@ -4642,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. * @@ -4650,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; /** 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/websiteManagement2/lib/operations/provider.js b/lib/services/applicationinsights/lib/operations/workbooks.js similarity index 54% rename from lib/services/websiteManagement2/lib/operations/provider.js rename to lib/services/applicationinsights/lib/operations/workbooks.js index 064fc16469..dafde7819a 100644 --- a/lib/services/websiteManagement2/lib/operations/provider.js +++ b/lib/services/applicationinsights/lib/operations/workbooks.js @@ -15,14 +15,20 @@ const msRestAzure = require('ms-rest-azure'); const WebResource = msRest.WebResource; /** - * @summary Get available application frameworks and their versions + * Get all Workbooks defined within a specified resource group and category. * - * Get available application frameworks and their versions + * @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 {object} [options] Optional Parameters. * - * @param {string} [options.osTypeSelected] Possible values include: 'Windows', - * 'Linux' + * @param {array} [options.tags] Tags presents on each workbook returned. + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable workbook. If false, only return + * summary content for workbooks. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -34,14 +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 ApplicationStackCollection} 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 _getAvailableStacks(options, callback) { +function _listByResourceGroup(resourceGroupName, category, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -51,11 +56,28 @@ function _getAvailableStacks(options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } - let osTypeSelected = (options && options.osTypeSelected !== undefined) ? options.osTypeSelected : undefined; + let tags = (options && options.tags !== undefined) ? options.tags : undefined; + let canFetchContent = (options && options.canFetchContent !== undefined) ? options.canFetchContent : undefined; // Validate try { - if (osTypeSelected !== null && osTypeSelected !== undefined && typeof osTypeSelected.valueOf() !== 'string') { - throw new Error('osTypeSelected 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 (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.'); + } + if (Array.isArray(tags)) { + for (let i = 0; i < tags.length; i++) { + if (tags[i] !== null && tags[i] !== undefined && typeof tags[i].valueOf() !== 'string') { + throw new Error('tags[i] must be of type string.'); + } + } + } + if (canFetchContent !== null && canFetchContent !== undefined && typeof canFetchContent !== 'boolean') { + throw new Error('canFetchContent must be of type boolean.'); } 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.'); @@ -69,10 +91,16 @@ function _getAvailableStacks(options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Web/availableStacks'; + 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 = []; - if (osTypeSelected !== null && osTypeSelected !== undefined) { - queryParameters.push('osTypeSelected=' + encodeURIComponent(osTypeSelected)); + queryParameters.push('category=' + encodeURIComponent(category)); + if (tags !== null && tags !== undefined) { + queryParameters.push('tags=' + encodeURIComponent(tags.join(','))); + } + if (canFetchContent !== null && canFetchContent !== undefined) { + queryParameters.push('canFetchContent=' + encodeURIComponent(canFetchContent.toString())); } queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); if (queryParameters.length > 0) { @@ -122,7 +150,7 @@ function _getAvailableStacks(options, callback) { error.message = internalError ? internalError.message : parsedErrorResponse.message; } if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['DefaultErrorResponse']().mapper(); + let resultMapper = new client.models['WorkbookError']().mapper(); error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); } } catch (defaultError) { @@ -142,7 +170,7 @@ function _getAvailableStacks(options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['ApplicationStackCollection']().mapper(); + let resultMapper = new client.models['WorkbooksListResult']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -158,11 +186,12 @@ function _getAvailableStacks(options, callback) { } /** - * @summary Gets all available operations for the Microsoft.Web resource - * provider. Also exposes resource metric definitions + * Get a single workbook by its resourceName. + * + * @param {string} resourceGroupName The name of the resource group. * - * Gets all available operations for the Microsoft.Web resource provider. Also - * exposes resource metric definitions + * @param {string} resourceName The name of the Application Insights component + * resource. * * @param {object} [options] Optional Parameters. * @@ -176,14 +205,13 @@ function _getAvailableStacks(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 CsmOperationCollection} for more - * information. + * 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 _listOperations(options, callback) { +function _get(resourceGroupName, resourceName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -195,6 +223,15 @@ function _listOperations(options, callback) { } // 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 (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.'); } @@ -207,7 +244,10 @@ function _listOperations(options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Web/operations'; + 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('api-version=' + encodeURIComponent(this.client.apiVersion)); if (queryParameters.length > 0) { @@ -257,7 +297,7 @@ function _listOperations(options, callback) { error.message = internalError ? internalError.message : parsedErrorResponse.message; } if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['DefaultErrorResponse']().mapper(); + let resultMapper = new client.models['WorkbookError']().mapper(); error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); } } catch (defaultError) { @@ -277,7 +317,7 @@ function _listOperations(options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['CsmOperationCollection']().mapper(); + let resultMapper = new client.models['Workbook']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -293,14 +333,14 @@ function _listOperations(options, callback) { } /** - * @summary Get available application frameworks and their versions + * Delete a workbook. * - * Get available application frameworks and their versions + * @param {string} resourceGroupName The name of the resource group. * - * @param {object} [options] Optional Parameters. + * @param {string} resourceName The name of the Application Insights component + * resource. * - * @param {string} [options.osTypeSelected] Possible values include: 'Windows', - * 'Linux' + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -311,15 +351,13 @@ function _listOperations(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 ApplicationStackCollection} 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 _getAvailableStacksOnPrem(options, callback) { +function _deleteMethod(resourceGroupName, resourceName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -329,15 +367,17 @@ function _getAvailableStacksOnPrem(options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } - let osTypeSelected = (options && options.osTypeSelected !== undefined) ? options.osTypeSelected : undefined; // Validate try { - if (osTypeSelected !== null && osTypeSelected !== undefined && typeof osTypeSelected.valueOf() !== 'string') { - throw new Error('osTypeSelected 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 (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 (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.'); } @@ -350,12 +390,11 @@ function _getAvailableStacksOnPrem(options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Web/availableStacks'; + 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 = []; - if (osTypeSelected !== null && osTypeSelected !== undefined) { - queryParameters.push('osTypeSelected=' + encodeURIComponent(osTypeSelected)); - } queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); @@ -363,7 +402,7 @@ function _getAvailableStacksOnPrem(options, callback) { // Create HTTP transport objects let httpRequest = new WebResource(); - httpRequest.method = 'GET'; + httpRequest.method = 'DELETE'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers @@ -388,7 +427,7 @@ function _getAvailableStacksOnPrem(options, callback) { 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); @@ -404,7 +443,7 @@ function _getAvailableStacksOnPrem(options, callback) { error.message = internalError ? internalError.message : parsedErrorResponse.message; } if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['DefaultErrorResponse']().mapper(); + let resultMapper = new client.models['WorkbookError']().mapper(); error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); } } catch (defaultError) { @@ -417,35 +456,58 @@ function _getAvailableStacksOnPrem(options, callback) { // 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['ApplicationStackCollection']().mapper(); - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); - return callback(deserializationError); - } - } return callback(null, result, httpRequest, response); }); } /** - * @summary Get available application frameworks and their versions + * 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} 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' * - * Get available application frameworks and their versions + * @param {string} workbookProperties.category Workbook category, as defined by + * the user at creation time. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @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. * @@ -459,14 +521,13 @@ function _getAvailableStacksOnPrem(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 ApplicationStackCollection} for more - * information. + * 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 _getAvailableStacksNext(nextPageLink, options, callback) { +function _createOrUpdate(resourceGroupName, resourceName, workbookProperties, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -478,8 +539,20 @@ function _getAvailableStacksNext(nextPageLink, options, callback) { } // Validate try { - if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { - throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + if (this.client.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 (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.'); @@ -489,12 +562,20 @@ function _getAvailableStacksNext(nextPageLink, options, callback) { } // Construct URL - let requestUrl = '{nextLink}'; - requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + let baseUrl = this.client.baseUri; + 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('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.method = 'PUT'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers @@ -512,14 +593,28 @@ function _getAvailableStacksNext(nextPageLink, 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) { 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); @@ -535,7 +630,7 @@ function _getAvailableStacksNext(nextPageLink, options, callback) { error.message = internalError ? internalError.message : parsedErrorResponse.message; } if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['DefaultErrorResponse']().mapper(); + let resultMapper = new client.models['WorkbookError']().mapper(); error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); } } catch (defaultError) { @@ -555,7 +650,7 @@ function _getAvailableStacksNext(nextPageLink, options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['ApplicationStackCollection']().mapper(); + let resultMapper = new client.models['Workbook']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -565,137 +660,21 @@ function _getAvailableStacksNext(nextPageLink, options, callback) { return callback(deserializationError); } } - - return callback(null, result, httpRequest, response); - }); -} - -/** - * @summary Gets all available operations for the Microsoft.Web resource - * provider. Also exposes resource metric definitions - * - * Gets all available operations for the Microsoft.Web resource provider. Also - * exposes resource metric definitions - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link CsmOperationCollection} for more - * information. - * - * {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 _listOperationsNext(nextPageLink, options, callback) { - /* jshint validthis: true */ - let client = this.client; - if(!callback && typeof options === 'function') { - callback = options; - options = null; - } - if (!callback) { - throw new Error('callback cannot be null.'); - } - // Validate - try { - if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { - throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); - } - if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { - throw new Error('this.client.acceptLanguage must be of type string.'); - } - } catch (error) { - return callback(error); - } - - // Construct URL - let requestUrl = '{nextLink}'; - requestUrl = requestUrl.replace('{nextLink}', nextPageLink); - - // Create HTTP transport objects - let httpRequest = new WebResource(); - httpRequest.method = 'GET'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; - if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - } - if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { - httpRequest.headers['accept-language'] = this.client.acceptLanguage; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - httpRequest.body = null; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - let internalError = null; - if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; - error.code = internalError ? internalError.code : parsedErrorResponse.code; - error.message = internalError ? internalError.message : parsedErrorResponse.message; - } - if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['DefaultErrorResponse']().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) { + 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['CsmOperationCollection']().mapper(); + 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); + 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); } } @@ -704,12 +683,52 @@ function _listOperationsNext(nextPageLink, options, callback) { } /** - * @summary Get available application frameworks and their versions + * Updates a workbook that has already been added. * - * Get available application frameworks and their versions + * @param {string} resourceGroupName The name of the resource group. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} resourceName The name of the Application Insights component + * resource. + * + * @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. * @@ -723,14 +742,13 @@ function _listOperationsNext(nextPageLink, 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 ApplicationStackCollection} for more - * information. + * 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 _getAvailableStacksOnPremNext(nextPageLink, options, callback) { +function _update(resourceGroupName, resourceName, workbookProperties, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -742,8 +760,20 @@ function _getAvailableStacksOnPremNext(nextPageLink, options, callback) { } // Validate try { - if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { - throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + if (this.client.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 (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.'); @@ -753,12 +783,20 @@ function _getAvailableStacksOnPremNext(nextPageLink, options, callback) { } // Construct URL - let requestUrl = '{nextLink}'; - requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + let baseUrl = this.client.baseUri; + 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('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.method = 'PATCH'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers @@ -776,7 +814,21 @@ function _getAvailableStacksOnPremNext(nextPageLink, 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) { @@ -799,7 +851,7 @@ function _getAvailableStacksOnPremNext(nextPageLink, options, callback) { error.message = internalError ? internalError.message : parsedErrorResponse.message; } if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['DefaultErrorResponse']().mapper(); + let resultMapper = new client.models['WorkbookError']().mapper(); error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); } } catch (defaultError) { @@ -819,7 +871,7 @@ function _getAvailableStacksOnPremNext(nextPageLink, options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['ApplicationStackCollection']().mapper(); + let resultMapper = new client.models['Workbook']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -834,46 +886,51 @@ function _getAvailableStacksOnPremNext(nextPageLink, options, callback) { }); } -/** Class representing a Provider. */ -class Provider { +/** Class representing a Workbooks. */ +class Workbooks { /** - * Create a Provider. - * @param {WebSiteManagementClient} client Reference to the service client. + * Create a Workbooks. + * @param {ApplicationInsightsManagementClient} client Reference to the service client. */ constructor(client) { this.client = client; - this._getAvailableStacks = _getAvailableStacks; - this._listOperations = _listOperations; - this._getAvailableStacksOnPrem = _getAvailableStacksOnPrem; - this._getAvailableStacksNext = _getAvailableStacksNext; - this._listOperationsNext = _listOperationsNext; - this._getAvailableStacksOnPremNext = _getAvailableStacksOnPremNext; + this._listByResourceGroup = _listByResourceGroup; + this._get = _get; + this._deleteMethod = _deleteMethod; + this._createOrUpdate = _createOrUpdate; + this._update = _update; } /** - * @summary Get available application frameworks and their versions + * Get all Workbooks defined within a specified resource group and category. * - * Get available application frameworks and their versions + * @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 {object} [options] Optional Parameters. * - * @param {string} [options.osTypeSelected] Possible values include: 'Windows', - * 'Linux' + * @param {array} [options.tags] Tags presents on each workbook returned. + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable workbook. If false, only return + * summary content for workbooks. * * @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. */ - getAvailableStacksWithHttpOperationResponse(options) { + listByResourceGroupWithHttpOperationResponse(resourceGroupName, category, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._getAvailableStacks(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); } @@ -884,14 +941,20 @@ class Provider { } /** - * @summary Get available application frameworks and their versions + * Get all Workbooks defined within a specified resource group and category. * - * Get available application frameworks and their versions + * @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 {object} [options] Optional Parameters. * - * @param {string} [options.osTypeSelected] Possible values include: 'Windows', - * 'Linux' + * @param {array} [options.tags] Tags presents on each workbook returned. + * + * @param {boolean} [options.canFetchContent] Flag indicating whether or not to + * return the full content for each applicable workbook. If false, only return + * summary content for workbooks. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -903,7 +966,7 @@ class Provider { * * {Promise} A promise is returned * - * @resolve {ApplicationStackCollection} - The deserialized result object. + * @resolve {WorkbooksListResult} - The deserialized result object. * * @reject {Error} - The error object. * @@ -912,14 +975,13 @@ class Provider { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link ApplicationStackCollection} 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. */ - getAvailableStacks(options, optionalCallback) { + listByResourceGroup(resourceGroupName, category, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -928,23 +990,24 @@ class Provider { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._getAvailableStacks(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._getAvailableStacks(options, optionalCallback); + return self._listByResourceGroup(resourceGroupName, category, options, optionalCallback); } } /** - * @summary Gets all available operations for the Microsoft.Web resource - * provider. Also exposes resource metric definitions + * Get a single workbook by its resourceName. + * + * @param {string} resourceGroupName The name of the resource group. * - * Gets all available operations for the Microsoft.Web resource provider. Also - * exposes resource metric definitions + * @param {string} resourceName The name of the Application Insights component + * resource. * * @param {object} [options] Optional Parameters. * @@ -953,15 +1016,15 @@ class Provider { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ - listOperationsWithHttpOperationResponse(options) { + getWithHttpOperationResponse(resourceGroupName, resourceName, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._listOperations(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); } @@ -972,11 +1035,12 @@ class Provider { } /** - * @summary Gets all available operations for the Microsoft.Web resource - * provider. Also exposes resource metric definitions + * Get a single workbook by its resourceName. * - * Gets all available operations for the Microsoft.Web resource provider. Also - * exposes resource metric definitions + * @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. * @@ -990,7 +1054,7 @@ class Provider { * * {Promise} A promise is returned * - * @resolve {CsmOperationCollection} - The deserialized result object. + * @resolve {Workbook} - The deserialized result object. * * @reject {Error} - The error object. * @@ -999,14 +1063,13 @@ class Provider { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link CsmOperationCollection} for more - * information. + * 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. */ - listOperations(options, optionalCallback) { + get(resourceGroupName, resourceName, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -1015,41 +1078,41 @@ class Provider { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._listOperations(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._listOperations(options, optionalCallback); + return self._get(resourceGroupName, resourceName, options, optionalCallback); } } /** - * @summary Get available application frameworks and their versions + * Delete a workbook. * - * Get available application frameworks and their versions + * @param {string} resourceGroupName The name of the resource group. * - * @param {object} [options] Optional Parameters. + * @param {string} resourceName The name of the Application Insights component + * resource. * - * @param {string} [options.osTypeSelected] Possible values include: 'Windows', - * 'Linux' + * @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. */ - getAvailableStacksOnPremWithHttpOperationResponse(options) { + deleteMethodWithHttpOperationResponse(resourceGroupName, resourceName, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._getAvailableStacksOnPrem(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); } @@ -1060,14 +1123,14 @@ class Provider { } /** - * @summary Get available application frameworks and their versions + * Delete a workbook. * - * Get available application frameworks and their versions + * @param {string} resourceGroupName The name of the resource group. * - * @param {object} [options] Optional Parameters. + * @param {string} resourceName The name of the Application Insights component + * resource. * - * @param {string} [options.osTypeSelected] Possible values include: 'Windows', - * 'Linux' + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -1079,7 +1142,7 @@ class Provider { * * {Promise} A promise is returned * - * @resolve {ApplicationStackCollection} - The deserialized result object. + * @resolve {null} - The deserialized result object. * * @reject {Error} - The error object. * @@ -1087,15 +1150,13 @@ class Provider { * * {Error} err - The Error object if an error occurred, null otherwise. * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link ApplicationStackCollection} 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. */ - getAvailableStacksOnPrem(options, optionalCallback) { + deleteMethod(resourceGroupName, resourceName, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -1104,115 +1165,64 @@ class Provider { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._getAvailableStacksOnPrem(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._getAvailableStacksOnPrem(options, optionalCallback); + return self._deleteMethod(resourceGroupName, resourceName, options, optionalCallback); } } /** - * @summary Get available application frameworks and their versions - * - * Get available application frameworks and their versions - * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - getAvailableStacksNextWithHttpOperationResponse(nextPageLink, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._getAvailableStacksNext(nextPageLink, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * @summary Get available application frameworks and their versions + * Create a new workbook. * - * Get available application frameworks and their versions + * @param {string} resourceGroupName The name of the resource group. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} resourceName The name of the Application Insights component + * resource. * - * @param {object} [options] Optional Parameters. + * @param {object} workbookProperties Properties that need to be specified to + * create a new workbook. * - * @param {object} [options.customHeaders] Headers that will be added to the - * request + * @param {string} [workbookProperties.kind] The kind of workbook. Choices are + * user and shared. Possible values include: 'user', 'shared' * - * @param {function} [optionalCallback] - The optional callback. + * @param {string} workbookProperties.workbookName The user-defined name of the + * workbook. * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. + * @param {string} workbookProperties.serializedData Configuration of this + * particular workbook. Configuration data is a string containing valid JSON * - * {Promise} A promise is returned + * @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. * - * @resolve {ApplicationStackCollection} - The deserialized result object. + * @param {string} workbookProperties.workbookId Internally assigned unique id + * of the workbook definition. * - * @reject {Error} - The error object. + * @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' * - * {function} optionalCallback(err, result, request, response) + * @param {string} workbookProperties.category Workbook category, as defined by + * the user at creation time. * - * {Error} err - The Error object if an error occurred, null otherwise. + * @param {array} [workbookProperties.workbookTags] A list of 0 or more tags + * that are associated with this workbook definition * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link ApplicationStackCollection} for more - * information. + * @param {string} workbookProperties.userId Unique user id of the specific + * user that owns this workbook. * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - getAvailableStacksNext(nextPageLink, options, optionalCallback) { - let client = this.client; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._getAvailableStacksNext(nextPageLink, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._getAvailableStacksNext(nextPageLink, options, optionalCallback); - } - } - - /** - * @summary Gets all available operations for the Microsoft.Web resource - * provider. Also exposes resource metric definitions + * @param {string} [workbookProperties.sourceResourceId] Optional resourceId + * for a source resource. * - * Gets all available operations for the Microsoft.Web resource provider. Also - * exposes resource metric definitions + * @param {string} [workbookProperties.location] Resource location * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {object} [workbookProperties.tags] Resource tags * * @param {object} [options] Optional Parameters. * @@ -1221,15 +1231,15 @@ class Provider { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ - listOperationsNextWithHttpOperationResponse(nextPageLink, options) { + createOrUpdateWithHttpOperationResponse(resourceGroupName, resourceName, workbookProperties, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._listOperationsNext(nextPageLink, 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); } @@ -1240,14 +1250,52 @@ class Provider { } /** - * @summary Gets all available operations for the Microsoft.Web resource - * provider. Also exposes resource metric definitions + * 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} 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' * - * Gets all available operations for the Microsoft.Web resource provider. Also - * exposes resource metric definitions + * @param {string} workbookProperties.category Workbook category, as defined by + * the user at creation time. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @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. * @@ -1261,7 +1309,7 @@ class Provider { * * {Promise} A promise is returned * - * @resolve {CsmOperationCollection} - The deserialized result object. + * @resolve {Workbook} - The deserialized result object. * * @reject {Error} - The error object. * @@ -1270,14 +1318,13 @@ class Provider { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link CsmOperationCollection} for more - * information. + * 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. */ - listOperationsNext(nextPageLink, options, optionalCallback) { + createOrUpdate(resourceGroupName, resourceName, workbookProperties, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -1286,24 +1333,64 @@ class Provider { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._listOperationsNext(nextPageLink, 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._listOperationsNext(nextPageLink, options, optionalCallback); + return self._createOrUpdate(resourceGroupName, resourceName, workbookProperties, options, optionalCallback); } } /** - * @summary Get available application frameworks and their versions + * 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 {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 * - * Get available application frameworks and their versions + * @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} nextPageLink The NextLink from the previous successful call - * to List operation. + * @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. * @@ -1312,15 +1399,15 @@ class Provider { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ - getAvailableStacksOnPremNextWithHttpOperationResponse(nextPageLink, options) { + updateWithHttpOperationResponse(resourceGroupName, resourceName, workbookProperties, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._getAvailableStacksOnPremNext(nextPageLink, 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); } @@ -1331,12 +1418,52 @@ class Provider { } /** - * @summary Get available application frameworks and their versions + * 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 {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. * - * Get available application frameworks and their versions + * @param {string} [workbookProperties.location] Resource location * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {object} [workbookProperties.tags] Resource tags * * @param {object} [options] Optional Parameters. * @@ -1350,7 +1477,7 @@ class Provider { * * {Promise} A promise is returned * - * @resolve {ApplicationStackCollection} - The deserialized result object. + * @resolve {Workbook} - The deserialized result object. * * @reject {Error} - The error object. * @@ -1359,14 +1486,13 @@ class Provider { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link ApplicationStackCollection} for more - * information. + * 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. */ - getAvailableStacksOnPremNext(nextPageLink, options, optionalCallback) { + update(resourceGroupName, resourceName, workbookProperties, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -1375,17 +1501,17 @@ class Provider { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._getAvailableStacksOnPremNext(nextPageLink, 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._getAvailableStacksOnPremNext(nextPageLink, options, optionalCallback); + return self._update(resourceGroupName, resourceName, workbookProperties, options, optionalCallback); } } } -module.exports = Provider; +module.exports = Workbooks; diff --git a/lib/services/applicationinsights/lib/package.json b/lib/services/applicationinsights/lib/package.json new file mode 100644 index 0000000000..cdc3b356c8 --- /dev/null +++ b/lib/services/applicationinsights/lib/package.json @@ -0,0 +1,22 @@ +{ + "name": "azure-arm-appinsights", + "author": "Microsoft Corporation", + "description": "ApplicationInsightsManagementClient Library with typescript type definitions for node", + "version": "", + "dependencies": { + "ms-rest": "^2.3.2", + "ms-rest-azure": "^2.5.5" + }, + "keywords": [ "node", "azure" ], + "license": "MIT", + "main": "./lib/applicationInsightsManagementClient.js", + "types": "./lib/applicationInsightsManagementClient.d.ts", + "homepage": "http://github.com/azure/azure-sdk-for-node", + "repository": { + "type": "git", + "url": "https://github.com/azure/azure-sdk-for-node.git" + }, + "bugs": { + "url": "http://github.com/Azure/azure-sdk-for-node/issues" + } +} diff --git a/lib/services/applicationinsights/package-lock.json b/lib/services/applicationinsights/package-lock.json new file mode 100644 index 0000000000..6153c1541a --- /dev/null +++ b/lib/services/applicationinsights/package-lock.json @@ -0,0 +1,474 @@ +{ + "name": "azure-arm-appinsights", + "version": "2.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/node": { + "version": "8.10.22", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.22.tgz", + "integrity": "sha512-HCJ1dUJEQVFRekwBAlyv9pJ+2rzxq9uimSmsK2q7YDYMbXR3b4BXcO9rsN+36ZBwSWQ5BNh5o8xdZijDSonS5A==" + }, + "adal-node": { + "version": "0.1.28", + "resolved": "https://registry.npmjs.org/adal-node/-/adal-node-0.1.28.tgz", + "integrity": "sha1-RoxLs+u9lrEnBmn0ucuk4AZepIU=", + "requires": { + "@types/node": "^8.0.47", + "async": ">=0.6.0", + "date-utils": "*", + "jws": "3.x.x", + "request": ">= 2.52.0", + "underscore": ">= 1.3.1", + "uuid": "^3.1.0", + "xmldom": ">= 0.1.x", + "xpath.js": "~1.1.0" + } + }, + "ajv": { + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", + "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "requires": { + "co": "^4.6.0", + "fast-deep-equal": "^1.0.0", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.3.0" + } + }, + "asn1": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", + "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=" + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + }, + "async": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", + "integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==", + "requires": { + "lodash": "^4.14.0" + } + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" + }, + "aws4": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.7.0.tgz", + "integrity": "sha512-32NDda82rhwD9/JBCCkB+MRYDp0oSvlo2IL6rQWA10PQi7tDUM3eqMSltXmY+Oyl/7N3P3qNtAlv7X0d9bI28w==" + }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "optional": true, + "requires": { + "tweetnacl": "^0.14.3" + } + }, + "buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk=" + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" + }, + "combined-stream": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", + "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "date-utils": { + "version": "1.2.21", + "resolved": "https://registry.npmjs.org/date-utils/-/date-utils-1.2.21.tgz", + "integrity": "sha1-YfsWzcEnSzyayq/+n8ad+HIKK2Q=" + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "duplexer": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", + "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=" + }, + "ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "optional": true, + "requires": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, + "ecdsa-sig-formatter": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.10.tgz", + "integrity": "sha1-HFlQAPBKiJffuFAAiSoPTDOvhsM=", + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" + }, + "fast-deep-equal": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", + "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=" + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" + }, + "form-data": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", + "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "1.0.6", + "mime-types": "^2.1.12" + } + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" + }, + "har-validator": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", + "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", + "requires": { + "ajv": "^5.1.0", + "har-schema": "^2.0.0" + } + }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "optional": true + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" + }, + "json-schema-traverse": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", + "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + } + }, + "jwa": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.1.6.tgz", + "integrity": "sha512-tBO/cf++BUsJkYql/kBbJroKOgHWEigTKBAjjBEmrMGYd1QMBC74Hr4Wo2zCZw6ZrVhlJPvoMrkcOnlWR/DJfw==", + "requires": { + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.10", + "safe-buffer": "^5.0.1" + } + }, + "jws": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/jws/-/jws-3.1.5.tgz", + "integrity": "sha512-GsCSexFADNQUr8T5HPJvayTjvPIfoyJPtLQBwn5a4WZQchcrPMPMAWcC1AzJVRDKyD6ZPROPAxgv6rfHViO4uQ==", + "requires": { + "jwa": "^1.1.5", + "safe-buffer": "^5.0.1" + } + }, + "lodash": { + "version": "4.17.10", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", + "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" + }, + "mime-db": { + "version": "1.35.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.35.0.tgz", + "integrity": "sha512-JWT/IcCTsB0Io3AhWUMjRqucrHSPsSf2xKLaRldJVULioggvkJvggZ3VXNNSRkCddE6D+BUI4HEIZIA2OjwIvg==" + }, + "mime-types": { + "version": "2.1.19", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.19.tgz", + "integrity": "sha512-P1tKYHVSZ6uFo26mtnve4HQFE3koh1UWVkp8YUC+ESBHe945xWSoXuHHiGarDqcEZ+whpCDnlNw5LON0kLo+sw==", + "requires": { + "mime-db": "~1.35.0" + } + }, + "moment": { + "version": "2.22.2", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz", + "integrity": "sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y=" + }, + "ms-rest": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/ms-rest/-/ms-rest-2.3.6.tgz", + "integrity": "sha512-M+Lx9P7Wy4TeAk7jqPLwGS1QS1gvxF6Xo+OHv5j1g3Kcb44T/GTUuSjxTKarF6aKyeacZH1ZD++Nt7pcql7dDA==", + "requires": { + "duplexer": "^0.1.1", + "is-buffer": "^1.1.6", + "is-stream": "^1.1.0", + "moment": "^2.21.0", + "request": "^2.87.0", + "through": "^2.3.8", + "tunnel": "0.0.5", + "uuid": "^3.2.1" + } + }, + "ms-rest-azure": { + "version": "2.5.7", + "resolved": "https://registry.npmjs.org/ms-rest-azure/-/ms-rest-azure-2.5.7.tgz", + "integrity": "sha512-e4lgB0z29Dx4ufu/c+PmEAYY1WXq98GYUBkE+iRx7WsxsN04lrM3B1vj8y+B8rKt7clPUE0niqB9VovVL8zvag==", + "requires": { + "adal-node": "^0.1.28", + "async": "2.6.0", + "moment": "^2.22.2", + "ms-rest": "^2.3.2", + "uuid": "^3.2.1" + } + }, + "oauth-sign": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", + "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=" + }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" + }, + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + }, + "request": { + "version": "2.87.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.87.0.tgz", + "integrity": "sha512-fcogkm7Az5bsS6Sl0sibkbhcKsnyon/jV1kF3ajGmF0c8HrttdKTPRT9hieOaQHA5HEq6r8OyWOo/o781C1tNw==", + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.6.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.5", + "extend": "~3.0.1", + "forever-agent": "~0.6.1", + "form-data": "~2.3.1", + "har-validator": "~5.0.3", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.17", + "oauth-sign": "~0.8.2", + "performance-now": "^2.1.0", + "qs": "~6.5.1", + "safe-buffer": "^5.1.1", + "tough-cookie": "~2.3.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.1.0" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "sshpk": { + "version": "1.14.2", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.2.tgz", + "integrity": "sha1-xvxhZIo9nE52T9P8306hBeSSupg=", + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + } + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" + }, + "tough-cookie": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", + "requires": { + "punycode": "^1.4.1" + } + }, + "tunnel": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.5.tgz", + "integrity": "sha512-gj5sdqherx4VZKMcBA4vewER7zdK25Td+z1npBqpbDys4eJrLx+SlYjJvq1bDXs2irkuJM5pf8ktaEQVipkrbA==" + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "optional": true + }, + "underscore": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", + "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" + }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "requires": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } + }, + "xmldom": { + "version": "0.1.27", + "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.27.tgz", + "integrity": "sha1-1QH5ezvbQDr4757MIFcxh6rawOk=" + }, + "xpath.js": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/xpath.js/-/xpath.js-1.1.0.tgz", + "integrity": "sha512-jg+qkfS4K8E7965sqaUl8mRngXiKb3WZGfONgE18pr03FUQiuSV6G+Ej4tS55B+rIQSFEIw3phdVAQ4pPqNWfQ==" + } + } +} diff --git a/lib/services/applicationinsights/package.json b/lib/services/applicationinsights/package.json index 7e7a6025c2..f670708f35 100644 --- a/lib/services/applicationinsights/package.json +++ b/lib/services/applicationinsights/package.json @@ -2,7 +2,7 @@ "name": "azure-arm-appinsights", "author": "Microsoft Corporation", "description": "ApplicationInsightsManagementClient Library with typescript type definitions for node", - "version": "1.2.0-preview", + "version": "2.0.0", "dependencies": { "ms-rest": "^2.3.3", "ms-rest-azure": "^2.5.5" @@ -14,12 +14,12 @@ "license": "MIT", "main": "./lib/applicationInsightsManagementClient.js", "types": "./lib/applicationInsightsManagementClient.d.ts", - "homepage": "http://github.com/azure/azure-sdk-for-node", + "homepage": "https://github.com/azure/azure-sdk-for-node/lib/services/applicationinsights", "repository": { "type": "git", "url": "https://github.com/azure/azure-sdk-for-node.git" }, "bugs": { - "url": "http://github.com/Azure/azure-sdk-for-node/issues" + "url": "https://github.com/azure/azure-sdk-for-node/issues" } } diff --git a/lib/services/websiteManagement2/lib/models/serviceSpecification.js b/lib/services/websiteManagement2/lib/models/serviceSpecification.js deleted file mode 100644 index 77a9cb816e..0000000000 --- a/lib/services/websiteManagement2/lib/models/serviceSpecification.js +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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'); - -/** - * Resource metrics service provided by Microsoft.Insights resource provider. - * - */ -class ServiceSpecification { - /** - * Create a ServiceSpecification. - * @member {array} [metricSpecifications] - * @member {array} [logSpecifications] - */ - constructor() { - } - - /** - * Defines the metadata of ServiceSpecification - * - * @returns {object} metadata of ServiceSpecification - * - */ - mapper() { - return { - required: false, - serializedName: 'ServiceSpecification', - type: { - name: 'Composite', - className: 'ServiceSpecification', - modelProperties: { - metricSpecifications: { - required: false, - serializedName: 'metricSpecifications', - type: { - name: 'Sequence', - element: { - required: false, - serializedName: 'MetricSpecificationElementType', - type: { - name: 'Composite', - className: 'MetricSpecification' - } - } - } - }, - logSpecifications: { - required: false, - serializedName: 'logSpecifications', - type: { - name: 'Sequence', - element: { - required: false, - serializedName: 'LogSpecificationElementType', - type: { - name: 'Composite', - className: 'LogSpecification' - } - } - } - } - } - } - }; - } -} - -module.exports = ServiceSpecification;