UNPKG

azure-arm-datalake-store

Version:

Microsoft Azure Data Lake Store Management Client Library for node

1,185 lines (1,137 loc) 157 kB
/* * 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 the Data Lake Store accounts within the subscription. The response * includes a link to the next page of results, if any. * * @param {object} [options] Optional Parameters. * * @param {string} [options.filter] OData filter. Optional. * * @param {number} [options.top] The number of items to return. Optional. * * @param {number} [options.skip] The number of items to skip over before * returning elements. Optional. * * @param {string} [options.select] OData Select statement. Limits the * properties on each entry to just those requested, e.g. * Categories?$select=CategoryName,Description. Optional. * * @param {string} [options.orderby] OrderBy clause. One or more * comma-separated expressions with an optional "asc" (the default) or "desc" * depending on the order you'd like the values sorted, e.g. * Categories?$orderby=CategoryName desc. Optional. * * @param {boolean} [options.count] The Boolean value of true or false to * request a count of the matching resources included with the resources in the * response, e.g. Categories?$count=true. Optional. * * @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 DataLakeStoreAccountListResult} 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.'); } let filter = (options && options.filter !== undefined) ? options.filter : undefined; let top = (options && options.top !== undefined) ? options.top : undefined; let skip = (options && options.skip !== undefined) ? options.skip : undefined; let select = (options && options.select !== undefined) ? options.select : undefined; let orderby = (options && options.orderby !== undefined) ? options.orderby : undefined; let count = (options && options.count !== undefined) ? options.count : undefined; // Validate try { if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); } if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { throw new Error('filter must be of type string.'); } if (top !== null && top !== undefined && typeof top !== 'number') { throw new Error('top must be of type number.'); } if (top !== null && top !== undefined) { if (top < 1) { throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); } } if (skip !== null && skip !== undefined && typeof skip !== 'number') { throw new Error('skip must be of type number.'); } if (skip !== null && skip !== undefined) { if (skip < 1) { throw new Error('"skip" should satisfy the constraint - "InclusiveMinimum": 1'); } } if (select !== null && select !== undefined && typeof select.valueOf() !== 'string') { throw new Error('select must be of type string.'); } if (orderby !== null && orderby !== undefined && typeof orderby.valueOf() !== 'string') { throw new Error('orderby must be of type string.'); } if (count !== null && count !== undefined && typeof count !== 'boolean') { throw new Error('count must be of type boolean.'); } if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); } } catch (error) { return callback(error); } // Construct URL let baseUrl = this.client.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.DataLakeStore/accounts'; requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); let queryParameters = []; if (filter !== null && filter !== undefined) { queryParameters.push('$filter=' + encodeURIComponent(filter)); } if (top !== null && top !== undefined) { queryParameters.push('$top=' + encodeURIComponent(top.toString())); } if (skip !== null && skip !== undefined) { queryParameters.push('$skip=' + encodeURIComponent(skip.toString())); } if (select !== null && select !== undefined) { queryParameters.push('$select=' + encodeURIComponent(select)); } if (orderby !== null && orderby !== undefined) { queryParameters.push('$orderby=' + encodeURIComponent(orderby)); } if (count !== null && count !== undefined) { queryParameters.push('$count=' + encodeURIComponent(count.toString())); } queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); } // Create HTTP transport objects let httpRequest = new WebResource(); httpRequest.method = 'GET'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); } if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { for(let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } } } httpRequest.body = null; // Send Request return client.pipeline(httpRequest, (err, response, responseBody) => { if (err) { return callback(err); } let statusCode = response.statusCode; if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); error.response = msRest.stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { parsedErrorResponse = JSON.parse(responseBody); if (parsedErrorResponse) { 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['DataLakeStoreAccountListResult']().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 the Data Lake Store accounts within a specific resource group. The * response includes a link to the next page of results, if any. * * @param {string} resourceGroupName The name of the Azure resource group. * * @param {object} [options] Optional Parameters. * * @param {string} [options.filter] OData filter. Optional. * * @param {number} [options.top] The number of items to return. Optional. * * @param {number} [options.skip] The number of items to skip over before * returning elements. Optional. * * @param {string} [options.select] OData Select statement. Limits the * properties on each entry to just those requested, e.g. * Categories?$select=CategoryName,Description. Optional. * * @param {string} [options.orderby] OrderBy clause. One or more * comma-separated expressions with an optional "asc" (the default) or "desc" * depending on the order you'd like the values sorted, e.g. * Categories?$orderby=CategoryName desc. Optional. * * @param {boolean} [options.count] A Boolean value of true or false to request * a count of the matching resources included with the resources in the * response, e.g. Categories?$count=true. Optional. * * @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 DataLakeStoreAccountListResult} 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.'); } let filter = (options && options.filter !== undefined) ? options.filter : undefined; let top = (options && options.top !== undefined) ? options.top : undefined; let skip = (options && options.skip !== undefined) ? options.skip : undefined; let select = (options && options.select !== undefined) ? options.select : undefined; let orderby = (options && options.orderby !== undefined) ? options.orderby : undefined; let count = (options && options.count !== undefined) ? options.count : undefined; // Validate try { if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); } if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); } if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { throw new Error('filter must be of type string.'); } if (top !== null && top !== undefined && typeof top !== 'number') { throw new Error('top must be of type number.'); } if (top !== null && top !== undefined) { if (top < 1) { throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); } } if (skip !== null && skip !== undefined && typeof skip !== 'number') { throw new Error('skip must be of type number.'); } if (skip !== null && skip !== undefined) { if (skip < 1) { throw new Error('"skip" should satisfy the constraint - "InclusiveMinimum": 1'); } } if (select !== null && select !== undefined && typeof select.valueOf() !== 'string') { throw new Error('select must be of type string.'); } if (orderby !== null && orderby !== undefined && typeof orderby.valueOf() !== 'string') { throw new Error('orderby must be of type string.'); } if (count !== null && count !== undefined && typeof count !== 'boolean') { throw new Error('count must be of type boolean.'); } if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); } } catch (error) { return callback(error); } // Construct URL let baseUrl = this.client.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataLakeStore/accounts'; requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); let queryParameters = []; if (filter !== null && filter !== undefined) { queryParameters.push('$filter=' + encodeURIComponent(filter)); } if (top !== null && top !== undefined) { queryParameters.push('$top=' + encodeURIComponent(top.toString())); } if (skip !== null && skip !== undefined) { queryParameters.push('$skip=' + encodeURIComponent(skip.toString())); } if (select !== null && select !== undefined) { queryParameters.push('$select=' + encodeURIComponent(select)); } if (orderby !== null && orderby !== undefined) { queryParameters.push('$orderby=' + encodeURIComponent(orderby)); } if (count !== null && count !== undefined) { queryParameters.push('$count=' + encodeURIComponent(count.toString())); } queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); } // Create HTTP transport objects let httpRequest = new WebResource(); httpRequest.method = 'GET'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); } if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { for(let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } } } httpRequest.body = null; // Send Request return client.pipeline(httpRequest, (err, response, responseBody) => { if (err) { return callback(err); } let statusCode = response.statusCode; if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); error.response = msRest.stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { parsedErrorResponse = JSON.parse(responseBody); if (parsedErrorResponse) { 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['DataLakeStoreAccountListResult']().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 the specified Data Lake Store account. * * @param {string} resourceGroupName The name of the Azure resource group. * * @param {string} accountName The name of the Data Lake Store account. * * @param {object} parameters Parameters supplied to create the Data Lake Store * account. * * @param {string} parameters.location The resource location. * * @param {object} [parameters.tags] The resource tags. * * @param {object} [parameters.identity] The Key Vault encryption identity, if * any. * * @param {string} [parameters.defaultGroup] The default owner group for all * new folders and files created in the Data Lake Store account. * * @param {object} [parameters.encryptionConfig] The Key Vault encryption * configuration. * * @param {string} parameters.encryptionConfig.type The type of encryption * configuration being used. Currently the only supported types are * 'UserManaged' and 'ServiceManaged'. Possible values include: 'UserManaged', * 'ServiceManaged' * * @param {object} [parameters.encryptionConfig.keyVaultMetaInfo] The Key Vault * information for connecting to user managed encryption keys. * * @param {string} * parameters.encryptionConfig.keyVaultMetaInfo.keyVaultResourceId The resource * identifier for the user managed Key Vault being used to encrypt. * * @param {string} * parameters.encryptionConfig.keyVaultMetaInfo.encryptionKeyName The name of * the user managed encryption key. * * @param {string} * parameters.encryptionConfig.keyVaultMetaInfo.encryptionKeyVersion The * version of the user managed encryption key. * * @param {string} [parameters.encryptionState] The current state of encryption * for this Data Lake Store account. Possible values include: 'Enabled', * 'Disabled' * * @param {array} [parameters.firewallRules] The list of firewall rules * associated with this Data Lake Store account. * * @param {array} [parameters.virtualNetworkRules] The list of virtual network * rules associated with this Data Lake Store account. * * @param {string} [parameters.firewallState] The current state of the IP * address firewall for this Data Lake Store account. Possible values include: * 'Enabled', 'Disabled' * * @param {string} [parameters.firewallAllowAzureIps] The current state of * allowing or disallowing IPs originating within Azure through the firewall. * If the firewall is disabled, this is not enforced. Possible values include: * 'Enabled', 'Disabled' * * @param {array} [parameters.trustedIdProviders] The list of trusted identity * providers associated with this Data Lake Store account. * * @param {string} [parameters.trustedIdProviderState] The current state of the * trusted identity provider feature for this Data Lake Store account. Possible * values include: 'Enabled', 'Disabled' * * @param {string} [parameters.newTier] The commitment tier to use for next * month. Possible values include: 'Consumption', 'Commitment_1TB', * 'Commitment_10TB', 'Commitment_100TB', 'Commitment_500TB', 'Commitment_1PB', * 'Commitment_5PB' * * @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 DataLakeStoreAccount} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _create(resourceGroupName, accountName, 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.beginCreate(resourceGroupName, accountName, 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['DataLakeStoreAccount']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); deserializationError.request = msRest.stripRequest(httpRequest); deserializationError.response = msRest.stripResponse(response); return callback(deserializationError); } return callback(null, result, httpRequest, response); }); }); } /** * Gets the specified Data Lake Store account. * * @param {string} resourceGroupName The name of the Azure resource group. * * @param {string} accountName The name of the Data Lake Store account. * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @param {function} callback - The callback. * * @returns {function} callback(err, result, request, response) * * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. * See {@link DataLakeStoreAccount} 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, accountName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { callback = options; options = null; } if (!callback) { throw new Error('callback cannot be null.'); } // Validate try { if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); } if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); } if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') { throw new Error('accountName 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.DataLakeStore/accounts/{accountName}'; requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); requestUrl = requestUrl.replace('{accountName}', encodeURIComponent(accountName)); 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['DataLakeStoreAccount']().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 the specified Data Lake Store account information. * * @param {string} resourceGroupName The name of the Azure resource group. * * @param {string} accountName The name of the Data Lake Store account. * * @param {object} parameters Parameters supplied to update the Data Lake Store * account. * * @param {object} [parameters.tags] Resource tags * * @param {string} [parameters.defaultGroup] The default owner group for all * new folders and files created in the Data Lake Store account. * * @param {object} [parameters.encryptionConfig] Used for rotation of user * managed Key Vault keys. Can only be used to rotate a user managed encryption * Key Vault key. * * @param {object} [parameters.encryptionConfig.keyVaultMetaInfo] The updated * Key Vault key to use in user managed key rotation. * * @param {string} * [parameters.encryptionConfig.keyVaultMetaInfo.encryptionKeyVersion] The * version of the user managed encryption key to update through a key rotation. * * @param {array} [parameters.firewallRules] The list of firewall rules * associated with this Data Lake Store account. * * @param {array} [parameters.virtualNetworkRules] The list of virtual network * rules associated with this Data Lake Store account. * * @param {string} [parameters.firewallState] The current state of the IP * address firewall for this Data Lake Store account. Disabling the firewall * does not remove existing rules, they will just be ignored until the firewall * is re-enabled. Possible values include: 'Enabled', 'Disabled' * * @param {string} [parameters.firewallAllowAzureIps] The current state of * allowing or disallowing IPs originating within Azure through the firewall. * If the firewall is disabled, this is not enforced. Possible values include: * 'Enabled', 'Disabled' * * @param {array} [parameters.trustedIdProviders] The list of trusted identity * providers associated with this Data Lake Store account. * * @param {string} [parameters.trustedIdProviderState] The current state of the * trusted identity provider feature for this Data Lake Store account. * Disabling trusted identity provider functionality does not remove the * providers, they will just be ignored until this feature is re-enabled. * Possible values include: 'Enabled', 'Disabled' * * @param {string} [parameters.newTier] The commitment tier to use for next * month. Possible values include: 'Consumption', 'Commitment_1TB', * 'Commitment_10TB', 'Commitment_100TB', 'Commitment_500TB', 'Commitment_1PB', * 'Commitment_5PB' * * @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 DataLakeStoreAccount} 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, accountName, 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, accountName, 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['DataLakeStoreAccount']().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 specified Data Lake Store account. * * @param {string} resourceGroupName The name of the Azure resource group. * * @param {string} accountName The name of the Data Lake Store account. * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @param {function} callback - The callback. * * @returns {function} callback(err, result, request, response) * * {Error} err - The Error object if an error occurred, null otherwise. * * {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, accountName, 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, accountName, 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); }); }); } /** * Attempts to enable a user managed Key Vault for encryption of the specified * Data Lake Store account. * * @param {string} resourceGroupName The name of the Azure resource group. * * @param {string} accountName The name of the Data Lake Store account. * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @param {function} callback - The callback. * * @returns {function} callback(err, result, request, response) * * {Error} err - The Error object if an error occurred, null otherwise. * * {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 _enableKeyVault(resourceGroupName, accountName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { callback = options; options = null; } if (!callback) { throw new Error('callback cannot be null.'); } // Validate try { if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); } if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); } if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') { throw new Error('accountName 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.DataLakeStore/accounts/{accountName}/enableKeyVault'; requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); requestUrl = requestUrl.replace('{accountName}', encodeURIComponent(accountName)); 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; return callback(null, result, httpRequest, response); }); } /** * Checks whether the specified account name is available or taken. * * @param {string} location The resource location without whitespace. * * @param {object} parameters Parameters supplied to check the Data Lake Store * account name availability. * * @param {string} parameters.name The Data Lake Store name to check * availability for. * * @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 NameAvailabilityInformation} 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, 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 (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 (parameters === null || parameters === undefined) { throw new Error('parameters cannot be null or undefined.'); } 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.DataLakeStore/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 (parameters !== null && parameters !== undefined) { let requestModelMapper = new client.models['CheckNameAvailabilityParameters']().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) { erro