diff --git a/lib/services/kustoManagement/LICENSE.txt b/lib/services/kustoManagement/LICENSE.txt new file mode 100644 index 0000000000..a70e8cf660 --- /dev/null +++ b/lib/services/kustoManagement/LICENSE.txt @@ -0,0 +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. diff --git a/lib/services/kustoManagement/README.md b/lib/services/kustoManagement/README.md new file mode 100644 index 0000000000..05b83ac845 --- /dev/null +++ b/lib/services/kustoManagement/README.md @@ -0,0 +1,43 @@ +--- +uid: azure-arm-kusto +summary: *content + +--- +**This SDK will be deprecated next year and will be replaced by a new TypeScript-based isomorphic SDK (found at https://github.com/Azure/azure-sdk-for-js) which works on Node.js and browsers.** +## Microsoft Azure SDK for Node.js - KustoManagementClient +This project provides a Node.js package for accessing Azure. Right now it supports: +- **Node.js version 6.x.x or higher** + +### Features + + +### How to Install + +```bash +npm install azure-arm-kusto +``` + +### How to use + +#### Authentication, client creation and get clusters as an example. + +```javascript +const msRestAzure = require("ms-rest-azure"); +const KustoManagementClient = require("azure-arm-kusto"); +msRestAzure.interactiveLogin().then((creds) => { + const subscriptionId = ""; + const client = new KustoManagementClient(creds, subscriptionId); + const resourceGroupName = "testresourceGroupName"; + const clusterName = "testclusterName"; + return client.clusters.get(resourceGroupName, clusterName).then((result) => { + console.log("The result is:"); + console.log(result); + }); +}).catch((err) => { + console.log('An error occurred:'); + console.dir(err, {depth: null, colors: true}); +}); + +### Related projects + +- [Microsoft Azure SDK for Node.js](https://github.com/Azure/azure-sdk-for-node) diff --git a/lib/services/kustoManagement/lib/kustoManagementClient.d.ts b/lib/services/kustoManagement/lib/kustoManagementClient.d.ts new file mode 100644 index 0000000000..955d1414f3 --- /dev/null +++ b/lib/services/kustoManagement/lib/kustoManagementClient.d.ts @@ -0,0 +1,65 @@ +/* + * 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 KustoManagementClient extends AzureServiceClient { + /** + * Initializes a new instance of the KustoManagementClient class. + * @constructor + * + * @class + * @param {credentials} credentials - Credentials needed for the client to connect to Azure. + * + * @param {string} subscriptionId - Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + * + * @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] - 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: ServiceClientCredentials, subscriptionId: string, baseUri?: string, options?: AzureServiceClientOptions); + + credentials: ServiceClientCredentials; + + subscriptionId: string; + + apiVersion: string; + + acceptLanguage: string; + + longRunningOperationRetryTimeout: number; + + generateClientRequestId: boolean; + + // Operation groups + clusters: operations.Clusters; + databases: operations.Databases; + eventHubConnections: operations.EventHubConnections; + operations: operations.Operations; +} + +export { KustoManagementClient, models as KustoManagementModels }; diff --git a/lib/services/kustoManagement/lib/kustoManagementClient.js b/lib/services/kustoManagement/lib/kustoManagementClient.js new file mode 100644 index 0000000000..037a6acc51 --- /dev/null +++ b/lib/services/kustoManagement/lib/kustoManagementClient.js @@ -0,0 +1,88 @@ +/* + * 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 KustoManagementClient. */ +class KustoManagementClient extends ServiceClient { + /** + * Create a KustoManagementClient. + * @param {credentials} credentials - Credentials needed for the client to connect to Azure. + * @param {string} subscriptionId - Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + * @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] - 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) { + 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 = '2018-09-07-preview'; + 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.clusters = new operations.Clusters(this); + this.databases = new operations.Databases(this); + this.eventHubConnections = new operations.EventHubConnections(this); + this.operations = new operations.Operations(this); + this.models = models; + msRest.addSerializationMixin(this); + } + +} + +module.exports = KustoManagementClient; +module.exports['default'] = KustoManagementClient; +module.exports.KustoManagementClient = KustoManagementClient; +module.exports.KustoManagementModels = models; diff --git a/lib/services/kustoManagement/lib/models/azureCapacity.js b/lib/services/kustoManagement/lib/models/azureCapacity.js new file mode 100644 index 0000000000..906cc942e4 --- /dev/null +++ b/lib/services/kustoManagement/lib/models/azureCapacity.js @@ -0,0 +1,76 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Class representing a AzureCapacity. + */ +class AzureCapacity { + /** + * Create a AzureCapacity. + * @property {string} scaleType Scale type. Possible values include: + * 'automatic', 'manual', 'none' + * @property {number} minimum Minimum allowed capacity. + * @property {number} maximum Maximum allowed capacity. + * @property {number} default The default capacity that would be used. + */ + constructor() { + } + + /** + * Defines the metadata of AzureCapacity + * + * @returns {object} metadata of AzureCapacity + * + */ + mapper() { + return { + required: false, + serializedName: 'AzureCapacity', + type: { + name: 'Composite', + className: 'AzureCapacity', + modelProperties: { + scaleType: { + required: true, + serializedName: 'scaleType', + type: { + name: 'String' + } + }, + minimum: { + required: true, + serializedName: 'minimum', + type: { + name: 'Number' + } + }, + maximum: { + required: true, + serializedName: 'maximum', + type: { + name: 'Number' + } + }, + default: { + required: true, + serializedName: 'default', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = AzureCapacity; diff --git a/lib/services/kustoManagement/lib/models/azureEntityResource.js b/lib/services/kustoManagement/lib/models/azureEntityResource.js new file mode 100644 index 0000000000..83674c0ce4 --- /dev/null +++ b/lib/services/kustoManagement/lib/models/azureEntityResource.js @@ -0,0 +1,82 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * The resource model definition for a Azure Resource Manager resource with an + * etag. + * + * @extends models['Resource'] + */ +class AzureEntityResource extends models['Resource'] { + /** + * Create a AzureEntityResource. + * @property {string} [etag] Resource Etag. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of AzureEntityResource + * + * @returns {object} metadata of AzureEntityResource + * + */ + mapper() { + return { + required: false, + serializedName: 'AzureEntityResource', + type: { + name: 'Composite', + className: 'AzureEntityResource', + 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' + } + }, + etag: { + required: false, + readOnly: true, + serializedName: 'etag', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = AzureEntityResource; diff --git a/lib/services/kustoManagement/lib/models/azureResourceSku.js b/lib/services/kustoManagement/lib/models/azureResourceSku.js new file mode 100644 index 0000000000..f6b2640581 --- /dev/null +++ b/lib/services/kustoManagement/lib/models/azureResourceSku.js @@ -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. + */ + +'use strict'; + +/** + * Class representing a AzureResourceSku. + */ +class AzureResourceSku { + /** + * Create a AzureResourceSku. + * @property {string} [resourceType] Resource Namespace and Type. + * @property {object} [sku] The SKU details. + * @property {string} [sku.name] SKU name. Possible values include: 'KC8', + * 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * @property {number} [sku.capacity] SKU capacity. + * @property {object} [capacity] The SKU capacity. + * @property {string} [capacity.scaleType] Scale type. Possible values + * include: 'automatic', 'manual', 'none' + * @property {number} [capacity.minimum] Minimum allowed capacity. + * @property {number} [capacity.maximum] Maximum allowed capacity. + * @property {number} [capacity.default] The default capacity that would be + * used. + */ + constructor() { + } + + /** + * Defines the metadata of AzureResourceSku + * + * @returns {object} metadata of AzureResourceSku + * + */ + mapper() { + return { + required: false, + serializedName: 'AzureResourceSku', + type: { + name: 'Composite', + className: 'AzureResourceSku', + modelProperties: { + resourceType: { + required: false, + serializedName: 'resourceType', + type: { + name: 'String' + } + }, + sku: { + required: false, + serializedName: 'sku', + type: { + name: 'Composite', + className: 'AzureSku' + } + }, + capacity: { + required: false, + serializedName: 'capacity', + type: { + name: 'Composite', + className: 'AzureCapacity' + } + } + } + } + }; + } +} + +module.exports = AzureResourceSku; diff --git a/lib/services/kustoManagement/lib/models/azureSku.js b/lib/services/kustoManagement/lib/models/azureSku.js new file mode 100644 index 0000000000..99238926bb --- /dev/null +++ b/lib/services/kustoManagement/lib/models/azureSku.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'; + +/** + * Class representing a AzureSku. + */ +class AzureSku { + /** + * Create a AzureSku. + * @property {string} name SKU name. Possible values include: 'KC8', 'KC16', + * 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * @property {number} [capacity] SKU capacity. + */ + constructor() { + } + + /** + * Defines the metadata of AzureSku + * + * @returns {object} metadata of AzureSku + * + */ + mapper() { + return { + required: false, + serializedName: 'AzureSku', + type: { + name: 'Composite', + className: 'AzureSku', + modelProperties: { + name: { + required: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + capacity: { + required: false, + serializedName: 'capacity', + type: { + name: 'Number' + } + }, + tier: { + required: true, + isConstant: true, + serializedName: 'tier', + defaultValue: 'Standard', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = AzureSku; diff --git a/lib/services/kustoManagement/lib/models/checkNameResult.js b/lib/services/kustoManagement/lib/models/checkNameResult.js new file mode 100644 index 0000000000..27b8cabe91 --- /dev/null +++ b/lib/services/kustoManagement/lib/models/checkNameResult.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'; + +/** + * Class representing a CheckNameResult. + */ +class CheckNameResult { + /** + * Create a CheckNameResult. + * @property {boolean} [nameAvailable] Specifies a Boolean value that + * indicates if the name is available. + * @property {string} [name] The name that was checked. + * @property {string} [message] Message indicating an unavailable name due to + * a conflict, or a description of the naming rules that are violated. + */ + constructor() { + } + + /** + * Defines the metadata of CheckNameResult + * + * @returns {object} metadata of CheckNameResult + * + */ + mapper() { + return { + required: false, + serializedName: 'CheckNameResult', + type: { + name: 'Composite', + className: 'CheckNameResult', + modelProperties: { + nameAvailable: { + required: false, + serializedName: 'nameAvailable', + type: { + name: 'Boolean' + } + }, + name: { + required: false, + serializedName: 'name', + type: { + name: 'String' + } + }, + message: { + required: false, + serializedName: 'message', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = CheckNameResult; diff --git a/lib/services/kustoManagement/lib/models/cluster.js b/lib/services/kustoManagement/lib/models/cluster.js new file mode 100644 index 0000000000..73eebccb16 --- /dev/null +++ b/lib/services/kustoManagement/lib/models/cluster.js @@ -0,0 +1,171 @@ +/* + * 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'); + +/** + * Class representing a Kusto cluster. + * + * @extends models['TrackedResource'] + */ +class Cluster extends models['TrackedResource'] { + /** + * Create a Cluster. + * @property {string} [etag] An ETag of the resource created. + * @property {object} sku The SKU of the cluster. + * @property {string} [sku.name] SKU name. Possible values include: 'KC8', + * 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * @property {number} [sku.capacity] SKU capacity. + * @property {string} [state] The state of the resource. Possible values + * include: 'Creating', 'Unavailable', 'Running', 'Deleting', 'Deleted', + * 'Stopping', 'Stopped', 'Starting' + * @property {string} [provisioningState] The provisioned state of the + * resource. Possible values include: 'Running', 'Creating', 'Deleting', + * 'Succeeded', 'Failed' + * @property {string} [uri] The cluster URI. + * @property {string} [dataIngestionUri] The cluster data ingestion URI. + * @property {array} [trustedExternalTenants] The cluster's external tenants. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Cluster + * + * @returns {object} metadata of Cluster + * + */ + mapper() { + return { + required: false, + serializedName: 'Cluster', + type: { + name: 'Composite', + className: 'Cluster', + 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' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + location: { + required: true, + serializedName: 'location', + type: { + name: 'String' + } + }, + etag: { + required: false, + readOnly: true, + serializedName: 'etag', + type: { + name: 'String' + } + }, + sku: { + required: true, + serializedName: 'sku', + defaultValue: {}, + type: { + name: 'Composite', + className: 'AzureSku' + } + }, + state: { + required: false, + readOnly: true, + serializedName: 'properties.state', + type: { + name: 'String' + } + }, + provisioningState: { + required: false, + readOnly: true, + serializedName: 'properties.provisioningState', + type: { + name: 'String' + } + }, + uri: { + required: false, + readOnly: true, + serializedName: 'properties.uri', + type: { + name: 'String' + } + }, + dataIngestionUri: { + required: false, + readOnly: true, + serializedName: 'properties.dataIngestionUri', + type: { + name: 'String' + } + }, + trustedExternalTenants: { + required: false, + serializedName: 'properties.trustedExternalTenants', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'TrustedExternalTenantElementType', + type: { + name: 'Composite', + className: 'TrustedExternalTenant' + } + } + } + } + } + } + }; + } +} + +module.exports = Cluster; diff --git a/lib/services/kustoManagement/lib/models/clusterCheckNameRequest.js b/lib/services/kustoManagement/lib/models/clusterCheckNameRequest.js new file mode 100644 index 0000000000..e52276f0e8 --- /dev/null +++ b/lib/services/kustoManagement/lib/models/clusterCheckNameRequest.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'; + +/** + * Class representing a ClusterCheckNameRequest. + */ +class ClusterCheckNameRequest { + /** + * Create a ClusterCheckNameRequest. + * @property {string} name Cluster name. + */ + constructor() { + } + + /** + * Defines the metadata of ClusterCheckNameRequest + * + * @returns {object} metadata of ClusterCheckNameRequest + * + */ + mapper() { + return { + required: false, + serializedName: 'ClusterCheckNameRequest', + type: { + name: 'Composite', + className: 'ClusterCheckNameRequest', + modelProperties: { + name: { + required: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: true, + isConstant: true, + serializedName: 'type', + defaultValue: 'Microsoft.Kusto/clusters', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ClusterCheckNameRequest; diff --git a/lib/services/kustoManagement/lib/models/clusterListResult.js b/lib/services/kustoManagement/lib/models/clusterListResult.js new file mode 100644 index 0000000000..14d6c6d180 --- /dev/null +++ b/lib/services/kustoManagement/lib/models/clusterListResult.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'; + +/** + * The list Kusto clusters operation response. + */ +class ClusterListResult extends Array { + /** + * Create a ClusterListResult. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ClusterListResult + * + * @returns {object} metadata of ClusterListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'ClusterListResult', + type: { + name: 'Composite', + className: 'ClusterListResult', + modelProperties: { + value: { + required: false, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ClusterElementType', + type: { + name: 'Composite', + className: 'Cluster' + } + } + } + } + } + } + }; + } +} + +module.exports = ClusterListResult; diff --git a/lib/services/kustoManagement/lib/models/clusterUpdate.js b/lib/services/kustoManagement/lib/models/clusterUpdate.js new file mode 100644 index 0000000000..038ad2bd38 --- /dev/null +++ b/lib/services/kustoManagement/lib/models/clusterUpdate.js @@ -0,0 +1,172 @@ +/* + * 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'); + +/** + * Class representing an update to a Kusto cluster. + * + * @extends models['Resource'] + */ +class ClusterUpdate extends models['Resource'] { + /** + * Create a ClusterUpdate. + * @property {object} [tags] Resource tags. + * @property {string} [location] Resource location. + * @property {string} [etag] An ETag of the resource updated. + * @property {object} [sku] The SKU of the cluster. + * @property {string} [sku.name] SKU name. Possible values include: 'KC8', + * 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * @property {number} [sku.capacity] SKU capacity. + * @property {string} [state] The state of the resource. Possible values + * include: 'Creating', 'Unavailable', 'Running', 'Deleting', 'Deleted', + * 'Stopping', 'Stopped', 'Starting' + * @property {string} [provisioningState] The provisioned state of the + * resource. Possible values include: 'Running', 'Creating', 'Deleting', + * 'Succeeded', 'Failed' + * @property {string} [uri] The cluster URI. + * @property {string} [dataIngestionUri] The cluster data ingestion URI. + * @property {array} [trustedExternalTenants] The cluster's external tenants. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ClusterUpdate + * + * @returns {object} metadata of ClusterUpdate + * + */ + mapper() { + return { + required: false, + serializedName: 'ClusterUpdate', + type: { + name: 'Composite', + className: 'ClusterUpdate', + 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' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + location: { + required: false, + serializedName: 'location', + type: { + name: 'String' + } + }, + etag: { + required: false, + readOnly: true, + serializedName: 'etag', + type: { + name: 'String' + } + }, + sku: { + required: false, + serializedName: 'sku', + type: { + name: 'Composite', + className: 'AzureSku' + } + }, + state: { + required: false, + readOnly: true, + serializedName: 'properties.state', + type: { + name: 'String' + } + }, + provisioningState: { + required: false, + readOnly: true, + serializedName: 'properties.provisioningState', + type: { + name: 'String' + } + }, + uri: { + required: false, + readOnly: true, + serializedName: 'properties.uri', + type: { + name: 'String' + } + }, + dataIngestionUri: { + required: false, + readOnly: true, + serializedName: 'properties.dataIngestionUri', + type: { + name: 'String' + } + }, + trustedExternalTenants: { + required: false, + serializedName: 'properties.trustedExternalTenants', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'TrustedExternalTenantElementType', + type: { + name: 'Composite', + className: 'TrustedExternalTenant' + } + } + } + } + } + } + }; + } +} + +module.exports = ClusterUpdate; diff --git a/lib/services/kustoManagement/lib/models/database.js b/lib/services/kustoManagement/lib/models/database.js new file mode 100644 index 0000000000..ef65324d1e --- /dev/null +++ b/lib/services/kustoManagement/lib/models/database.js @@ -0,0 +1,142 @@ +/* + * 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'); + +/** + * Class representing a Kusto database. + * + * @extends models['TrackedResource'] + */ +class Database extends models['TrackedResource'] { + /** + * Create a Database. + * @property {string} [etag] An ETag of the resource created. + * @property {string} [provisioningState] The provisioned state of the + * resource. Possible values include: 'Running', 'Creating', 'Deleting', + * 'Succeeded', 'Failed' + * @property {number} softDeletePeriodInDays The number of days data should + * be kept before it stops being accessible to queries. + * @property {number} [hotCachePeriodInDays] The number of days of data that + * should be kept in cache for fast queries. + * @property {object} [statistics] The statistics of the database. + * @property {number} [statistics.size] The database size - the total size of + * compressed data and index in bytes. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Database + * + * @returns {object} metadata of Database + * + */ + mapper() { + return { + required: false, + serializedName: 'Database', + type: { + name: 'Composite', + className: 'Database', + 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' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + location: { + required: true, + serializedName: 'location', + type: { + name: 'String' + } + }, + etag: { + required: false, + readOnly: true, + serializedName: 'etag', + type: { + name: 'String' + } + }, + provisioningState: { + required: false, + readOnly: true, + serializedName: 'properties.provisioningState', + type: { + name: 'String' + } + }, + softDeletePeriodInDays: { + required: true, + serializedName: 'properties.softDeletePeriodInDays', + type: { + name: 'Number' + } + }, + hotCachePeriodInDays: { + required: false, + serializedName: 'properties.hotCachePeriodInDays', + type: { + name: 'Number' + } + }, + statistics: { + required: false, + serializedName: 'properties.statistics', + type: { + name: 'Composite', + className: 'DatabaseStatistics' + } + } + } + } + }; + } +} + +module.exports = Database; diff --git a/lib/services/kustoManagement/lib/models/databaseCheckNameRequest.js b/lib/services/kustoManagement/lib/models/databaseCheckNameRequest.js new file mode 100644 index 0000000000..9d21449bfa --- /dev/null +++ b/lib/services/kustoManagement/lib/models/databaseCheckNameRequest.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'; + +/** + * Class representing a DatabaseCheckNameRequest. + */ +class DatabaseCheckNameRequest { + /** + * Create a DatabaseCheckNameRequest. + * @property {string} name Database name. + */ + constructor() { + } + + /** + * Defines the metadata of DatabaseCheckNameRequest + * + * @returns {object} metadata of DatabaseCheckNameRequest + * + */ + mapper() { + return { + required: false, + serializedName: 'DatabaseCheckNameRequest', + type: { + name: 'Composite', + className: 'DatabaseCheckNameRequest', + modelProperties: { + name: { + required: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: true, + isConstant: true, + serializedName: 'type', + defaultValue: 'Microsoft.Kusto/clusters/databases', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = DatabaseCheckNameRequest; diff --git a/lib/services/kustoManagement/lib/models/databaseListResult.js b/lib/services/kustoManagement/lib/models/databaseListResult.js new file mode 100644 index 0000000000..2501a1592c --- /dev/null +++ b/lib/services/kustoManagement/lib/models/databaseListResult.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'; + +/** + * The list Kusto databases operation response. + */ +class DatabaseListResult extends Array { + /** + * Create a DatabaseListResult. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of DatabaseListResult + * + * @returns {object} metadata of DatabaseListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'DatabaseListResult', + type: { + name: 'Composite', + className: 'DatabaseListResult', + modelProperties: { + value: { + required: false, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'DatabaseElementType', + type: { + name: 'Composite', + className: 'Database' + } + } + } + } + } + } + }; + } +} + +module.exports = DatabaseListResult; diff --git a/lib/services/kustoManagement/lib/models/databasePrincipal.js b/lib/services/kustoManagement/lib/models/databasePrincipal.js new file mode 100644 index 0000000000..32ba0470a8 --- /dev/null +++ b/lib/services/kustoManagement/lib/models/databasePrincipal.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'; + +/** + * Class representing a DatabasePrincipal. + */ +class DatabasePrincipal { + /** + * Create a DatabasePrincipal. + * @property {string} role Database principal role. Possible values include: + * 'Admin', 'Ingestor', 'Monitor', 'User', 'UnrestrictedViewers', 'Viewer' + * @property {string} name Database principal name. + * @property {string} type Database principal type. Possible values include: + * 'App', 'Group', 'User' + * @property {string} [fqn] Database principal fully qualified name. + * @property {string} [email] Database principal email if exists. + * @property {string} [appId] Application id - relevant only for application + * principal type. + */ + constructor() { + } + + /** + * Defines the metadata of DatabasePrincipal + * + * @returns {object} metadata of DatabasePrincipal + * + */ + mapper() { + return { + required: false, + serializedName: 'DatabasePrincipal', + type: { + name: 'Composite', + className: 'DatabasePrincipal', + modelProperties: { + role: { + required: true, + serializedName: 'role', + type: { + name: 'String' + } + }, + name: { + required: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + fqn: { + required: false, + serializedName: 'fqn', + type: { + name: 'String' + } + }, + email: { + required: false, + serializedName: 'email', + type: { + name: 'String' + } + }, + appId: { + required: false, + serializedName: 'appId', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = DatabasePrincipal; diff --git a/lib/services/kustoManagement/lib/models/databasePrincipalListRequest.js b/lib/services/kustoManagement/lib/models/databasePrincipalListRequest.js new file mode 100644 index 0000000000..96e38f627b --- /dev/null +++ b/lib/services/kustoManagement/lib/models/databasePrincipalListRequest.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'; + +/** + * The list Kusto database principals operation request. + * + */ +class DatabasePrincipalListRequest { + /** + * Create a DatabasePrincipalListRequest. + * @property {array} [value] The list of Kusto database principals. + */ + constructor() { + } + + /** + * Defines the metadata of DatabasePrincipalListRequest + * + * @returns {object} metadata of DatabasePrincipalListRequest + * + */ + mapper() { + return { + required: false, + serializedName: 'DatabasePrincipalListRequest', + type: { + name: 'Composite', + className: 'DatabasePrincipalListRequest', + modelProperties: { + value: { + required: false, + serializedName: 'value', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'DatabasePrincipalElementType', + type: { + name: 'Composite', + className: 'DatabasePrincipal' + } + } + } + } + } + } + }; + } +} + +module.exports = DatabasePrincipalListRequest; diff --git a/lib/services/kustoManagement/lib/models/databasePrincipalListResult.js b/lib/services/kustoManagement/lib/models/databasePrincipalListResult.js new file mode 100644 index 0000000000..74091a260d --- /dev/null +++ b/lib/services/kustoManagement/lib/models/databasePrincipalListResult.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'; + +/** + * The list Kusto database principals operation response. + */ +class DatabasePrincipalListResult extends Array { + /** + * Create a DatabasePrincipalListResult. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of DatabasePrincipalListResult + * + * @returns {object} metadata of DatabasePrincipalListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'DatabasePrincipalListResult', + type: { + name: 'Composite', + className: 'DatabasePrincipalListResult', + modelProperties: { + value: { + required: false, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'DatabasePrincipalElementType', + type: { + name: 'Composite', + className: 'DatabasePrincipal' + } + } + } + } + } + } + }; + } +} + +module.exports = DatabasePrincipalListResult; diff --git a/lib/services/kustoManagement/lib/models/databaseStatistics.js b/lib/services/kustoManagement/lib/models/databaseStatistics.js new file mode 100644 index 0000000000..d5ce0a8193 --- /dev/null +++ b/lib/services/kustoManagement/lib/models/databaseStatistics.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Class representing a DatabaseStatistics. + */ +class DatabaseStatistics { + /** + * Create a DatabaseStatistics. + * @property {number} [size] The database size - the total size of compressed + * data and index in bytes. + */ + constructor() { + } + + /** + * Defines the metadata of DatabaseStatistics + * + * @returns {object} metadata of DatabaseStatistics + * + */ + mapper() { + return { + required: false, + serializedName: 'DatabaseStatistics', + type: { + name: 'Composite', + className: 'DatabaseStatistics', + modelProperties: { + size: { + required: false, + serializedName: 'size', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = DatabaseStatistics; diff --git a/lib/services/kustoManagement/lib/models/databaseUpdate.js b/lib/services/kustoManagement/lib/models/databaseUpdate.js new file mode 100644 index 0000000000..db268fc531 --- /dev/null +++ b/lib/services/kustoManagement/lib/models/databaseUpdate.js @@ -0,0 +1,129 @@ +/* + * 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'); + +/** + * Class representing an update to a Kusto database. + * + * @extends models['Resource'] + */ +class DatabaseUpdate extends models['Resource'] { + /** + * Create a DatabaseUpdate. + * @property {string} [location] Resource location. + * @property {string} [etag] An ETag of the resource updated. + * @property {string} [provisioningState] The provisioned state of the + * resource. Possible values include: 'Running', 'Creating', 'Deleting', + * 'Succeeded', 'Failed' + * @property {number} softDeletePeriodInDays The number of days data should + * be kept before it stops being accessible to queries. + * @property {number} [hotCachePeriodInDays] The number of days of data that + * should be kept in cache for fast queries. + * @property {object} [statistics] The statistics of the database. + * @property {number} [statistics.size] The database size - the total size of + * compressed data and index in bytes. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of DatabaseUpdate + * + * @returns {object} metadata of DatabaseUpdate + * + */ + mapper() { + return { + required: false, + serializedName: 'DatabaseUpdate', + type: { + name: 'Composite', + className: 'DatabaseUpdate', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + location: { + required: false, + serializedName: 'location', + type: { + name: 'String' + } + }, + etag: { + required: false, + readOnly: true, + serializedName: 'etag', + type: { + name: 'String' + } + }, + provisioningState: { + required: false, + readOnly: true, + serializedName: 'properties.provisioningState', + type: { + name: 'String' + } + }, + softDeletePeriodInDays: { + required: true, + serializedName: 'properties.softDeletePeriodInDays', + type: { + name: 'Number' + } + }, + hotCachePeriodInDays: { + required: false, + serializedName: 'properties.hotCachePeriodInDays', + type: { + name: 'Number' + } + }, + statistics: { + required: false, + serializedName: 'properties.statistics', + type: { + name: 'Composite', + className: 'DatabaseStatistics' + } + } + } + } + }; + } +} + +module.exports = DatabaseUpdate; diff --git a/lib/services/kustoManagement/lib/models/eventHubConnection.js b/lib/services/kustoManagement/lib/models/eventHubConnection.js new file mode 100644 index 0000000000..29f5fa2e8f --- /dev/null +++ b/lib/services/kustoManagement/lib/models/eventHubConnection.js @@ -0,0 +1,125 @@ +/* + * 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'); + +/** + * Class representing an event hub connection. + * + * @extends models['ProxyResource'] + */ +class EventHubConnection extends models['ProxyResource'] { + /** + * Create a EventHubConnection. + * @property {string} [location] Resource location. + * @property {string} eventHubResourceId The resource ID of the event hub to + * be used to create a data connection. + * @property {string} consumerGroup The event hub consumer group. + * @property {string} [tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * @property {string} [mappingRuleName] The mapping rule to be used to ingest + * the data. Optionally the mapping information can be added to each message. + * @property {string} [dataFormat] The data format of the message. Optionally + * the data format can be added to each message. Possible values include: + * 'MULTIJSON', 'JSON', 'CSV' + */ + constructor() { + super(); + } + + /** + * Defines the metadata of EventHubConnection + * + * @returns {object} metadata of EventHubConnection + * + */ + mapper() { + return { + required: false, + serializedName: 'EventHubConnection', + type: { + name: 'Composite', + className: 'EventHubConnection', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + location: { + required: false, + serializedName: 'location', + type: { + name: 'String' + } + }, + eventHubResourceId: { + required: true, + serializedName: 'properties.eventHubResourceId', + type: { + name: 'String' + } + }, + consumerGroup: { + required: true, + serializedName: 'properties.consumerGroup', + type: { + name: 'String' + } + }, + tableName: { + required: false, + serializedName: 'properties.tableName', + type: { + name: 'String' + } + }, + mappingRuleName: { + required: false, + serializedName: 'properties.mappingRuleName', + type: { + name: 'String' + } + }, + dataFormat: { + required: false, + serializedName: 'properties.dataFormat', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = EventHubConnection; diff --git a/lib/services/kustoManagement/lib/models/eventHubConnectionListResult.js b/lib/services/kustoManagement/lib/models/eventHubConnectionListResult.js new file mode 100644 index 0000000000..cf29802e85 --- /dev/null +++ b/lib/services/kustoManagement/lib/models/eventHubConnectionListResult.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'; + +/** + * The list Kusto event hub connections operation response. + */ +class EventHubConnectionListResult extends Array { + /** + * Create a EventHubConnectionListResult. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of EventHubConnectionListResult + * + * @returns {object} metadata of EventHubConnectionListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'EventHubConnectionListResult', + type: { + name: 'Composite', + className: 'EventHubConnectionListResult', + modelProperties: { + value: { + required: false, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'EventHubConnectionElementType', + type: { + name: 'Composite', + className: 'EventHubConnection' + } + } + } + } + } + } + }; + } +} + +module.exports = EventHubConnectionListResult; diff --git a/lib/services/kustoManagement/lib/models/eventHubConnectionUpdate.js b/lib/services/kustoManagement/lib/models/eventHubConnectionUpdate.js new file mode 100644 index 0000000000..fda6c0dceb --- /dev/null +++ b/lib/services/kustoManagement/lib/models/eventHubConnectionUpdate.js @@ -0,0 +1,125 @@ +/* + * 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'); + +/** + * Class representing an update to event hub connection. + * + * @extends models['ProxyResource'] + */ +class EventHubConnectionUpdate extends models['ProxyResource'] { + /** + * Create a EventHubConnectionUpdate. + * @property {string} [location] Resource location. + * @property {string} eventHubResourceId The resource ID of the event hub to + * be used to create a data connection. + * @property {string} consumerGroup The event hub consumer group. + * @property {string} [tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * @property {string} [mappingRuleName] The mapping rule to be used to ingest + * the data. Optionally the mapping information can be added to each message. + * @property {string} [dataFormat] The data format of the message. Optionally + * the data format can be added to each message. Possible values include: + * 'MULTIJSON', 'JSON', 'CSV' + */ + constructor() { + super(); + } + + /** + * Defines the metadata of EventHubConnectionUpdate + * + * @returns {object} metadata of EventHubConnectionUpdate + * + */ + mapper() { + return { + required: false, + serializedName: 'EventHubConnectionUpdate', + type: { + name: 'Composite', + className: 'EventHubConnectionUpdate', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + location: { + required: false, + serializedName: 'location', + type: { + name: 'String' + } + }, + eventHubResourceId: { + required: true, + serializedName: 'properties.eventHubResourceId', + type: { + name: 'String' + } + }, + consumerGroup: { + required: true, + serializedName: 'properties.consumerGroup', + type: { + name: 'String' + } + }, + tableName: { + required: false, + serializedName: 'properties.tableName', + type: { + name: 'String' + } + }, + mappingRuleName: { + required: false, + serializedName: 'properties.mappingRuleName', + type: { + name: 'String' + } + }, + dataFormat: { + required: false, + serializedName: 'properties.dataFormat', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = EventHubConnectionUpdate; diff --git a/lib/services/kustoManagement/lib/models/eventHubConnectionValidation.js b/lib/services/kustoManagement/lib/models/eventHubConnectionValidation.js new file mode 100644 index 0000000000..7b94224125 --- /dev/null +++ b/lib/services/kustoManagement/lib/models/eventHubConnectionValidation.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'; + +/** + * Class representing an event hub connection validation. + * + */ +class EventHubConnectionValidation { + /** + * Create a EventHubConnectionValidation. + * @property {string} [eventhubConnectionName] The name of the event hub + * connection. + * @property {string} eventHubResourceId The resource ID of the event hub to + * be used to create a data connection. + * @property {string} consumerGroup The event hub consumer group. + * @property {string} [tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * @property {string} [mappingRuleName] The mapping rule to be used to ingest + * the data. Optionally the mapping information can be added to each message. + * @property {string} [dataFormat] The data format of the message. Optionally + * the data format can be added to each message. Possible values include: + * 'MULTIJSON', 'JSON', 'CSV' + */ + constructor() { + } + + /** + * Defines the metadata of EventHubConnectionValidation + * + * @returns {object} metadata of EventHubConnectionValidation + * + */ + mapper() { + return { + required: false, + serializedName: 'EventHubConnectionValidation', + type: { + name: 'Composite', + className: 'EventHubConnectionValidation', + modelProperties: { + eventhubConnectionName: { + required: false, + serializedName: 'eventhubConnectionName', + type: { + name: 'String' + } + }, + eventHubResourceId: { + required: true, + serializedName: 'properties.eventHubResourceId', + type: { + name: 'String' + } + }, + consumerGroup: { + required: true, + serializedName: 'properties.consumerGroup', + type: { + name: 'String' + } + }, + tableName: { + required: false, + serializedName: 'properties.tableName', + type: { + name: 'String' + } + }, + mappingRuleName: { + required: false, + serializedName: 'properties.mappingRuleName', + type: { + name: 'String' + } + }, + dataFormat: { + required: false, + serializedName: 'properties.dataFormat', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = EventHubConnectionValidation; diff --git a/lib/services/kustoManagement/lib/models/eventHubConnectionValidationListResult.js b/lib/services/kustoManagement/lib/models/eventHubConnectionValidationListResult.js new file mode 100644 index 0000000000..7365a7747c --- /dev/null +++ b/lib/services/kustoManagement/lib/models/eventHubConnectionValidationListResult.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The list Kusto event hub connection validation result. + * + */ +class EventHubConnectionValidationListResult { + /** + * Create a EventHubConnectionValidationListResult. + * @property {array} [value] The list of Kusto event hub connection + * validation errors. + */ + constructor() { + } + + /** + * Defines the metadata of EventHubConnectionValidationListResult + * + * @returns {object} metadata of EventHubConnectionValidationListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'EventHubConnectionValidationListResult', + type: { + name: 'Composite', + className: 'EventHubConnectionValidationListResult', + modelProperties: { + value: { + required: false, + serializedName: 'value', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'EventHubConnectionValidationResultElementType', + type: { + name: 'Composite', + className: 'EventHubConnectionValidationResult' + } + } + } + } + } + } + }; + } +} + +module.exports = EventHubConnectionValidationListResult; diff --git a/lib/services/kustoManagement/lib/models/eventHubConnectionValidationResult.js b/lib/services/kustoManagement/lib/models/eventHubConnectionValidationResult.js new file mode 100644 index 0000000000..8292ebc591 --- /dev/null +++ b/lib/services/kustoManagement/lib/models/eventHubConnectionValidationResult.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Class representing a EventHubConnectionValidationResult. + */ +class EventHubConnectionValidationResult { + /** + * Create a EventHubConnectionValidationResult. + * @property {string} [errorMessage] A message which indicates a problem in + * event hub connection validation. + */ + constructor() { + } + + /** + * Defines the metadata of EventHubConnectionValidationResult + * + * @returns {object} metadata of EventHubConnectionValidationResult + * + */ + mapper() { + return { + required: false, + serializedName: 'EventHubConnectionValidationResult', + type: { + name: 'Composite', + className: 'EventHubConnectionValidationResult', + modelProperties: { + errorMessage: { + required: false, + serializedName: 'errorMessage', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = EventHubConnectionValidationResult; diff --git a/lib/services/kustoManagement/lib/models/index.d.ts b/lib/services/kustoManagement/lib/models/index.d.ts new file mode 100644 index 0000000000..ae29d4d6fd --- /dev/null +++ b/lib/services/kustoManagement/lib/models/index.d.ts @@ -0,0 +1,539 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { BaseResource, CloudError } from "ms-rest-azure"; +import * as moment from "moment"; + +export { + + BaseResource, + CloudError +}; + +export interface TrustedExternalTenant { + /** + * GUID representing an external tenant. + */ + value?: string; +} + +export interface AzureSku { + /** + * SKU name. Possible values include: 'KC8', 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', + * 'L16' + */ + name: string; + /** + * SKU capacity. + */ + capacity?: number; +} + +export interface AzureCapacity { + /** + * Scale type. Possible values include: 'automatic', 'manual', 'none' + */ + scaleType: string; + /** + * Minimum allowed capacity. + */ + minimum: number; + /** + * Maximum allowed capacity. + */ + maximum: number; + /** + * The default capacity that would be used. + */ + default: number; +} + +export interface AzureResourceSku { + /** + * Resource Namespace and Type. + */ + resourceType?: string; + /** + * The SKU details. + */ + sku?: AzureSku; + /** + * The SKU capacity. + */ + capacity?: AzureCapacity; +} + +export interface DatabaseStatistics { + /** + * The database size - the total size of compressed data and index in bytes. + */ + size?: number; +} + +/** + * Class representing an event hub connection validation. +*/ +export interface EventHubConnectionValidation { + /** + * The name of the event hub connection. + */ + eventhubConnectionName?: string; + /** + * The resource ID of the event hub to be used to create a data connection. + */ + eventHubResourceId: string; + /** + * The event hub consumer group. + */ + consumerGroup: string; + /** + * The table where the data should be ingested. Optionally the table information can be added to + * each message. + */ + tableName?: string; + /** + * The mapping rule to be used to ingest the data. Optionally the mapping information can be + * added to each message. + */ + mappingRuleName?: string; + /** + * The data format of the message. Optionally the data format can be added to each message. + * Possible values include: 'MULTIJSON', 'JSON', 'CSV' + */ + dataFormat?: string; +} + +export interface Resource extends BaseResource { + /** + * Fully qualified resource Id for the resource. Ex - + * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + */ + readonly id?: string; + /** + * The name of the resource + */ + readonly name?: string; + /** + * The type of the resource. Ex- Microsoft.Compute/virtualMachines or + * Microsoft.Storage/storageAccounts. + */ + readonly type?: string; +} + +/** + * The resource model definition for a ARM tracked top level resource +*/ +export interface TrackedResource extends Resource { + /** + * Resource tags. + */ + tags?: { [propertyName: string]: string }; + /** + * The geo-location where the resource lives + */ + location: string; +} + +/** + * Class representing a Kusto cluster. +*/ +export interface Cluster extends TrackedResource { + /** + * An ETag of the resource created. + */ + readonly etag?: string; + /** + * The SKU of the cluster. + */ + sku: AzureSku; + /** + * The state of the resource. Possible values include: 'Creating', 'Unavailable', 'Running', + * 'Deleting', 'Deleted', 'Stopping', 'Stopped', 'Starting' + */ + readonly state?: string; + /** + * The provisioned state of the resource. Possible values include: 'Running', 'Creating', + * 'Deleting', 'Succeeded', 'Failed' + */ + readonly provisioningState?: string; + /** + * The cluster URI. + */ + readonly uri?: string; + /** + * The cluster data ingestion URI. + */ + readonly dataIngestionUri?: string; + /** + * The cluster's external tenants. + */ + trustedExternalTenants?: TrustedExternalTenant[]; +} + +/** + * Class representing an update to a Kusto cluster. +*/ +export interface ClusterUpdate extends Resource { + /** + * Resource tags. + */ + tags?: { [propertyName: string]: string }; + /** + * Resource location. + */ + location?: string; + /** + * An ETag of the resource updated. + */ + readonly etag?: string; + /** + * The SKU of the cluster. + */ + sku?: AzureSku; + /** + * The state of the resource. Possible values include: 'Creating', 'Unavailable', 'Running', + * 'Deleting', 'Deleted', 'Stopping', 'Stopped', 'Starting' + */ + readonly state?: string; + /** + * The provisioned state of the resource. Possible values include: 'Running', 'Creating', + * 'Deleting', 'Succeeded', 'Failed' + */ + readonly provisioningState?: string; + /** + * The cluster URI. + */ + readonly uri?: string; + /** + * The cluster data ingestion URI. + */ + readonly dataIngestionUri?: string; + /** + * The cluster's external tenants. + */ + trustedExternalTenants?: TrustedExternalTenant[]; +} + +/** + * Class representing a Kusto database. +*/ +export interface Database extends TrackedResource { + /** + * An ETag of the resource created. + */ + readonly etag?: string; + /** + * The provisioned state of the resource. Possible values include: 'Running', 'Creating', + * 'Deleting', 'Succeeded', 'Failed' + */ + readonly provisioningState?: string; + /** + * The number of days data should be kept before it stops being accessible to queries. + */ + softDeletePeriodInDays: number; + /** + * The number of days of data that should be kept in cache for fast queries. + */ + hotCachePeriodInDays?: number; + /** + * The statistics of the database. + */ + statistics?: DatabaseStatistics; +} + +/** + * Class representing an update to a Kusto database. +*/ +export interface DatabaseUpdate extends Resource { + /** + * Resource location. + */ + location?: string; + /** + * An ETag of the resource updated. + */ + readonly etag?: string; + /** + * The provisioned state of the resource. Possible values include: 'Running', 'Creating', + * 'Deleting', 'Succeeded', 'Failed' + */ + readonly provisioningState?: string; + /** + * The number of days data should be kept before it stops being accessible to queries. + */ + softDeletePeriodInDays: number; + /** + * The number of days of data that should be kept in cache for fast queries. + */ + hotCachePeriodInDays?: number; + /** + * The statistics of the database. + */ + statistics?: DatabaseStatistics; +} + +export interface DatabasePrincipal { + /** + * Database principal role. Possible values include: 'Admin', 'Ingestor', 'Monitor', 'User', + * 'UnrestrictedViewers', 'Viewer' + */ + role: string; + /** + * Database principal name. + */ + name: string; + /** + * Database principal type. Possible values include: 'App', 'Group', 'User' + */ + type: string; + /** + * Database principal fully qualified name. + */ + fqn?: string; + /** + * Database principal email if exists. + */ + email?: string; + /** + * Application id - relevant only for application principal type. + */ + appId?: string; +} + +/** + * The resource model definition for a ARM proxy resource. It will have everything other than + * required location and tags +*/ +export interface ProxyResource extends Resource { +} + +/** + * Class representing an update to event hub connection. +*/ +export interface EventHubConnectionUpdate extends ProxyResource { + /** + * Resource location. + */ + location?: string; + /** + * The resource ID of the event hub to be used to create a data connection. + */ + eventHubResourceId: string; + /** + * The event hub consumer group. + */ + consumerGroup: string; + /** + * The table where the data should be ingested. Optionally the table information can be added to + * each message. + */ + tableName?: string; + /** + * The mapping rule to be used to ingest the data. Optionally the mapping information can be + * added to each message. + */ + mappingRuleName?: string; + /** + * The data format of the message. Optionally the data format can be added to each message. + * Possible values include: 'MULTIJSON', 'JSON', 'CSV' + */ + dataFormat?: string; +} + +/** + * Class representing an event hub connection. +*/ +export interface EventHubConnection extends ProxyResource { + /** + * Resource location. + */ + location?: string; + /** + * The resource ID of the event hub to be used to create a data connection. + */ + eventHubResourceId: string; + /** + * The event hub consumer group. + */ + consumerGroup: string; + /** + * The table where the data should be ingested. Optionally the table information can be added to + * each message. + */ + tableName?: string; + /** + * The mapping rule to be used to ingest the data. Optionally the mapping information can be + * added to each message. + */ + mappingRuleName?: string; + /** + * The data format of the message. Optionally the data format can be added to each message. + * Possible values include: 'MULTIJSON', 'JSON', 'CSV' + */ + dataFormat?: string; +} + +export interface EventHubConnectionValidationResult { + /** + * A message which indicates a problem in event hub connection validation. + */ + errorMessage?: string; +} + +/** + * The list Kusto database principals operation request. +*/ +export interface DatabasePrincipalListRequest { + /** + * The list of Kusto database principals. + */ + value?: DatabasePrincipal[]; +} + +/** + * The list Kusto event hub connection validation result. +*/ +export interface EventHubConnectionValidationListResult { + /** + * The list of Kusto event hub connection validation errors. + */ + value?: EventHubConnectionValidationResult[]; +} + +export interface ClusterCheckNameRequest { + /** + * Cluster name. + */ + name: string; +} + +export interface DatabaseCheckNameRequest { + /** + * Database name. + */ + name: string; +} + +export interface CheckNameResult { + /** + * Specifies a Boolean value that indicates if the name is available. + */ + nameAvailable?: boolean; + /** + * The name that was checked. + */ + name?: string; + /** + * Message indicating an unavailable name due to a conflict, or a description of the naming rules + * that are violated. + */ + message?: string; +} + +/** + * @summary The object that describes the operation. +*/ +export interface OperationDisplay { + /** + * @summary Friendly name of the resource provider. + */ + provider?: string; + /** + * @summary The operation type. + * @description For example: read, write, delete. + */ + operation?: string; + /** + * @summary The resource type on which the operation is performed. + */ + resource?: string; + /** + * @summary The friendly name of the operation. + */ + description?: string; +} + +/** + * @summary A REST API operation +*/ +export interface Operation { + /** + * @summary The operation name. + * @description This is of the format {provider}/{resource}/{operation}. + */ + name?: string; + /** + * @summary The object that describes the operation. + */ + display?: OperationDisplay; + /** + * @summary The intended executor of the operation. + */ + origin?: string; + /** + * @summary Properties of the operation. + */ + properties?: any; +} + +/** + * The resource model definition for a Azure Resource Manager resource with an etag. +*/ +export interface AzureEntityResource extends Resource { + /** + * Resource Etag. + */ + readonly etag?: string; +} + +/** + * The list Kusto clusters operation response. +*/ +export interface ClusterListResult extends Array { +} + +/** + * List of available SKUs for a new Kusto Cluster. +*/ +export interface ListSkusResult extends Array { +} + +/** + * List of available SKUs for an existing Kusto Cluster. +*/ +export interface ListResourceSkusResult extends Array { +} + +/** + * The list Kusto databases operation response. +*/ +export interface DatabaseListResult extends Array { +} + +/** + * The list Kusto database principals operation response. +*/ +export interface DatabasePrincipalListResult extends Array { +} + +/** + * The list Kusto event hub connections operation response. +*/ +export interface EventHubConnectionListResult extends Array { +} + +/** + * @summary Result of the request to list REST API operations. It contains a list of operations and + * a URL nextLink to get the next set of results. +*/ +export interface OperationListResult extends Array { + /** + * @summary The URL to get the next set of operation list results if there are any. + */ + nextLink?: string; +} diff --git a/lib/services/kustoManagement/lib/models/index.js b/lib/services/kustoManagement/lib/models/index.js new file mode 100644 index 0000000000..eabd4e0f36 --- /dev/null +++ b/lib/services/kustoManagement/lib/models/index.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +/* 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.TrustedExternalTenant = require('./trustedExternalTenant'); +exports.AzureSku = require('./azureSku'); +exports.AzureCapacity = require('./azureCapacity'); +exports.AzureResourceSku = require('./azureResourceSku'); +exports.DatabaseStatistics = require('./databaseStatistics'); +exports.EventHubConnectionValidation = require('./eventHubConnectionValidation'); +exports.Resource = require('./resource'); +exports.TrackedResource = require('./trackedResource'); +exports.Cluster = require('./cluster'); +exports.ClusterUpdate = require('./clusterUpdate'); +exports.Database = require('./database'); +exports.DatabaseUpdate = require('./databaseUpdate'); +exports.DatabasePrincipal = require('./databasePrincipal'); +exports.ProxyResource = require('./proxyResource'); +exports.EventHubConnectionUpdate = require('./eventHubConnectionUpdate'); +exports.EventHubConnection = require('./eventHubConnection'); +exports.EventHubConnectionValidationResult = require('./eventHubConnectionValidationResult'); +exports.DatabasePrincipalListRequest = require('./databasePrincipalListRequest'); +exports.EventHubConnectionValidationListResult = require('./eventHubConnectionValidationListResult'); +exports.ClusterCheckNameRequest = require('./clusterCheckNameRequest'); +exports.DatabaseCheckNameRequest = require('./databaseCheckNameRequest'); +exports.CheckNameResult = require('./checkNameResult'); +exports.OperationDisplay = require('./operationDisplay'); +exports.Operation = require('./operation'); +exports.AzureEntityResource = require('./azureEntityResource'); +exports.ClusterListResult = require('./clusterListResult'); +exports.ListSkusResult = require('./listSkusResult'); +exports.ListResourceSkusResult = require('./listResourceSkusResult'); +exports.DatabaseListResult = require('./databaseListResult'); +exports.DatabasePrincipalListResult = require('./databasePrincipalListResult'); +exports.EventHubConnectionListResult = require('./eventHubConnectionListResult'); +exports.OperationListResult = require('./operationListResult'); diff --git a/lib/services/kustoManagement/lib/models/listResourceSkusResult.js b/lib/services/kustoManagement/lib/models/listResourceSkusResult.js new file mode 100644 index 0000000000..62068e2b53 --- /dev/null +++ b/lib/services/kustoManagement/lib/models/listResourceSkusResult.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'; + +/** + * List of available SKUs for an existing Kusto Cluster. + */ +class ListResourceSkusResult extends Array { + /** + * Create a ListResourceSkusResult. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ListResourceSkusResult + * + * @returns {object} metadata of ListResourceSkusResult + * + */ + mapper() { + return { + required: false, + serializedName: 'ListResourceSkusResult', + type: { + name: 'Composite', + className: 'ListResourceSkusResult', + modelProperties: { + value: { + required: false, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'AzureResourceSkuElementType', + type: { + name: 'Composite', + className: 'AzureResourceSku' + } + } + } + } + } + } + }; + } +} + +module.exports = ListResourceSkusResult; diff --git a/lib/services/kustoManagement/lib/models/listSkusResult.js b/lib/services/kustoManagement/lib/models/listSkusResult.js new file mode 100644 index 0000000000..111a04b054 --- /dev/null +++ b/lib/services/kustoManagement/lib/models/listSkusResult.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'; + +/** + * List of available SKUs for a new Kusto Cluster. + */ +class ListSkusResult extends Array { + /** + * Create a ListSkusResult. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ListSkusResult + * + * @returns {object} metadata of ListSkusResult + * + */ + mapper() { + return { + required: false, + serializedName: 'ListSkusResult', + type: { + name: 'Composite', + className: 'ListSkusResult', + modelProperties: { + value: { + required: false, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'AzureSkuElementType', + type: { + name: 'Composite', + className: 'AzureSku' + } + } + } + } + } + } + }; + } +} + +module.exports = ListSkusResult; diff --git a/lib/services/kustoManagement/lib/models/operation.js b/lib/services/kustoManagement/lib/models/operation.js new file mode 100644 index 0000000000..6ae00902ac --- /dev/null +++ b/lib/services/kustoManagement/lib/models/operation.js @@ -0,0 +1,82 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * @summary A REST API operation + * + */ +class Operation { + /** + * Create a Operation. + * @property {string} [name] The operation name. This is of the format + * {provider}/{resource}/{operation}. + * @property {object} [display] The object that describes the operation. + * @property {string} [display.provider] + * @property {string} [display.operation] For example: read, write, delete. + * @property {string} [display.resource] + * @property {string} [display.description] + * @property {string} [origin] The intended executor of the operation. + * @property {object} [properties] Properties of the operation. + */ + 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' + } + }, + origin: { + required: false, + serializedName: 'origin', + type: { + name: 'String' + } + }, + properties: { + required: false, + serializedName: 'properties', + type: { + name: 'Object' + } + } + } + } + }; + } +} + +module.exports = Operation; diff --git a/lib/services/kustoManagement/lib/models/operationDisplay.js b/lib/services/kustoManagement/lib/models/operationDisplay.js new file mode 100644 index 0000000000..889bff3f1c --- /dev/null +++ b/lib/services/kustoManagement/lib/models/operationDisplay.js @@ -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. + */ + +'use strict'; + +/** + * @summary The object that describes the operation. + * + */ +class OperationDisplay { + /** + * Create a OperationDisplay. + * @property {string} [provider] Friendly name of the resource provider. + * @property {string} [operation] The operation type. For example: read, + * write, delete. + * @property {string} [resource] The resource type on which the operation is + * performed. + * @property {string} [description] The friendly name of the operation. + */ + 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' + } + }, + operation: { + required: false, + serializedName: 'operation', + type: { + name: 'String' + } + }, + resource: { + required: false, + serializedName: 'resource', + type: { + name: 'String' + } + }, + description: { + required: false, + serializedName: 'description', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = OperationDisplay; diff --git a/lib/services/kustoManagement/lib/models/operationListResult.js b/lib/services/kustoManagement/lib/models/operationListResult.js new file mode 100644 index 0000000000..45b95bc658 --- /dev/null +++ b/lib/services/kustoManagement/lib/models/operationListResult.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'; + +/** + * @summary Result of the request to list REST API operations. It contains a + * list of operations and a URL nextLink to get the next set of results. + */ +class OperationListResult extends Array { + /** + * Create a OperationListResult. + * @property {string} [nextLink] + */ + 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/kustoManagement/lib/models/proxyResource.js b/lib/services/kustoManagement/lib/models/proxyResource.js new file mode 100644 index 0000000000..43e93ec60e --- /dev/null +++ b/lib/services/kustoManagement/lib/models/proxyResource.js @@ -0,0 +1,73 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * The resource model definition for a ARM proxy resource. It will have + * everything other than required location and tags + * + * @extends models['Resource'] + */ +class ProxyResource extends models['Resource'] { + /** + * Create a ProxyResource. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ProxyResource + * + * @returns {object} metadata of ProxyResource + * + */ + mapper() { + return { + required: false, + serializedName: 'ProxyResource', + type: { + name: 'Composite', + className: 'ProxyResource', + 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' + } + } + } + } + }; + } +} + +module.exports = ProxyResource; diff --git a/lib/services/kustoManagement/lib/models/resource.js b/lib/services/kustoManagement/lib/models/resource.js new file mode 100644 index 0000000000..8dc0265e3c --- /dev/null +++ b/lib/services/kustoManagement/lib/models/resource.js @@ -0,0 +1,76 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Class representing a Resource. + * @extends models['BaseResource'] + */ +class Resource extends models['BaseResource'] { + /** + * Create a Resource. + * @property {string} [id] Fully qualified resource Id for the resource. Ex - + * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + * @property {string} [name] The name of the resource + * @property {string} [type] The type of the resource. Ex- + * Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + */ + 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' + } + } + } + } + }; + } +} + +module.exports = Resource; diff --git a/lib/services/kustoManagement/lib/models/trackedResource.js b/lib/services/kustoManagement/lib/models/trackedResource.js new file mode 100644 index 0000000000..d74a5106d9 --- /dev/null +++ b/lib/services/kustoManagement/lib/models/trackedResource.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'; + +const models = require('./index'); + +/** + * The resource model definition for a ARM tracked top level resource + * + * @extends models['Resource'] + */ +class TrackedResource extends models['Resource'] { + /** + * Create a TrackedResource. + * @property {object} [tags] Resource tags. + * @property {string} location The geo-location where the resource lives + */ + constructor() { + super(); + } + + /** + * Defines the metadata of TrackedResource + * + * @returns {object} metadata of TrackedResource + * + */ + mapper() { + return { + required: false, + serializedName: 'TrackedResource', + type: { + name: 'Composite', + className: 'TrackedResource', + 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' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + location: { + required: true, + serializedName: 'location', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = TrackedResource; diff --git a/lib/services/kustoManagement/lib/models/trustedExternalTenant.js b/lib/services/kustoManagement/lib/models/trustedExternalTenant.js new file mode 100644 index 0000000000..63902b764d --- /dev/null +++ b/lib/services/kustoManagement/lib/models/trustedExternalTenant.js @@ -0,0 +1,51 @@ +/* + * 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'; + +/** + * Class representing a TrustedExternalTenant. + */ +class TrustedExternalTenant { + /** + * Create a TrustedExternalTenant. + * @property {string} [value] GUID representing an external tenant. + */ + constructor() { + } + + /** + * Defines the metadata of TrustedExternalTenant + * + * @returns {object} metadata of TrustedExternalTenant + * + */ + mapper() { + return { + required: false, + serializedName: 'TrustedExternalTenant', + type: { + name: 'Composite', + className: 'TrustedExternalTenant', + modelProperties: { + value: { + required: false, + serializedName: 'value', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = TrustedExternalTenant; diff --git a/lib/services/kustoManagement/lib/operations/clusters.js b/lib/services/kustoManagement/lib/operations/clusters.js new file mode 100644 index 0000000000..e9241e3a10 --- /dev/null +++ b/lib/services/kustoManagement/lib/operations/clusters.js @@ -0,0 +1,3601 @@ +/* + * 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 Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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 Cluster} for more information. + * + * {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, clusterName, 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 (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') { + throw new Error('clusterName 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.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName)); + 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['Cluster']().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 or update a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} parameters The Kusto cluster parameters supplied to the + * CreateOrUpdate operation. + * + * @param {object} parameters.sku The SKU of the cluster. + * + * @param {string} parameters.sku.name SKU name. Possible values include: + * 'KC8', 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * + * @param {number} [parameters.sku.capacity] SKU capacity. + * + * @param {array} [parameters.trustedExternalTenants] The cluster's external + * tenants. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location The geo-location where the resource + * lives + * + * @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 Cluster} for more information. + * + * {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, clusterName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + + if (!callback) { + throw new Error('callback cannot be null.'); + } + + // Send request + this.beginCreateOrUpdate(resourceGroupName, clusterName, parameters, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Cluster']().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 a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} parameters The Kusto cluster parameters supplied to the + * Update operation. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} [parameters.location] Resource location. + * + * @param {object} [parameters.sku] The SKU of the cluster. + * + * @param {string} parameters.sku.name SKU name. Possible values include: + * 'KC8', 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * + * @param {number} [parameters.sku.capacity] SKU capacity. + * + * @param {array} [parameters.trustedExternalTenants] The cluster's external + * tenants. + * + * @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 Cluster} for more information. + * + * {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, clusterName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + + if (!callback) { + throw new Error('callback cannot be null.'); + } + + // Send request + this.beginUpdate(resourceGroupName, clusterName, parameters, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Cluster']().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 Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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, clusterName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + + if (!callback) { + throw new Error('callback cannot be null.'); + } + + // Send request + this.beginDeleteMethod(resourceGroupName, clusterName, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + + return callback(null, result, httpRequest, response); + }); + }); +} + + +/** + * Stops a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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 _stop(resourceGroupName, clusterName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + + if (!callback) { + throw new Error('callback cannot be null.'); + } + + // Send request + this.beginStop(resourceGroupName, clusterName, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + + return callback(null, result, httpRequest, response); + }); + }); +} + + +/** + * Starts a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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 _start(resourceGroupName, clusterName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + + if (!callback) { + throw new Error('callback cannot be null.'); + } + + // Send request + this.beginStart(resourceGroupName, clusterName, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + + return callback(null, result, httpRequest, response); + }); + }); +} + +/** + * Lists all Kusto clusters within a resource group. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @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 ClusterListResult} for more information. + * + * {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.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters'; + 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['ClusterListResult']().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 Kusto clusters 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 ClusterListResult} for more information. + * + * {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.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Kusto/clusters'; + 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['ClusterListResult']().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 eligible SKUs for Kusto resource provider. + * + * @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 ListSkusResult} for more information. + * + * {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 _listSkus(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.Kusto/skus'; + 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['ListSkusResult']().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); + }); +} + +/** + * Checks that the cluster name is valid and is not already in use. + * + * @param {string} location Azure location. + * + * @param {object} clusterName The name of the cluster. + * + * @param {string} clusterName.name Cluster name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link CheckNameResult} for more information. + * + * {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 _checkNameAvailability(location, clusterName, 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.'); + } + if (clusterName === null || clusterName === undefined) + { + clusterName = {}; + } + // 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 (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 (clusterName === null || clusterName === undefined) { + throw new Error('clusterName 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.Kusto/locations/{location}/checkNameAvailability'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{location}', encodeURIComponent(location)); + 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 (clusterName !== null && clusterName !== undefined) { + let requestModelMapper = new client.models['ClusterCheckNameRequest']().mapper(); + requestModel = client.serialize(requestModelMapper, clusterName, 'clusterName'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(clusterName, 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['CheckNameResult']().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); + }); +} + +/** + * Returns the SKUs available for the provided resource. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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 ListResourceSkusResult} for more + * information. + * + * {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 _listSkusByResource(resourceGroupName, clusterName, 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 (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') { + throw new Error('clusterName 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.Kusto/clusters/{clusterName}/skus'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName)); + 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['ListResourceSkusResult']().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 or update a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} parameters The Kusto cluster parameters supplied to the + * CreateOrUpdate operation. + * + * @param {object} parameters.sku The SKU of the cluster. + * + * @param {string} parameters.sku.name SKU name. Possible values include: + * 'KC8', 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * + * @param {number} [parameters.sku.capacity] SKU capacity. + * + * @param {array} [parameters.trustedExternalTenants] The cluster's external + * tenants. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location The geo-location where the resource + * lives + * + * @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 Cluster} for more information. + * + * {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 _beginCreateOrUpdate(resourceGroupName, clusterName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + if (parameters === null || parameters === undefined) + { + parameters = {}; + } + // 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 (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') { + throw new Error('clusterName cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName)); + 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 (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['Cluster']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 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) { + 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['Cluster']().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['Cluster']().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); + }); +} + +/** + * Update a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} parameters The Kusto cluster parameters supplied to the + * Update operation. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} [parameters.location] Resource location. + * + * @param {object} [parameters.sku] The SKU of the cluster. + * + * @param {string} parameters.sku.name SKU name. Possible values include: + * 'KC8', 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * + * @param {number} [parameters.sku.capacity] SKU capacity. + * + * @param {array} [parameters.trustedExternalTenants] The cluster's external + * tenants. + * + * @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 Cluster} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _beginUpdate(resourceGroupName, clusterName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + if (parameters === null || parameters === undefined) + { + parameters = {}; + } + // 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 (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') { + throw new Error('clusterName cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName)); + 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 (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['ClusterUpdate']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 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) { + 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['Cluster']().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['Cluster']().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); + }); +} + +/** + * Deletes a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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 _beginDeleteMethod(resourceGroupName, clusterName, 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 (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') { + throw new Error('clusterName 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.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName)); + 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 = '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 !== 202 && 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); + }); +} + +/** + * Stops a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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 _beginStop(resourceGroupName, clusterName, 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 (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') { + throw new Error('clusterName 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.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/stop'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName)); + 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 = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 202) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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); + }); +} + +/** + * Starts a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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 _beginStart(resourceGroupName, clusterName, 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 (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') { + throw new Error('clusterName 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.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/start'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName)); + 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 = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 202) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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 Clusters. */ +class Clusters { + /** + * Create a Clusters. + * @param {KustoManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + this._update = _update; + this._deleteMethod = _deleteMethod; + this._stop = _stop; + this._start = _start; + this._listByResourceGroup = _listByResourceGroup; + this._list = _list; + this._listSkus = _listSkus; + this._checkNameAvailability = _checkNameAvailability; + this._listSkusByResource = _listSkusByResource; + this._beginCreateOrUpdate = _beginCreateOrUpdate; + this._beginUpdate = _beginUpdate; + this._beginDeleteMethod = _beginDeleteMethod; + this._beginStop = _beginStop; + this._beginStart = _beginStart; + } + + /** + * Gets a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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, clusterName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, clusterName, 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 Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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 {Cluster} - 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 Cluster} for more information. + * + * {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, clusterName, 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, clusterName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, clusterName, options, optionalCallback); + } + } + + /** + * Create or update a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} parameters The Kusto cluster parameters supplied to the + * CreateOrUpdate operation. + * + * @param {object} parameters.sku The SKU of the cluster. + * + * @param {string} parameters.sku.name SKU name. Possible values include: + * 'KC8', 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * + * @param {number} [parameters.sku.capacity] SKU capacity. + * + * @param {array} [parameters.trustedExternalTenants] The cluster's external + * tenants. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location The geo-location where the resource + * lives + * + * @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, clusterName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, clusterName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Create or update a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} parameters The Kusto cluster parameters supplied to the + * CreateOrUpdate operation. + * + * @param {object} parameters.sku The SKU of the cluster. + * + * @param {string} parameters.sku.name SKU name. Possible values include: + * 'KC8', 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * + * @param {number} [parameters.sku.capacity] SKU capacity. + * + * @param {array} [parameters.trustedExternalTenants] The cluster's external + * tenants. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location The geo-location where the resource + * lives + * + * @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 {Cluster} - 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 Cluster} for more information. + * + * {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, clusterName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, clusterName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, clusterName, parameters, options, optionalCallback); + } + } + + /** + * Update a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} parameters The Kusto cluster parameters supplied to the + * Update operation. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} [parameters.location] Resource location. + * + * @param {object} [parameters.sku] The SKU of the cluster. + * + * @param {string} parameters.sku.name SKU name. Possible values include: + * 'KC8', 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * + * @param {number} [parameters.sku.capacity] SKU capacity. + * + * @param {array} [parameters.trustedExternalTenants] The cluster's external + * tenants. + * + * @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, clusterName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(resourceGroupName, clusterName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Update a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} parameters The Kusto cluster parameters supplied to the + * Update operation. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} [parameters.location] Resource location. + * + * @param {object} [parameters.sku] The SKU of the cluster. + * + * @param {string} parameters.sku.name SKU name. Possible values include: + * 'KC8', 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * + * @param {number} [parameters.sku.capacity] SKU capacity. + * + * @param {array} [parameters.trustedExternalTenants] The cluster's external + * tenants. + * + * @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 {Cluster} - 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 Cluster} for more information. + * + * {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, clusterName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._update(resourceGroupName, clusterName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(resourceGroupName, clusterName, parameters, options, optionalCallback); + } + } + + /** + * Deletes a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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, clusterName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, clusterName, 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 Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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, clusterName, 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, clusterName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, clusterName, options, optionalCallback); + } + } + + /** + * Stops a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + stopWithHttpOperationResponse(resourceGroupName, clusterName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._stop(resourceGroupName, clusterName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Stops a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + stop(resourceGroupName, clusterName, 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._stop(resourceGroupName, clusterName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._stop(resourceGroupName, clusterName, options, optionalCallback); + } + } + + /** + * Starts a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + startWithHttpOperationResponse(resourceGroupName, clusterName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._start(resourceGroupName, clusterName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Starts a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + start(resourceGroupName, clusterName, 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._start(resourceGroupName, clusterName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._start(resourceGroupName, clusterName, options, optionalCallback); + } + } + + /** + * Lists all Kusto clusters within a resource group. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @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; + }); + }); + } + + /** + * Lists all Kusto clusters within a resource group. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @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 {ClusterListResult} - 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 ClusterListResult} for more information. + * + * {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); + } + } + + /** + * Lists all Kusto clusters 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; + }); + }); + } + + /** + * Lists all Kusto clusters 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 {ClusterListResult} - 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 ClusterListResult} for more information. + * + * {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 eligible SKUs for Kusto resource provider. + * + * @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. + */ + listSkusWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listSkus(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists eligible SKUs for Kusto resource provider. + * + * @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 {ListSkusResult} - 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 ListSkusResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listSkus(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._listSkus(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listSkus(options, optionalCallback); + } + } + + /** + * Checks that the cluster name is valid and is not already in use. + * + * @param {string} location Azure location. + * + * @param {object} clusterName The name of the cluster. + * + * @param {string} clusterName.name Cluster name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + checkNameAvailabilityWithHttpOperationResponse(location, clusterName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._checkNameAvailability(location, clusterName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Checks that the cluster name is valid and is not already in use. + * + * @param {string} location Azure location. + * + * @param {object} clusterName The name of the cluster. + * + * @param {string} clusterName.name Cluster name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {CheckNameResult} - 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 CheckNameResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + checkNameAvailability(location, clusterName, 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._checkNameAvailability(location, clusterName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._checkNameAvailability(location, clusterName, options, optionalCallback); + } + } + + /** + * Returns the SKUs available for the provided resource. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + listSkusByResourceWithHttpOperationResponse(resourceGroupName, clusterName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listSkusByResource(resourceGroupName, clusterName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Returns the SKUs available for the provided resource. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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 {ListResourceSkusResult} - 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 ListResourceSkusResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listSkusByResource(resourceGroupName, clusterName, 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._listSkusByResource(resourceGroupName, clusterName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listSkusByResource(resourceGroupName, clusterName, options, optionalCallback); + } + } + + /** + * Create or update a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} parameters The Kusto cluster parameters supplied to the + * CreateOrUpdate operation. + * + * @param {object} parameters.sku The SKU of the cluster. + * + * @param {string} parameters.sku.name SKU name. Possible values include: + * 'KC8', 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * + * @param {number} [parameters.sku.capacity] SKU capacity. + * + * @param {array} [parameters.trustedExternalTenants] The cluster's external + * tenants. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location The geo-location where the resource + * lives + * + * @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. + */ + beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName, clusterName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginCreateOrUpdate(resourceGroupName, clusterName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Create or update a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} parameters The Kusto cluster parameters supplied to the + * CreateOrUpdate operation. + * + * @param {object} parameters.sku The SKU of the cluster. + * + * @param {string} parameters.sku.name SKU name. Possible values include: + * 'KC8', 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * + * @param {number} [parameters.sku.capacity] SKU capacity. + * + * @param {array} [parameters.trustedExternalTenants] The cluster's external + * tenants. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location The geo-location where the resource + * lives + * + * @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 {Cluster} - 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 Cluster} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + beginCreateOrUpdate(resourceGroupName, clusterName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._beginCreateOrUpdate(resourceGroupName, clusterName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginCreateOrUpdate(resourceGroupName, clusterName, parameters, options, optionalCallback); + } + } + + /** + * Update a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} parameters The Kusto cluster parameters supplied to the + * Update operation. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} [parameters.location] Resource location. + * + * @param {object} [parameters.sku] The SKU of the cluster. + * + * @param {string} parameters.sku.name SKU name. Possible values include: + * 'KC8', 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * + * @param {number} [parameters.sku.capacity] SKU capacity. + * + * @param {array} [parameters.trustedExternalTenants] The cluster's external + * tenants. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + beginUpdateWithHttpOperationResponse(resourceGroupName, clusterName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginUpdate(resourceGroupName, clusterName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Update a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} parameters The Kusto cluster parameters supplied to the + * Update operation. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} [parameters.location] Resource location. + * + * @param {object} [parameters.sku] The SKU of the cluster. + * + * @param {string} parameters.sku.name SKU name. Possible values include: + * 'KC8', 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * + * @param {number} [parameters.sku.capacity] SKU capacity. + * + * @param {array} [parameters.trustedExternalTenants] The cluster's external + * tenants. + * + * @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 {Cluster} - 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 Cluster} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + beginUpdate(resourceGroupName, clusterName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._beginUpdate(resourceGroupName, clusterName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginUpdate(resourceGroupName, clusterName, parameters, options, optionalCallback); + } + } + + /** + * Deletes a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + beginDeleteMethodWithHttpOperationResponse(resourceGroupName, clusterName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginDeleteMethod(resourceGroupName, clusterName, 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 Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + beginDeleteMethod(resourceGroupName, clusterName, 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._beginDeleteMethod(resourceGroupName, clusterName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginDeleteMethod(resourceGroupName, clusterName, options, optionalCallback); + } + } + + /** + * Stops a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + beginStopWithHttpOperationResponse(resourceGroupName, clusterName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginStop(resourceGroupName, clusterName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Stops a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + beginStop(resourceGroupName, clusterName, 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._beginStop(resourceGroupName, clusterName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginStop(resourceGroupName, clusterName, options, optionalCallback); + } + } + + /** + * Starts a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + beginStartWithHttpOperationResponse(resourceGroupName, clusterName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginStart(resourceGroupName, clusterName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Starts a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + beginStart(resourceGroupName, clusterName, 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._beginStart(resourceGroupName, clusterName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginStart(resourceGroupName, clusterName, options, optionalCallback); + } + } + +} + +module.exports = Clusters; diff --git a/lib/services/kustoManagement/lib/operations/databases.js b/lib/services/kustoManagement/lib/operations/databases.js new file mode 100644 index 0000000000..1cebc2a5ca --- /dev/null +++ b/lib/services/kustoManagement/lib/operations/databases.js @@ -0,0 +1,3088 @@ +/* + * 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; + +/** + * Checks that the database name is valid and is not already in use. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} databaseName The name of the database. + * + * @param {string} databaseName.name Database name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link CheckNameResult} for more information. + * + * {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 _checkNameAvailability(resourceGroupName, clusterName, databaseName, 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.'); + } + if (databaseName === null || databaseName === undefined) + { + databaseName = {}; + } + // 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 (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') { + throw new Error('clusterName 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 (databaseName === null || databaseName === undefined) { + throw new Error('databaseName 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.Kusto/clusters/{clusterName}/checkNameAvailability'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName)); + 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 = '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 (databaseName !== null && databaseName !== undefined) { + let requestModelMapper = new client.models['DatabaseCheckNameRequest']().mapper(); + requestModel = client.serialize(requestModelMapper, databaseName, 'databaseName'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(databaseName, 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['CheckNameResult']().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); + }); +} + +/** + * Returns the list of databases of the given Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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 DatabaseListResult} for more information. + * + * {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 _listByCluster(resourceGroupName, clusterName, 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 (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') { + throw new Error('clusterName 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.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName)); + 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['DatabaseListResult']().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); + }); +} + +/** + * Returns a database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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 Database} for more information. + * + * {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, clusterName, databaseName, 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 (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') { + throw new Error('clusterName cannot be null or undefined and it must be of type string.'); + } + if (databaseName === null || databaseName === undefined || typeof databaseName.valueOf() !== 'string') { + throw new Error('databaseName 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.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName)); + requestUrl = requestUrl.replace('{databaseName}', encodeURIComponent(databaseName)); + 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['Database']().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 a database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The database parameters supplied to the + * CreateOrUpdate operation. + * + * @param {number} parameters.softDeletePeriodInDays The number of days data + * should be kept before it stops being accessible to queries. + * + * @param {number} [parameters.hotCachePeriodInDays] The number of days of data + * that should be kept in cache for fast queries. + * + * @param {object} [parameters.statistics] The statistics of the database. + * + * @param {number} [parameters.statistics.size] The database size - the total + * size of compressed data and index in bytes. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location The geo-location where the resource + * lives + * + * @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 Database} for more information. + * + * {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, clusterName, databaseName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + + if (!callback) { + throw new Error('callback cannot be null.'); + } + + // Send request + this.beginCreateOrUpdate(resourceGroupName, clusterName, databaseName, parameters, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Database']().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 database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The database parameters supplied to the Update + * operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {number} parameters.softDeletePeriodInDays The number of days data + * should be kept before it stops being accessible to queries. + * + * @param {number} [parameters.hotCachePeriodInDays] The number of days of data + * that should be kept in cache for fast queries. + * + * @param {object} [parameters.statistics] The statistics of the database. + * + * @param {number} [parameters.statistics.size] The database size - the total + * size of compressed data and index in bytes. + * + * @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 Database} for more information. + * + * {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, clusterName, databaseName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + + if (!callback) { + throw new Error('callback cannot be null.'); + } + + // Send request + this.beginUpdate(resourceGroupName, clusterName, databaseName, parameters, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Database']().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 the database with the given name. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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, clusterName, databaseName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + + if (!callback) { + throw new Error('callback cannot be null.'); + } + + // Send request + this.beginDeleteMethod(resourceGroupName, clusterName, databaseName, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + + return callback(null, result, httpRequest, response); + }); + }); +} + +/** + * Returns a list of database principals of the given Kusto cluster and + * database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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 DatabasePrincipalListResult} for more + * information. + * + * {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 _listPrincipals(resourceGroupName, clusterName, databaseName, 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 (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') { + throw new Error('clusterName cannot be null or undefined and it must be of type string.'); + } + if (databaseName === null || databaseName === undefined || typeof databaseName.valueOf() !== 'string') { + throw new Error('databaseName 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.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/listPrincipals'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName)); + requestUrl = requestUrl.replace('{databaseName}', encodeURIComponent(databaseName)); + 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 = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['DatabasePrincipalListResult']().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); + }); +} + +/** + * Add Database principals permissions. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} databasePrincipalsToAdd List of database principals to add. + * + * @param {array} [databasePrincipalsToAdd.value] The list of Kusto database + * principals. + * + * @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 DatabasePrincipalListResult} for more + * information. + * + * {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 _addPrincipals(resourceGroupName, clusterName, databaseName, databasePrincipalsToAdd, 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 (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') { + throw new Error('clusterName cannot be null or undefined and it must be of type string.'); + } + if (databaseName === null || databaseName === undefined || typeof databaseName.valueOf() !== 'string') { + throw new Error('databaseName 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 (databasePrincipalsToAdd === null || databasePrincipalsToAdd === undefined) { + throw new Error('databasePrincipalsToAdd 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.Kusto/clusters/{clusterName}/databases/{databaseName}/addPrincipals'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName)); + requestUrl = requestUrl.replace('{databaseName}', encodeURIComponent(databaseName)); + 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 = '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 (databasePrincipalsToAdd !== null && databasePrincipalsToAdd !== undefined) { + let requestModelMapper = new client.models['DatabasePrincipalListRequest']().mapper(); + requestModel = client.serialize(requestModelMapper, databasePrincipalsToAdd, 'databasePrincipalsToAdd'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(databasePrincipalsToAdd, 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['DatabasePrincipalListResult']().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 Database principals permissions. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} databasePrincipalsToRemove List of database principals to + * remove. + * + * @param {array} [databasePrincipalsToRemove.value] The list of Kusto database + * principals. + * + * @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 DatabasePrincipalListResult} for more + * information. + * + * {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 _removePrincipals(resourceGroupName, clusterName, databaseName, databasePrincipalsToRemove, 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 (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') { + throw new Error('clusterName cannot be null or undefined and it must be of type string.'); + } + if (databaseName === null || databaseName === undefined || typeof databaseName.valueOf() !== 'string') { + throw new Error('databaseName 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 (databasePrincipalsToRemove === null || databasePrincipalsToRemove === undefined) { + throw new Error('databasePrincipalsToRemove 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.Kusto/clusters/{clusterName}/databases/{databaseName}/removePrincipals'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName)); + requestUrl = requestUrl.replace('{databaseName}', encodeURIComponent(databaseName)); + 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 = '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 (databasePrincipalsToRemove !== null && databasePrincipalsToRemove !== undefined) { + let requestModelMapper = new client.models['DatabasePrincipalListRequest']().mapper(); + requestModel = client.serialize(requestModelMapper, databasePrincipalsToRemove, 'databasePrincipalsToRemove'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(databasePrincipalsToRemove, 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['DatabasePrincipalListResult']().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 a database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The database parameters supplied to the + * CreateOrUpdate operation. + * + * @param {number} parameters.softDeletePeriodInDays The number of days data + * should be kept before it stops being accessible to queries. + * + * @param {number} [parameters.hotCachePeriodInDays] The number of days of data + * that should be kept in cache for fast queries. + * + * @param {object} [parameters.statistics] The statistics of the database. + * + * @param {number} [parameters.statistics.size] The database size - the total + * size of compressed data and index in bytes. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location The geo-location where the resource + * lives + * + * @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 Database} for more information. + * + * {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 _beginCreateOrUpdate(resourceGroupName, clusterName, databaseName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (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 (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') { + throw new Error('clusterName cannot be null or undefined and it must be of type string.'); + } + if (databaseName === null || databaseName === undefined || typeof databaseName.valueOf() !== 'string') { + throw new Error('databaseName cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName)); + requestUrl = requestUrl.replace('{databaseName}', encodeURIComponent(databaseName)); + 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 (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['Database']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201 && statusCode !== 202) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['Database']().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['Database']().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 database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The database parameters supplied to the Update + * operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {number} parameters.softDeletePeriodInDays The number of days data + * should be kept before it stops being accessible to queries. + * + * @param {number} [parameters.hotCachePeriodInDays] The number of days of data + * that should be kept in cache for fast queries. + * + * @param {object} [parameters.statistics] The statistics of the database. + * + * @param {number} [parameters.statistics.size] The database size - the total + * size of compressed data and index in bytes. + * + * @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 Database} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _beginUpdate(resourceGroupName, clusterName, databaseName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (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 (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') { + throw new Error('clusterName cannot be null or undefined and it must be of type string.'); + } + if (databaseName === null || databaseName === undefined || typeof databaseName.valueOf() !== 'string') { + throw new Error('databaseName cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName)); + requestUrl = requestUrl.replace('{databaseName}', encodeURIComponent(databaseName)); + 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 (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['DatabaseUpdate']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201 && statusCode !== 202) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['Database']().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['Database']().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); + }); +} + +/** + * Deletes the database with the given name. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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 _beginDeleteMethod(resourceGroupName, clusterName, databaseName, 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 (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') { + throw new Error('clusterName cannot be null or undefined and it must be of type string.'); + } + if (databaseName === null || databaseName === undefined || typeof databaseName.valueOf() !== 'string') { + throw new Error('databaseName 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.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName)); + requestUrl = requestUrl.replace('{databaseName}', encodeURIComponent(databaseName)); + 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 = '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 !== 202 && 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); + }); +} + +/** Class representing a Databases. */ +class Databases { + /** + * Create a Databases. + * @param {KustoManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._checkNameAvailability = _checkNameAvailability; + this._listByCluster = _listByCluster; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + this._update = _update; + this._deleteMethod = _deleteMethod; + this._listPrincipals = _listPrincipals; + this._addPrincipals = _addPrincipals; + this._removePrincipals = _removePrincipals; + this._beginCreateOrUpdate = _beginCreateOrUpdate; + this._beginUpdate = _beginUpdate; + this._beginDeleteMethod = _beginDeleteMethod; + } + + /** + * Checks that the database name is valid and is not already in use. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} databaseName The name of the database. + * + * @param {string} databaseName.name Database name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + checkNameAvailabilityWithHttpOperationResponse(resourceGroupName, clusterName, databaseName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._checkNameAvailability(resourceGroupName, clusterName, databaseName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Checks that the database name is valid and is not already in use. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} databaseName The name of the database. + * + * @param {string} databaseName.name Database name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {CheckNameResult} - 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 CheckNameResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + checkNameAvailability(resourceGroupName, clusterName, databaseName, 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._checkNameAvailability(resourceGroupName, clusterName, databaseName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._checkNameAvailability(resourceGroupName, clusterName, databaseName, options, optionalCallback); + } + } + + /** + * Returns the list of databases of the given Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + listByClusterWithHttpOperationResponse(resourceGroupName, clusterName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByCluster(resourceGroupName, clusterName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Returns the list of databases of the given Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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 {DatabaseListResult} - 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 DatabaseListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByCluster(resourceGroupName, clusterName, 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._listByCluster(resourceGroupName, clusterName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByCluster(resourceGroupName, clusterName, options, optionalCallback); + } + } + + /** + * Returns a database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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, clusterName, databaseName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, clusterName, databaseName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Returns a database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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 {Database} - 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 Database} for more information. + * + * {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, clusterName, databaseName, 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, clusterName, databaseName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, clusterName, databaseName, options, optionalCallback); + } + } + + /** + * Creates or updates a database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The database parameters supplied to the + * CreateOrUpdate operation. + * + * @param {number} parameters.softDeletePeriodInDays The number of days data + * should be kept before it stops being accessible to queries. + * + * @param {number} [parameters.hotCachePeriodInDays] The number of days of data + * that should be kept in cache for fast queries. + * + * @param {object} [parameters.statistics] The statistics of the database. + * + * @param {number} [parameters.statistics.size] The database size - the total + * size of compressed data and index in bytes. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location The geo-location where the resource + * lives + * + * @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, clusterName, databaseName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, clusterName, databaseName, parameters, 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 a database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The database parameters supplied to the + * CreateOrUpdate operation. + * + * @param {number} parameters.softDeletePeriodInDays The number of days data + * should be kept before it stops being accessible to queries. + * + * @param {number} [parameters.hotCachePeriodInDays] The number of days of data + * that should be kept in cache for fast queries. + * + * @param {object} [parameters.statistics] The statistics of the database. + * + * @param {number} [parameters.statistics.size] The database size - the total + * size of compressed data and index in bytes. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location The geo-location where the resource + * lives + * + * @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 {Database} - 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 Database} for more information. + * + * {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, clusterName, databaseName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, clusterName, databaseName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, clusterName, databaseName, parameters, options, optionalCallback); + } + } + + /** + * Updates a database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The database parameters supplied to the Update + * operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {number} parameters.softDeletePeriodInDays The number of days data + * should be kept before it stops being accessible to queries. + * + * @param {number} [parameters.hotCachePeriodInDays] The number of days of data + * that should be kept in cache for fast queries. + * + * @param {object} [parameters.statistics] The statistics of the database. + * + * @param {number} [parameters.statistics.size] The database size - the total + * size of compressed data and index in bytes. + * + * @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, clusterName, databaseName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(resourceGroupName, clusterName, databaseName, parameters, 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 database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The database parameters supplied to the Update + * operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {number} parameters.softDeletePeriodInDays The number of days data + * should be kept before it stops being accessible to queries. + * + * @param {number} [parameters.hotCachePeriodInDays] The number of days of data + * that should be kept in cache for fast queries. + * + * @param {object} [parameters.statistics] The statistics of the database. + * + * @param {number} [parameters.statistics.size] The database size - the total + * size of compressed data and index in bytes. + * + * @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 {Database} - 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 Database} for more information. + * + * {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, clusterName, databaseName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._update(resourceGroupName, clusterName, databaseName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(resourceGroupName, clusterName, databaseName, parameters, options, optionalCallback); + } + } + + /** + * Deletes the database with the given name. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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, clusterName, databaseName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, clusterName, databaseName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Deletes the database with the given name. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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, clusterName, databaseName, 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, clusterName, databaseName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, clusterName, databaseName, options, optionalCallback); + } + } + + /** + * Returns a list of database principals of the given Kusto cluster and + * database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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. + */ + listPrincipalsWithHttpOperationResponse(resourceGroupName, clusterName, databaseName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listPrincipals(resourceGroupName, clusterName, databaseName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Returns a list of database principals of the given Kusto cluster and + * database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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 {DatabasePrincipalListResult} - 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 DatabasePrincipalListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listPrincipals(resourceGroupName, clusterName, databaseName, 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._listPrincipals(resourceGroupName, clusterName, databaseName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listPrincipals(resourceGroupName, clusterName, databaseName, options, optionalCallback); + } + } + + /** + * Add Database principals permissions. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} databasePrincipalsToAdd List of database principals to add. + * + * @param {array} [databasePrincipalsToAdd.value] The list of Kusto database + * principals. + * + * @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. + */ + addPrincipalsWithHttpOperationResponse(resourceGroupName, clusterName, databaseName, databasePrincipalsToAdd, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._addPrincipals(resourceGroupName, clusterName, databaseName, databasePrincipalsToAdd, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Add Database principals permissions. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} databasePrincipalsToAdd List of database principals to add. + * + * @param {array} [databasePrincipalsToAdd.value] The list of Kusto database + * principals. + * + * @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 {DatabasePrincipalListResult} - 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 DatabasePrincipalListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + addPrincipals(resourceGroupName, clusterName, databaseName, databasePrincipalsToAdd, 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._addPrincipals(resourceGroupName, clusterName, databaseName, databasePrincipalsToAdd, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._addPrincipals(resourceGroupName, clusterName, databaseName, databasePrincipalsToAdd, options, optionalCallback); + } + } + + /** + * Remove Database principals permissions. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} databasePrincipalsToRemove List of database principals to + * remove. + * + * @param {array} [databasePrincipalsToRemove.value] The list of Kusto database + * principals. + * + * @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. + */ + removePrincipalsWithHttpOperationResponse(resourceGroupName, clusterName, databaseName, databasePrincipalsToRemove, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._removePrincipals(resourceGroupName, clusterName, databaseName, databasePrincipalsToRemove, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Remove Database principals permissions. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} databasePrincipalsToRemove List of database principals to + * remove. + * + * @param {array} [databasePrincipalsToRemove.value] The list of Kusto database + * principals. + * + * @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 {DatabasePrincipalListResult} - 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 DatabasePrincipalListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + removePrincipals(resourceGroupName, clusterName, databaseName, databasePrincipalsToRemove, 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._removePrincipals(resourceGroupName, clusterName, databaseName, databasePrincipalsToRemove, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._removePrincipals(resourceGroupName, clusterName, databaseName, databasePrincipalsToRemove, options, optionalCallback); + } + } + + /** + * Creates or updates a database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The database parameters supplied to the + * CreateOrUpdate operation. + * + * @param {number} parameters.softDeletePeriodInDays The number of days data + * should be kept before it stops being accessible to queries. + * + * @param {number} [parameters.hotCachePeriodInDays] The number of days of data + * that should be kept in cache for fast queries. + * + * @param {object} [parameters.statistics] The statistics of the database. + * + * @param {number} [parameters.statistics.size] The database size - the total + * size of compressed data and index in bytes. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location The geo-location where the resource + * lives + * + * @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. + */ + beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName, clusterName, databaseName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginCreateOrUpdate(resourceGroupName, clusterName, databaseName, parameters, 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 a database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The database parameters supplied to the + * CreateOrUpdate operation. + * + * @param {number} parameters.softDeletePeriodInDays The number of days data + * should be kept before it stops being accessible to queries. + * + * @param {number} [parameters.hotCachePeriodInDays] The number of days of data + * that should be kept in cache for fast queries. + * + * @param {object} [parameters.statistics] The statistics of the database. + * + * @param {number} [parameters.statistics.size] The database size - the total + * size of compressed data and index in bytes. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location The geo-location where the resource + * lives + * + * @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 {Database} - 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 Database} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + beginCreateOrUpdate(resourceGroupName, clusterName, databaseName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._beginCreateOrUpdate(resourceGroupName, clusterName, databaseName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginCreateOrUpdate(resourceGroupName, clusterName, databaseName, parameters, options, optionalCallback); + } + } + + /** + * Updates a database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The database parameters supplied to the Update + * operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {number} parameters.softDeletePeriodInDays The number of days data + * should be kept before it stops being accessible to queries. + * + * @param {number} [parameters.hotCachePeriodInDays] The number of days of data + * that should be kept in cache for fast queries. + * + * @param {object} [parameters.statistics] The statistics of the database. + * + * @param {number} [parameters.statistics.size] The database size - the total + * size of compressed data and index in bytes. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + beginUpdateWithHttpOperationResponse(resourceGroupName, clusterName, databaseName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginUpdate(resourceGroupName, clusterName, databaseName, parameters, 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 database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The database parameters supplied to the Update + * operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {number} parameters.softDeletePeriodInDays The number of days data + * should be kept before it stops being accessible to queries. + * + * @param {number} [parameters.hotCachePeriodInDays] The number of days of data + * that should be kept in cache for fast queries. + * + * @param {object} [parameters.statistics] The statistics of the database. + * + * @param {number} [parameters.statistics.size] The database size - the total + * size of compressed data and index in bytes. + * + * @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 {Database} - 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 Database} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + beginUpdate(resourceGroupName, clusterName, databaseName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._beginUpdate(resourceGroupName, clusterName, databaseName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginUpdate(resourceGroupName, clusterName, databaseName, parameters, options, optionalCallback); + } + } + + /** + * Deletes the database with the given name. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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. + */ + beginDeleteMethodWithHttpOperationResponse(resourceGroupName, clusterName, databaseName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginDeleteMethod(resourceGroupName, clusterName, databaseName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Deletes the database with the given name. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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. + */ + beginDeleteMethod(resourceGroupName, clusterName, databaseName, 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._beginDeleteMethod(resourceGroupName, clusterName, databaseName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginDeleteMethod(resourceGroupName, clusterName, databaseName, options, optionalCallback); + } + } + +} + +module.exports = Databases; diff --git a/lib/services/kustoManagement/lib/operations/eventHubConnections.js b/lib/services/kustoManagement/lib/operations/eventHubConnections.js new file mode 100644 index 0000000000..f1b39442c9 --- /dev/null +++ b/lib/services/kustoManagement/lib/operations/eventHubConnections.js @@ -0,0 +1,2451 @@ +/* + * 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 the list of Event Hub connections of the given Kusto database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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 EventHubConnectionListResult} for more + * information. + * + * {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 _listByDatabase(resourceGroupName, clusterName, databaseName, 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 (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') { + throw new Error('clusterName cannot be null or undefined and it must be of type string.'); + } + if (databaseName === null || databaseName === undefined || typeof databaseName.valueOf() !== 'string') { + throw new Error('databaseName 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.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/eventhubconnections'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName)); + requestUrl = requestUrl.replace('{databaseName}', encodeURIComponent(databaseName)); + 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['EventHubConnectionListResult']().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); + }); +} + +/** + * Checks that the Event Hub data connection parameters are valid. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the CreateOrUpdate operation. + * + * @param {string} [parameters.eventhubConnectionName] The name of the event + * hub connection. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @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 EventHubConnectionValidationListResult} for + * more information. + * + * {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 _eventhubConnectionValidation(resourceGroupName, clusterName, databaseName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (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 (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') { + throw new Error('clusterName cannot be null or undefined and it must be of type string.'); + } + if (databaseName === null || databaseName === undefined || typeof databaseName.valueOf() !== 'string') { + throw new Error('databaseName 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 (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/eventhubConnectionValidation'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName)); + requestUrl = requestUrl.replace('{databaseName}', encodeURIComponent(databaseName)); + 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 = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['EventHubConnectionValidation']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['EventHubConnectionValidationListResult']().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); + }); +} + +/** + * Returns an Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @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 EventHubConnection} for more information. + * + * {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, clusterName, databaseName, eventHubConnectionName, 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 (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') { + throw new Error('clusterName cannot be null or undefined and it must be of type string.'); + } + if (databaseName === null || databaseName === undefined || typeof databaseName.valueOf() !== 'string') { + throw new Error('databaseName cannot be null or undefined and it must be of type string.'); + } + if (eventHubConnectionName === null || eventHubConnectionName === undefined || typeof eventHubConnectionName.valueOf() !== 'string') { + throw new Error('eventHubConnectionName 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.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/eventhubconnections/{eventHubConnectionName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName)); + requestUrl = requestUrl.replace('{databaseName}', encodeURIComponent(databaseName)); + requestUrl = requestUrl.replace('{eventHubConnectionName}', encodeURIComponent(eventHubConnectionName)); + 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['EventHubConnection']().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 a Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the CreateOrUpdate operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @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 EventHubConnection} for more information. + * + * {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, clusterName, databaseName, eventHubConnectionName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + + if (!callback) { + throw new Error('callback cannot be null.'); + } + + // Send request + this.beginCreateOrUpdate(resourceGroupName, clusterName, databaseName, eventHubConnectionName, parameters, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['EventHubConnection']().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 Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the Update operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @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 EventHubConnection} for more information. + * + * {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, clusterName, databaseName, eventHubConnectionName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + + if (!callback) { + throw new Error('callback cannot be null.'); + } + + // Send request + this.beginUpdate(resourceGroupName, clusterName, databaseName, eventHubConnectionName, parameters, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['EventHubConnection']().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 the Event Hub connection with the given name. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @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, clusterName, databaseName, eventHubConnectionName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + + if (!callback) { + throw new Error('callback cannot be null.'); + } + + // Send request + this.beginDeleteMethod(resourceGroupName, clusterName, databaseName, eventHubConnectionName, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + + return callback(null, result, httpRequest, response); + }); + }); +} + +/** + * Creates or updates a Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the CreateOrUpdate operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @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 EventHubConnection} for more information. + * + * {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 _beginCreateOrUpdate(resourceGroupName, clusterName, databaseName, eventHubConnectionName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (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 (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') { + throw new Error('clusterName cannot be null or undefined and it must be of type string.'); + } + if (databaseName === null || databaseName === undefined || typeof databaseName.valueOf() !== 'string') { + throw new Error('databaseName cannot be null or undefined and it must be of type string.'); + } + if (eventHubConnectionName === null || eventHubConnectionName === undefined || typeof eventHubConnectionName.valueOf() !== 'string') { + throw new Error('eventHubConnectionName cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/eventhubconnections/{eventHubConnectionName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName)); + requestUrl = requestUrl.replace('{databaseName}', encodeURIComponent(databaseName)); + requestUrl = requestUrl.replace('{eventHubConnectionName}', encodeURIComponent(eventHubConnectionName)); + 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 (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['EventHubConnection']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201 && statusCode !== 202) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['EventHubConnection']().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['EventHubConnection']().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 Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the Update operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @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 EventHubConnection} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _beginUpdate(resourceGroupName, clusterName, databaseName, eventHubConnectionName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (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 (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') { + throw new Error('clusterName cannot be null or undefined and it must be of type string.'); + } + if (databaseName === null || databaseName === undefined || typeof databaseName.valueOf() !== 'string') { + throw new Error('databaseName cannot be null or undefined and it must be of type string.'); + } + if (eventHubConnectionName === null || eventHubConnectionName === undefined || typeof eventHubConnectionName.valueOf() !== 'string') { + throw new Error('eventHubConnectionName cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/eventhubconnections/{eventHubConnectionName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName)); + requestUrl = requestUrl.replace('{databaseName}', encodeURIComponent(databaseName)); + requestUrl = requestUrl.replace('{eventHubConnectionName}', encodeURIComponent(eventHubConnectionName)); + 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 (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['EventHubConnectionUpdate']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201 && statusCode !== 202) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + 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['EventHubConnection']().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['EventHubConnection']().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); + }); +} + +/** + * Deletes the Event Hub connection with the given name. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @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 _beginDeleteMethod(resourceGroupName, clusterName, databaseName, eventHubConnectionName, 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 (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') { + throw new Error('clusterName cannot be null or undefined and it must be of type string.'); + } + if (databaseName === null || databaseName === undefined || typeof databaseName.valueOf() !== 'string') { + throw new Error('databaseName cannot be null or undefined and it must be of type string.'); + } + if (eventHubConnectionName === null || eventHubConnectionName === undefined || typeof eventHubConnectionName.valueOf() !== 'string') { + throw new Error('eventHubConnectionName 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.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/eventhubconnections/{eventHubConnectionName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName)); + requestUrl = requestUrl.replace('{databaseName}', encodeURIComponent(databaseName)); + requestUrl = requestUrl.replace('{eventHubConnectionName}', encodeURIComponent(eventHubConnectionName)); + 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 = '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 !== 202 && 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); + }); +} + +/** Class representing a EventHubConnections. */ +class EventHubConnections { + /** + * Create a EventHubConnections. + * @param {KustoManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._listByDatabase = _listByDatabase; + this._eventhubConnectionValidation = _eventhubConnectionValidation; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + this._update = _update; + this._deleteMethod = _deleteMethod; + this._beginCreateOrUpdate = _beginCreateOrUpdate; + this._beginUpdate = _beginUpdate; + this._beginDeleteMethod = _beginDeleteMethod; + } + + /** + * Returns the list of Event Hub connections of the given Kusto database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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. + */ + listByDatabaseWithHttpOperationResponse(resourceGroupName, clusterName, databaseName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByDatabase(resourceGroupName, clusterName, databaseName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Returns the list of Event Hub connections of the given Kusto database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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 {EventHubConnectionListResult} - 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 EventHubConnectionListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByDatabase(resourceGroupName, clusterName, databaseName, 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._listByDatabase(resourceGroupName, clusterName, databaseName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByDatabase(resourceGroupName, clusterName, databaseName, options, optionalCallback); + } + } + + /** + * Checks that the Event Hub data connection parameters are valid. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the CreateOrUpdate operation. + * + * @param {string} [parameters.eventhubConnectionName] The name of the event + * hub connection. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @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. + */ + eventhubConnectionValidationWithHttpOperationResponse(resourceGroupName, clusterName, databaseName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._eventhubConnectionValidation(resourceGroupName, clusterName, databaseName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Checks that the Event Hub data connection parameters are valid. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the CreateOrUpdate operation. + * + * @param {string} [parameters.eventhubConnectionName] The name of the event + * hub connection. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @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 {EventHubConnectionValidationListResult} - 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 EventHubConnectionValidationListResult} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + eventhubConnectionValidation(resourceGroupName, clusterName, databaseName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._eventhubConnectionValidation(resourceGroupName, clusterName, databaseName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._eventhubConnectionValidation(resourceGroupName, clusterName, databaseName, parameters, options, optionalCallback); + } + } + + /** + * Returns an Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @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, clusterName, databaseName, eventHubConnectionName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, clusterName, databaseName, eventHubConnectionName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Returns an Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @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 {EventHubConnection} - 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 EventHubConnection} for more information. + * + * {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, clusterName, databaseName, eventHubConnectionName, 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, clusterName, databaseName, eventHubConnectionName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, clusterName, databaseName, eventHubConnectionName, options, optionalCallback); + } + } + + /** + * Creates or updates a Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the CreateOrUpdate operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @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, clusterName, databaseName, eventHubConnectionName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, clusterName, databaseName, eventHubConnectionName, parameters, 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 a Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the CreateOrUpdate operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @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 {EventHubConnection} - 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 EventHubConnection} for more information. + * + * {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, clusterName, databaseName, eventHubConnectionName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, clusterName, databaseName, eventHubConnectionName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, clusterName, databaseName, eventHubConnectionName, parameters, options, optionalCallback); + } + } + + /** + * Updates a Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the Update operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @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, clusterName, databaseName, eventHubConnectionName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(resourceGroupName, clusterName, databaseName, eventHubConnectionName, parameters, 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 Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the Update operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @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 {EventHubConnection} - 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 EventHubConnection} for more information. + * + * {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, clusterName, databaseName, eventHubConnectionName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._update(resourceGroupName, clusterName, databaseName, eventHubConnectionName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(resourceGroupName, clusterName, databaseName, eventHubConnectionName, parameters, options, optionalCallback); + } + } + + /** + * Deletes the Event Hub connection with the given name. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @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, clusterName, databaseName, eventHubConnectionName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, clusterName, databaseName, eventHubConnectionName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Deletes the Event Hub connection with the given name. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @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, clusterName, databaseName, eventHubConnectionName, 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, clusterName, databaseName, eventHubConnectionName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, clusterName, databaseName, eventHubConnectionName, options, optionalCallback); + } + } + + /** + * Creates or updates a Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the CreateOrUpdate operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @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. + */ + beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName, clusterName, databaseName, eventHubConnectionName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginCreateOrUpdate(resourceGroupName, clusterName, databaseName, eventHubConnectionName, parameters, 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 a Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the CreateOrUpdate operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @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 {EventHubConnection} - 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 EventHubConnection} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + beginCreateOrUpdate(resourceGroupName, clusterName, databaseName, eventHubConnectionName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._beginCreateOrUpdate(resourceGroupName, clusterName, databaseName, eventHubConnectionName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginCreateOrUpdate(resourceGroupName, clusterName, databaseName, eventHubConnectionName, parameters, options, optionalCallback); + } + } + + /** + * Updates a Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the Update operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + beginUpdateWithHttpOperationResponse(resourceGroupName, clusterName, databaseName, eventHubConnectionName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginUpdate(resourceGroupName, clusterName, databaseName, eventHubConnectionName, parameters, 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 Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the Update operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @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 {EventHubConnection} - 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 EventHubConnection} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + beginUpdate(resourceGroupName, clusterName, databaseName, eventHubConnectionName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._beginUpdate(resourceGroupName, clusterName, databaseName, eventHubConnectionName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginUpdate(resourceGroupName, clusterName, databaseName, eventHubConnectionName, parameters, options, optionalCallback); + } + } + + /** + * Deletes the Event Hub connection with the given name. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @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. + */ + beginDeleteMethodWithHttpOperationResponse(resourceGroupName, clusterName, databaseName, eventHubConnectionName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginDeleteMethod(resourceGroupName, clusterName, databaseName, eventHubConnectionName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Deletes the Event Hub connection with the given name. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @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. + */ + beginDeleteMethod(resourceGroupName, clusterName, databaseName, eventHubConnectionName, 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._beginDeleteMethod(resourceGroupName, clusterName, databaseName, eventHubConnectionName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginDeleteMethod(resourceGroupName, clusterName, databaseName, eventHubConnectionName, options, optionalCallback); + } + } + +} + +module.exports = EventHubConnections; diff --git a/lib/services/kustoManagement/lib/operations/index.d.ts b/lib/services/kustoManagement/lib/operations/index.d.ts new file mode 100644 index 0000000000..473e0e99bb --- /dev/null +++ b/lib/services/kustoManagement/lib/operations/index.d.ts @@ -0,0 +1,3016 @@ +/* + * 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 + * Clusters + * __NOTE__: An instance of this class is automatically created for an + * instance of the KustoManagementClient. + */ +export interface Clusters { + + + /** + * Gets a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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, clusterName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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 {Cluster} - 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. + * + * {Cluster} [result] - The deserialized result object if an error did not occur. + * See {@link Cluster} 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, clusterName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, clusterName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, clusterName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Create or update a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} parameters The Kusto cluster parameters supplied to the + * CreateOrUpdate operation. + * + * @param {object} parameters.sku The SKU of the cluster. + * + * @param {string} parameters.sku.name SKU name. Possible values include: + * 'KC8', 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * + * @param {number} [parameters.sku.capacity] SKU capacity. + * + * @param {array} [parameters.trustedExternalTenants] The cluster's external + * tenants. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location The geo-location where the resource + * lives + * + * @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, clusterName: string, parameters: models.Cluster, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Create or update a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} parameters The Kusto cluster parameters supplied to the + * CreateOrUpdate operation. + * + * @param {object} parameters.sku The SKU of the cluster. + * + * @param {string} parameters.sku.name SKU name. Possible values include: + * 'KC8', 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * + * @param {number} [parameters.sku.capacity] SKU capacity. + * + * @param {array} [parameters.trustedExternalTenants] The cluster's external + * tenants. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location The geo-location where the resource + * lives + * + * @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 {Cluster} - 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. + * + * {Cluster} [result] - The deserialized result object if an error did not occur. + * See {@link Cluster} 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, clusterName: string, parameters: models.Cluster, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, clusterName: string, parameters: models.Cluster, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, clusterName: string, parameters: models.Cluster, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Update a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} parameters The Kusto cluster parameters supplied to the + * Update operation. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} [parameters.location] Resource location. + * + * @param {object} [parameters.sku] The SKU of the cluster. + * + * @param {string} parameters.sku.name SKU name. Possible values include: + * 'KC8', 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * + * @param {number} [parameters.sku.capacity] SKU capacity. + * + * @param {array} [parameters.trustedExternalTenants] The cluster's external + * tenants. + * + * @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, clusterName: string, parameters: models.ClusterUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Update a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} parameters The Kusto cluster parameters supplied to the + * Update operation. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} [parameters.location] Resource location. + * + * @param {object} [parameters.sku] The SKU of the cluster. + * + * @param {string} parameters.sku.name SKU name. Possible values include: + * 'KC8', 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * + * @param {number} [parameters.sku.capacity] SKU capacity. + * + * @param {array} [parameters.trustedExternalTenants] The cluster's external + * tenants. + * + * @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 {Cluster} - 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. + * + * {Cluster} [result] - The deserialized result object if an error did not occur. + * See {@link Cluster} 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, clusterName: string, parameters: models.ClusterUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, clusterName: string, parameters: models.ClusterUpdate, callback: ServiceCallback): void; + update(resourceGroupName: string, clusterName: string, parameters: models.ClusterUpdate, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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, clusterName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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, clusterName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, clusterName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, clusterName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Stops a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + stopWithHttpOperationResponse(resourceGroupName: string, clusterName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Stops a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + stop(resourceGroupName: string, clusterName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + stop(resourceGroupName: string, clusterName: string, callback: ServiceCallback): void; + stop(resourceGroupName: string, clusterName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Starts a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + startWithHttpOperationResponse(resourceGroupName: string, clusterName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Starts a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + start(resourceGroupName: string, clusterName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + start(resourceGroupName: string, clusterName: string, callback: ServiceCallback): void; + start(resourceGroupName: string, clusterName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all Kusto clusters within a resource group. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @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>; + + /** + * Lists all Kusto clusters within a resource group. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @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 {ClusterListResult} - 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. + * + * {ClusterListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ClusterListResult} 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; + + + /** + * Lists all Kusto clusters 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>; + + /** + * Lists all Kusto clusters 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 {ClusterListResult} - 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. + * + * {ClusterListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ClusterListResult} 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 eligible SKUs for Kusto resource provider. + * + * @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. + */ + listSkusWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists eligible SKUs for Kusto resource provider. + * + * @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 {ListSkusResult} - 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. + * + * {ListSkusResult} [result] - The deserialized result object if an error did not occur. + * See {@link ListSkusResult} 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. + */ + listSkus(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listSkus(callback: ServiceCallback): void; + listSkus(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Checks that the cluster name is valid and is not already in use. + * + * @param {string} location Azure location. + * + * @param {object} clusterName The name of the cluster. + * + * @param {string} clusterName.name Cluster name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + checkNameAvailabilityWithHttpOperationResponse(location: string, clusterName: models.ClusterCheckNameRequest, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Checks that the cluster name is valid and is not already in use. + * + * @param {string} location Azure location. + * + * @param {object} clusterName The name of the cluster. + * + * @param {string} clusterName.name Cluster name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {CheckNameResult} - 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. + * + * {CheckNameResult} [result] - The deserialized result object if an error did not occur. + * See {@link CheckNameResult} 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. + */ + checkNameAvailability(location: string, clusterName: models.ClusterCheckNameRequest, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + checkNameAvailability(location: string, clusterName: models.ClusterCheckNameRequest, callback: ServiceCallback): void; + checkNameAvailability(location: string, clusterName: models.ClusterCheckNameRequest, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Returns the SKUs available for the provided resource. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + listSkusByResourceWithHttpOperationResponse(resourceGroupName: string, clusterName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Returns the SKUs available for the provided resource. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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 {ListResourceSkusResult} - 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. + * + * {ListResourceSkusResult} [result] - The deserialized result object if an error did not occur. + * See {@link ListResourceSkusResult} 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. + */ + listSkusByResource(resourceGroupName: string, clusterName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listSkusByResource(resourceGroupName: string, clusterName: string, callback: ServiceCallback): void; + listSkusByResource(resourceGroupName: string, clusterName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Create or update a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} parameters The Kusto cluster parameters supplied to the + * CreateOrUpdate operation. + * + * @param {object} parameters.sku The SKU of the cluster. + * + * @param {string} parameters.sku.name SKU name. Possible values include: + * 'KC8', 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * + * @param {number} [parameters.sku.capacity] SKU capacity. + * + * @param {array} [parameters.trustedExternalTenants] The cluster's external + * tenants. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location The geo-location where the resource + * lives + * + * @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. + */ + beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName: string, clusterName: string, parameters: models.Cluster, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Create or update a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} parameters The Kusto cluster parameters supplied to the + * CreateOrUpdate operation. + * + * @param {object} parameters.sku The SKU of the cluster. + * + * @param {string} parameters.sku.name SKU name. Possible values include: + * 'KC8', 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * + * @param {number} [parameters.sku.capacity] SKU capacity. + * + * @param {array} [parameters.trustedExternalTenants] The cluster's external + * tenants. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location The geo-location where the resource + * lives + * + * @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 {Cluster} - 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. + * + * {Cluster} [result] - The deserialized result object if an error did not occur. + * See {@link Cluster} 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. + */ + beginCreateOrUpdate(resourceGroupName: string, clusterName: string, parameters: models.Cluster, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginCreateOrUpdate(resourceGroupName: string, clusterName: string, parameters: models.Cluster, callback: ServiceCallback): void; + beginCreateOrUpdate(resourceGroupName: string, clusterName: string, parameters: models.Cluster, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Update a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} parameters The Kusto cluster parameters supplied to the + * Update operation. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} [parameters.location] Resource location. + * + * @param {object} [parameters.sku] The SKU of the cluster. + * + * @param {string} parameters.sku.name SKU name. Possible values include: + * 'KC8', 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * + * @param {number} [parameters.sku.capacity] SKU capacity. + * + * @param {array} [parameters.trustedExternalTenants] The cluster's external + * tenants. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + beginUpdateWithHttpOperationResponse(resourceGroupName: string, clusterName: string, parameters: models.ClusterUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Update a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} parameters The Kusto cluster parameters supplied to the + * Update operation. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} [parameters.location] Resource location. + * + * @param {object} [parameters.sku] The SKU of the cluster. + * + * @param {string} parameters.sku.name SKU name. Possible values include: + * 'KC8', 'KC16', 'KS8', 'KS16', 'D13_v2', 'D14_v2', 'L8', 'L16' + * + * @param {number} [parameters.sku.capacity] SKU capacity. + * + * @param {array} [parameters.trustedExternalTenants] The cluster's external + * tenants. + * + * @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 {Cluster} - 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. + * + * {Cluster} [result] - The deserialized result object if an error did not occur. + * See {@link Cluster} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + beginUpdate(resourceGroupName: string, clusterName: string, parameters: models.ClusterUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginUpdate(resourceGroupName: string, clusterName: string, parameters: models.ClusterUpdate, callback: ServiceCallback): void; + beginUpdate(resourceGroupName: string, clusterName: string, parameters: models.ClusterUpdate, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + beginDeleteMethodWithHttpOperationResponse(resourceGroupName: string, clusterName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + beginDeleteMethod(resourceGroupName: string, clusterName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginDeleteMethod(resourceGroupName: string, clusterName: string, callback: ServiceCallback): void; + beginDeleteMethod(resourceGroupName: string, clusterName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Stops a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + beginStopWithHttpOperationResponse(resourceGroupName: string, clusterName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Stops a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + beginStop(resourceGroupName: string, clusterName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginStop(resourceGroupName: string, clusterName: string, callback: ServiceCallback): void; + beginStop(resourceGroupName: string, clusterName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Starts a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + beginStartWithHttpOperationResponse(resourceGroupName: string, clusterName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Starts a Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + beginStart(resourceGroupName: string, clusterName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginStart(resourceGroupName: string, clusterName: string, callback: ServiceCallback): void; + beginStart(resourceGroupName: string, clusterName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * Databases + * __NOTE__: An instance of this class is automatically created for an + * instance of the KustoManagementClient. + */ +export interface Databases { + + + /** + * Checks that the database name is valid and is not already in use. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} databaseName The name of the database. + * + * @param {string} databaseName.name Database name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + checkNameAvailabilityWithHttpOperationResponse(resourceGroupName: string, clusterName: string, databaseName: models.DatabaseCheckNameRequest, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Checks that the database name is valid and is not already in use. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {object} databaseName The name of the database. + * + * @param {string} databaseName.name Database name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {CheckNameResult} - 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. + * + * {CheckNameResult} [result] - The deserialized result object if an error did not occur. + * See {@link CheckNameResult} 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. + */ + checkNameAvailability(resourceGroupName: string, clusterName: string, databaseName: models.DatabaseCheckNameRequest, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + checkNameAvailability(resourceGroupName: string, clusterName: string, databaseName: models.DatabaseCheckNameRequest, callback: ServiceCallback): void; + checkNameAvailability(resourceGroupName: string, clusterName: string, databaseName: models.DatabaseCheckNameRequest, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Returns the list of databases of the given Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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. + */ + listByClusterWithHttpOperationResponse(resourceGroupName: string, clusterName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Returns the list of databases of the given Kusto cluster. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @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 {DatabaseListResult} - 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. + * + * {DatabaseListResult} [result] - The deserialized result object if an error did not occur. + * See {@link DatabaseListResult} 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. + */ + listByCluster(resourceGroupName: string, clusterName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByCluster(resourceGroupName: string, clusterName: string, callback: ServiceCallback): void; + listByCluster(resourceGroupName: string, clusterName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Returns a database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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, clusterName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Returns a database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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 {Database} - 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. + * + * {Database} [result] - The deserialized result object if an error did not occur. + * See {@link Database} 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, clusterName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, clusterName: string, databaseName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, clusterName: string, databaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Creates or updates a database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The database parameters supplied to the + * CreateOrUpdate operation. + * + * @param {number} parameters.softDeletePeriodInDays The number of days data + * should be kept before it stops being accessible to queries. + * + * @param {number} [parameters.hotCachePeriodInDays] The number of days of data + * that should be kept in cache for fast queries. + * + * @param {object} [parameters.statistics] The statistics of the database. + * + * @param {number} [parameters.statistics.size] The database size - the total + * size of compressed data and index in bytes. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location The geo-location where the resource + * lives + * + * @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, clusterName: string, databaseName: string, parameters: models.Database, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Creates or updates a database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The database parameters supplied to the + * CreateOrUpdate operation. + * + * @param {number} parameters.softDeletePeriodInDays The number of days data + * should be kept before it stops being accessible to queries. + * + * @param {number} [parameters.hotCachePeriodInDays] The number of days of data + * that should be kept in cache for fast queries. + * + * @param {object} [parameters.statistics] The statistics of the database. + * + * @param {number} [parameters.statistics.size] The database size - the total + * size of compressed data and index in bytes. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location The geo-location where the resource + * lives + * + * @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 {Database} - 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. + * + * {Database} [result] - The deserialized result object if an error did not occur. + * See {@link Database} 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, clusterName: string, databaseName: string, parameters: models.Database, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, clusterName: string, databaseName: string, parameters: models.Database, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, clusterName: string, databaseName: string, parameters: models.Database, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Updates a database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The database parameters supplied to the Update + * operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {number} parameters.softDeletePeriodInDays The number of days data + * should be kept before it stops being accessible to queries. + * + * @param {number} [parameters.hotCachePeriodInDays] The number of days of data + * that should be kept in cache for fast queries. + * + * @param {object} [parameters.statistics] The statistics of the database. + * + * @param {number} [parameters.statistics.size] The database size - the total + * size of compressed data and index in bytes. + * + * @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, clusterName: string, databaseName: string, parameters: models.DatabaseUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Updates a database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The database parameters supplied to the Update + * operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {number} parameters.softDeletePeriodInDays The number of days data + * should be kept before it stops being accessible to queries. + * + * @param {number} [parameters.hotCachePeriodInDays] The number of days of data + * that should be kept in cache for fast queries. + * + * @param {object} [parameters.statistics] The statistics of the database. + * + * @param {number} [parameters.statistics.size] The database size - the total + * size of compressed data and index in bytes. + * + * @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 {Database} - 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. + * + * {Database} [result] - The deserialized result object if an error did not occur. + * See {@link Database} 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, clusterName: string, databaseName: string, parameters: models.DatabaseUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, clusterName: string, databaseName: string, parameters: models.DatabaseUpdate, callback: ServiceCallback): void; + update(resourceGroupName: string, clusterName: string, databaseName: string, parameters: models.DatabaseUpdate, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes the database with the given name. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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, clusterName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes the database with the given name. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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, clusterName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, clusterName: string, databaseName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, clusterName: string, databaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Returns a list of database principals of the given Kusto cluster and + * database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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. + */ + listPrincipalsWithHttpOperationResponse(resourceGroupName: string, clusterName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Returns a list of database principals of the given Kusto cluster and + * database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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 {DatabasePrincipalListResult} - 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. + * + * {DatabasePrincipalListResult} [result] - The deserialized result object if an error did not occur. + * See {@link DatabasePrincipalListResult} 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. + */ + listPrincipals(resourceGroupName: string, clusterName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listPrincipals(resourceGroupName: string, clusterName: string, databaseName: string, callback: ServiceCallback): void; + listPrincipals(resourceGroupName: string, clusterName: string, databaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Add Database principals permissions. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} databasePrincipalsToAdd List of database principals to add. + * + * @param {array} [databasePrincipalsToAdd.value] The list of Kusto database + * principals. + * + * @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. + */ + addPrincipalsWithHttpOperationResponse(resourceGroupName: string, clusterName: string, databaseName: string, databasePrincipalsToAdd: models.DatabasePrincipalListRequest, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Add Database principals permissions. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} databasePrincipalsToAdd List of database principals to add. + * + * @param {array} [databasePrincipalsToAdd.value] The list of Kusto database + * principals. + * + * @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 {DatabasePrincipalListResult} - 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. + * + * {DatabasePrincipalListResult} [result] - The deserialized result object if an error did not occur. + * See {@link DatabasePrincipalListResult} 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. + */ + addPrincipals(resourceGroupName: string, clusterName: string, databaseName: string, databasePrincipalsToAdd: models.DatabasePrincipalListRequest, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + addPrincipals(resourceGroupName: string, clusterName: string, databaseName: string, databasePrincipalsToAdd: models.DatabasePrincipalListRequest, callback: ServiceCallback): void; + addPrincipals(resourceGroupName: string, clusterName: string, databaseName: string, databasePrincipalsToAdd: models.DatabasePrincipalListRequest, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Remove Database principals permissions. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} databasePrincipalsToRemove List of database principals to + * remove. + * + * @param {array} [databasePrincipalsToRemove.value] The list of Kusto database + * principals. + * + * @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. + */ + removePrincipalsWithHttpOperationResponse(resourceGroupName: string, clusterName: string, databaseName: string, databasePrincipalsToRemove: models.DatabasePrincipalListRequest, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Remove Database principals permissions. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} databasePrincipalsToRemove List of database principals to + * remove. + * + * @param {array} [databasePrincipalsToRemove.value] The list of Kusto database + * principals. + * + * @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 {DatabasePrincipalListResult} - 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. + * + * {DatabasePrincipalListResult} [result] - The deserialized result object if an error did not occur. + * See {@link DatabasePrincipalListResult} 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. + */ + removePrincipals(resourceGroupName: string, clusterName: string, databaseName: string, databasePrincipalsToRemove: models.DatabasePrincipalListRequest, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + removePrincipals(resourceGroupName: string, clusterName: string, databaseName: string, databasePrincipalsToRemove: models.DatabasePrincipalListRequest, callback: ServiceCallback): void; + removePrincipals(resourceGroupName: string, clusterName: string, databaseName: string, databasePrincipalsToRemove: models.DatabasePrincipalListRequest, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Creates or updates a database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The database parameters supplied to the + * CreateOrUpdate operation. + * + * @param {number} parameters.softDeletePeriodInDays The number of days data + * should be kept before it stops being accessible to queries. + * + * @param {number} [parameters.hotCachePeriodInDays] The number of days of data + * that should be kept in cache for fast queries. + * + * @param {object} [parameters.statistics] The statistics of the database. + * + * @param {number} [parameters.statistics.size] The database size - the total + * size of compressed data and index in bytes. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location The geo-location where the resource + * lives + * + * @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. + */ + beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName: string, clusterName: string, databaseName: string, parameters: models.Database, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Creates or updates a database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The database parameters supplied to the + * CreateOrUpdate operation. + * + * @param {number} parameters.softDeletePeriodInDays The number of days data + * should be kept before it stops being accessible to queries. + * + * @param {number} [parameters.hotCachePeriodInDays] The number of days of data + * that should be kept in cache for fast queries. + * + * @param {object} [parameters.statistics] The statistics of the database. + * + * @param {number} [parameters.statistics.size] The database size - the total + * size of compressed data and index in bytes. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {string} parameters.location The geo-location where the resource + * lives + * + * @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 {Database} - 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. + * + * {Database} [result] - The deserialized result object if an error did not occur. + * See {@link Database} 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. + */ + beginCreateOrUpdate(resourceGroupName: string, clusterName: string, databaseName: string, parameters: models.Database, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginCreateOrUpdate(resourceGroupName: string, clusterName: string, databaseName: string, parameters: models.Database, callback: ServiceCallback): void; + beginCreateOrUpdate(resourceGroupName: string, clusterName: string, databaseName: string, parameters: models.Database, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Updates a database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The database parameters supplied to the Update + * operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {number} parameters.softDeletePeriodInDays The number of days data + * should be kept before it stops being accessible to queries. + * + * @param {number} [parameters.hotCachePeriodInDays] The number of days of data + * that should be kept in cache for fast queries. + * + * @param {object} [parameters.statistics] The statistics of the database. + * + * @param {number} [parameters.statistics.size] The database size - the total + * size of compressed data and index in bytes. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + beginUpdateWithHttpOperationResponse(resourceGroupName: string, clusterName: string, databaseName: string, parameters: models.DatabaseUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Updates a database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The database parameters supplied to the Update + * operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {number} parameters.softDeletePeriodInDays The number of days data + * should be kept before it stops being accessible to queries. + * + * @param {number} [parameters.hotCachePeriodInDays] The number of days of data + * that should be kept in cache for fast queries. + * + * @param {object} [parameters.statistics] The statistics of the database. + * + * @param {number} [parameters.statistics.size] The database size - the total + * size of compressed data and index in bytes. + * + * @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 {Database} - 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. + * + * {Database} [result] - The deserialized result object if an error did not occur. + * See {@link Database} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + beginUpdate(resourceGroupName: string, clusterName: string, databaseName: string, parameters: models.DatabaseUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginUpdate(resourceGroupName: string, clusterName: string, databaseName: string, parameters: models.DatabaseUpdate, callback: ServiceCallback): void; + beginUpdate(resourceGroupName: string, clusterName: string, databaseName: string, parameters: models.DatabaseUpdate, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes the database with the given name. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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. + */ + beginDeleteMethodWithHttpOperationResponse(resourceGroupName: string, clusterName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes the database with the given name. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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. + */ + beginDeleteMethod(resourceGroupName: string, clusterName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginDeleteMethod(resourceGroupName: string, clusterName: string, databaseName: string, callback: ServiceCallback): void; + beginDeleteMethod(resourceGroupName: string, clusterName: string, databaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * EventHubConnections + * __NOTE__: An instance of this class is automatically created for an + * instance of the KustoManagementClient. + */ +export interface EventHubConnections { + + + /** + * Returns the list of Event Hub connections of the given Kusto database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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. + */ + listByDatabaseWithHttpOperationResponse(resourceGroupName: string, clusterName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Returns the list of Event Hub connections of the given Kusto database. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @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 {EventHubConnectionListResult} - 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. + * + * {EventHubConnectionListResult} [result] - The deserialized result object if an error did not occur. + * See {@link EventHubConnectionListResult} 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. + */ + listByDatabase(resourceGroupName: string, clusterName: string, databaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByDatabase(resourceGroupName: string, clusterName: string, databaseName: string, callback: ServiceCallback): void; + listByDatabase(resourceGroupName: string, clusterName: string, databaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Checks that the Event Hub data connection parameters are valid. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the CreateOrUpdate operation. + * + * @param {string} [parameters.eventhubConnectionName] The name of the event + * hub connection. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @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. + */ + eventhubConnectionValidationWithHttpOperationResponse(resourceGroupName: string, clusterName: string, databaseName: string, parameters: models.EventHubConnectionValidation, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Checks that the Event Hub data connection parameters are valid. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the CreateOrUpdate operation. + * + * @param {string} [parameters.eventhubConnectionName] The name of the event + * hub connection. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @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 {EventHubConnectionValidationListResult} - 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. + * + * {EventHubConnectionValidationListResult} [result] - The deserialized result object if an error did not occur. + * See {@link EventHubConnectionValidationListResult} 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. + */ + eventhubConnectionValidation(resourceGroupName: string, clusterName: string, databaseName: string, parameters: models.EventHubConnectionValidation, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + eventhubConnectionValidation(resourceGroupName: string, clusterName: string, databaseName: string, parameters: models.EventHubConnectionValidation, callback: ServiceCallback): void; + eventhubConnectionValidation(resourceGroupName: string, clusterName: string, databaseName: string, parameters: models.EventHubConnectionValidation, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Returns an Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @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, clusterName: string, databaseName: string, eventHubConnectionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Returns an Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @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 {EventHubConnection} - 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. + * + * {EventHubConnection} [result] - The deserialized result object if an error did not occur. + * See {@link EventHubConnection} 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, clusterName: string, databaseName: string, eventHubConnectionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, clusterName: string, databaseName: string, eventHubConnectionName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, clusterName: string, databaseName: string, eventHubConnectionName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Creates or updates a Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the CreateOrUpdate operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @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, clusterName: string, databaseName: string, eventHubConnectionName: string, parameters: models.EventHubConnection, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Creates or updates a Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the CreateOrUpdate operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @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 {EventHubConnection} - 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. + * + * {EventHubConnection} [result] - The deserialized result object if an error did not occur. + * See {@link EventHubConnection} 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, clusterName: string, databaseName: string, eventHubConnectionName: string, parameters: models.EventHubConnection, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, clusterName: string, databaseName: string, eventHubConnectionName: string, parameters: models.EventHubConnection, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, clusterName: string, databaseName: string, eventHubConnectionName: string, parameters: models.EventHubConnection, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Updates a Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the Update operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @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, clusterName: string, databaseName: string, eventHubConnectionName: string, parameters: models.EventHubConnectionUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Updates a Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the Update operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @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 {EventHubConnection} - 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. + * + * {EventHubConnection} [result] - The deserialized result object if an error did not occur. + * See {@link EventHubConnection} 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, clusterName: string, databaseName: string, eventHubConnectionName: string, parameters: models.EventHubConnectionUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, clusterName: string, databaseName: string, eventHubConnectionName: string, parameters: models.EventHubConnectionUpdate, callback: ServiceCallback): void; + update(resourceGroupName: string, clusterName: string, databaseName: string, eventHubConnectionName: string, parameters: models.EventHubConnectionUpdate, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes the Event Hub connection with the given name. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @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, clusterName: string, databaseName: string, eventHubConnectionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes the Event Hub connection with the given name. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @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, clusterName: string, databaseName: string, eventHubConnectionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, clusterName: string, databaseName: string, eventHubConnectionName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, clusterName: string, databaseName: string, eventHubConnectionName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Creates or updates a Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the CreateOrUpdate operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @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. + */ + beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName: string, clusterName: string, databaseName: string, eventHubConnectionName: string, parameters: models.EventHubConnection, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Creates or updates a Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the CreateOrUpdate operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @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 {EventHubConnection} - 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. + * + * {EventHubConnection} [result] - The deserialized result object if an error did not occur. + * See {@link EventHubConnection} 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. + */ + beginCreateOrUpdate(resourceGroupName: string, clusterName: string, databaseName: string, eventHubConnectionName: string, parameters: models.EventHubConnection, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginCreateOrUpdate(resourceGroupName: string, clusterName: string, databaseName: string, eventHubConnectionName: string, parameters: models.EventHubConnection, callback: ServiceCallback): void; + beginCreateOrUpdate(resourceGroupName: string, clusterName: string, databaseName: string, eventHubConnectionName: string, parameters: models.EventHubConnection, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Updates a Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the Update operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + beginUpdateWithHttpOperationResponse(resourceGroupName: string, clusterName: string, databaseName: string, eventHubConnectionName: string, parameters: models.EventHubConnectionUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Updates a Event Hub connection. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @param {object} parameters The Event Hub connection parameters supplied to + * the Update operation. + * + * @param {string} [parameters.location] Resource location. + * + * @param {string} parameters.eventHubResourceId The resource ID of the event + * hub to be used to create a data connection. + * + * @param {string} parameters.consumerGroup The event hub consumer group. + * + * @param {string} [parameters.tableName] The table where the data should be + * ingested. Optionally the table information can be added to each message. + * + * @param {string} [parameters.mappingRuleName] The mapping rule to be used to + * ingest the data. Optionally the mapping information can be added to each + * message. + * + * @param {string} [parameters.dataFormat] The data format of the message. + * Optionally the data format can be added to each message. Possible values + * include: 'MULTIJSON', 'JSON', 'CSV' + * + * @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 {EventHubConnection} - 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. + * + * {EventHubConnection} [result] - The deserialized result object if an error did not occur. + * See {@link EventHubConnection} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + beginUpdate(resourceGroupName: string, clusterName: string, databaseName: string, eventHubConnectionName: string, parameters: models.EventHubConnectionUpdate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginUpdate(resourceGroupName: string, clusterName: string, databaseName: string, eventHubConnectionName: string, parameters: models.EventHubConnectionUpdate, callback: ServiceCallback): void; + beginUpdate(resourceGroupName: string, clusterName: string, databaseName: string, eventHubConnectionName: string, parameters: models.EventHubConnectionUpdate, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes the Event Hub connection with the given name. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @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. + */ + beginDeleteMethodWithHttpOperationResponse(resourceGroupName: string, clusterName: string, databaseName: string, eventHubConnectionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes the Event Hub connection with the given name. + * + * @param {string} resourceGroupName The name of the resource group containing + * the Kusto cluster. + * + * @param {string} clusterName The name of the Kusto cluster. + * + * @param {string} databaseName The name of the database in the Kusto cluster. + * + * @param {string} eventHubConnectionName The name of the event hub connection. + * + * @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. + */ + beginDeleteMethod(resourceGroupName: string, clusterName: string, databaseName: string, eventHubConnectionName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginDeleteMethod(resourceGroupName: string, clusterName: string, databaseName: string, eventHubConnectionName: string, callback: ServiceCallback): void; + beginDeleteMethod(resourceGroupName: string, clusterName: string, databaseName: string, eventHubConnectionName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * Operations + * __NOTE__: An instance of this class is automatically created for an + * instance of the KustoManagementClient. + */ +export interface Operations { + + + /** + * Lists available operations for the Microsoft.Kusto provider. + * + * @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 available operations for the Microsoft.Kusto provider. + * + * @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 available operations for the Microsoft.Kusto provider. + * + * @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 available operations for the Microsoft.Kusto provider. + * + * @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; +} diff --git a/lib/services/kustoManagement/lib/operations/index.js b/lib/services/kustoManagement/lib/operations/index.js new file mode 100644 index 0000000000..e6ecebc32f --- /dev/null +++ b/lib/services/kustoManagement/lib/operations/index.js @@ -0,0 +1,20 @@ +/* + * 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.Clusters = require('./clusters'); +exports.Databases = require('./databases'); +exports.EventHubConnections = require('./eventHubConnections'); +exports.Operations = require('./operations'); diff --git a/lib/services/kustoManagement/lib/operations/operations.js b/lib/services/kustoManagement/lib/operations/operations.js new file mode 100644 index 0000000000..289ecdb50d --- /dev/null +++ b/lib/services/kustoManagement/lib/operations/operations.js @@ -0,0 +1,449 @@ +/* + * 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 available operations for the Microsoft.Kusto provider. + * + * @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.Kusto/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) { + 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['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 available operations for the Microsoft.Kusto provider. + * + * @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) { + 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['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 {KustoManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listNext = _listNext; + } + + /** + * Lists available operations for the Microsoft.Kusto provider. + * + * @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 available operations for the Microsoft.Kusto provider. + * + * @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 available operations for the Microsoft.Kusto provider. + * + * @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 available operations for the Microsoft.Kusto provider. + * + * @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/kustoManagement/package.json b/lib/services/kustoManagement/package.json new file mode 100644 index 0000000000..6ec944a032 --- /dev/null +++ b/lib/services/kustoManagement/package.json @@ -0,0 +1,25 @@ +{ + "name": "azure-arm-kusto", + "author": "Microsoft Corporation", + "description": "KustoManagementClient Library with typescript type definitions for node", + "version": "1.0.0-preview", + "dependencies": { + "ms-rest": "^2.3.3", + "ms-rest-azure": "^2.5.5" + }, + "keywords": [ + "node", + "azure" + ], + "license": "MIT", + "main": "./lib/kustoManagementClient.js", + "types": "./lib/kustoManagementClient.d.ts", + "homepage": "https://github.com/azure/azure-sdk-for-node/tree/master/lib/services/kustoManagement", + "repository": { + "type": "git", + "url": "https://github.com/azure/azure-sdk-for-node.git" + }, + "bugs": { + "url": "https://github.com/azure/azure-sdk-for-node/issues" + } +}