diff --git a/lib/services/rediscachemanagement/LICENSE.txt b/lib/services/rediscachemanagement/LICENSE.txt new file mode 100644 index 0000000000..2bb9ad240f --- /dev/null +++ b/lib/services/rediscachemanagement/LICENSE.txt @@ -0,0 +1,176 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/lib/services/rediscachemanagement/README.md b/lib/services/rediscachemanagement/README.md new file mode 100644 index 0000000000..03b8289e9c --- /dev/null +++ b/lib/services/rediscachemanagement/README.md @@ -0,0 +1,24 @@ +# Microsoft Azure SDK for Node.js - Redis + +This project provides a Node.js package for accessing the Azure Redis Cache Client. Right now it supports: +- **Node.js version: 0.6.15 or higher** +- **API version: ** + +## Features + + +## How to Install + +```bash +npm install azure-arm-rediscache +``` + +## How to Use + +### to be added + +### Create the redis client + +## Related projects + +- [Microsoft Azure SDK for Node.js](https://github.com/WindowsAzure/azure-sdk-for-node) \ No newline at end of file diff --git a/lib/services/rediscachemanagement/lib/redisManagementClient.js b/lib/services/rediscachemanagement/lib/redisManagementClient.js new file mode 100644 index 0000000000..5863c99c26 --- /dev/null +++ b/lib/services/rediscachemanagement/lib/redisManagementClient.js @@ -0,0 +1,1345 @@ +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +'use strict'; + +var util = require('util'); +var azureCommon = require('azure-common'); +var Service = azureCommon.Service; +var WebResource = azureCommon.WebResource; + +var RedisManagementClient = ( /** @lends RedisManagementClient */ function() { + /** + * @class + * .Net client wrapper for the REST API for Azure Redis Cache Management + * Service + * Initializes a new instance of the RedisManagementClient class. + * @constructor + * + * @param {SubscriptionCloudCredentials} credentials Gets subscription + * credentials which uniquely identify Microsoft Azure subscription. The + * subscription ID forms part of the URI for every service call. + * + * @param {string} [credentials.subscriptionId] + * + * @param {string} [baseUri] Gets the URI used as the base for all cloud + * service requests. + * + * @param {Array} filters + */ + function RedisManagementClient(credentials, baseUri, filters) { + if (credentials === null || credentials === undefined) { + throw new Error('credentials cannot be null.'); + } + + RedisManagementClient['super_'].call(this, credentials, filters); + + this.credentials = credentials; + this.baseUri = baseUri; + if (this.baseUri === null || this.baseUri === undefined) { + this.baseUri = 'https://management.azure.com'; + } + if (this.apiVersion === null || this.apiVersion === undefined) { + this.apiVersion = '2015-03-01'; + } + if (this.longRunningOperationInitialTimeout === null || this.longRunningOperationInitialTimeout === undefined) { + this.longRunningOperationInitialTimeout = -1; + } + if (this.longRunningOperationRetryTimeout === null || this.longRunningOperationRetryTimeout === undefined) { + this.longRunningOperationRetryTimeout = -1; + } + /** + * Provides an instance of the [RedisOperations](-RedisOperations.html) + * object. + * @type {object} + */ + this.redis = new RedisOperations(this); + } + + util.inherits(RedisManagementClient, Service); + + + return RedisManagementClient; +})(); +exports.RedisManagementClient = RedisManagementClient; + +var RedisOperations = ( /** @lends RedisOperations */ function() { + /** + * @class + * Operations for managing the redis cache. + * __NOTE__: An instance of this class is automatically created for an + * instance of the [RedisManagementClient] {@link + * RedisManagementClient~RedisManagementClient}. + * See [redis] {@link RedisManagementClient~RedisManagementClient#redis}. + * Initializes a new instance of the RedisOperations class. + * @constructor + * + * @param {RedisManagementClient} client Reference to the service client. + */ + function RedisOperations(client) { + this.client = client; + } + + /** + * Create a redis cache, or replace (overwrite/recreate, with potential + * downtime) an existing cache + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} name The name of the redis cache. + * + * @param {RedisCreateOrUpdateParameters} parameters Parameters supplied to + * the CreateOrUpdate redis operation. + * + * @param {RedisProperties} parameters.properties Redis cache properties. + * + * @param {string} parameters.properties.redisVersion The version of Redis to + * deploy. Valid values: (2.8) + * + * @param {Sku} parameters.properties.sku What sku of redis cache to deploy. + * + * @param {string} parameters.properties.sku.name What type of redis cache to + * deploy. Valid values: (Basic, Standard) + * + * @param {string} parameters.properties.sku.family Which family to use. + * Valid values: (C) + * + * @param {number} parameters.properties.sku.capacity What size of redis + * cache to deploy. Valid values: (0, 1, 2, 3, 4, 5, 6) + * + * @param {object} [parameters.properties.redisConfiguration] All Redis + * Settings. Few possible keys: + * maxmemory-deltamaxmemory-policynotify-keyspace-eventsmaxmemory-samplesslowlog-log-slower-thanslowlog-max-lenlist-max-ziplist-entrieslist-max-ziplist-valuehash-max-ziplist-entrieshash-max-ziplist-valueset-max-intset-entrieszset-max-ziplist-entrieszset-max-ziplist-value + * etc. + * + * @param {boolean} parameters.properties.enableNonSslPort Non-ssl redis + * server port (6379) is enabled or not. + * + * @param {string} parameters.location Gets or sets the location of the + * resource. + * + * @param {object} [parameters.tags] Gets or sets the tags attached to the + * resource. + * + * @param {function} callback + * + * @returns {Stream} The response stream. + */ + RedisOperations.prototype.createOrUpdate = function(resourceGroupName, name, parameters, callback) { + if (callback === null || callback === undefined) { + throw new Error('callback cannot be null.'); + } + // Validate + if (resourceGroupName === null || resourceGroupName === undefined) { + return callback(new Error('resourceGroupName cannot be null.')); + } + if (name === null || name === undefined) { + return callback(new Error('name cannot be null.')); + } + if (parameters === null || parameters === undefined) { + return callback(new Error('parameters cannot be null.')); + } + if (parameters.location === null || parameters.location === undefined) { + return callback(new Error('parameters.location cannot be null.')); + } + if (parameters.properties === null || parameters.properties === undefined) { + return callback(new Error('parameters.properties cannot be null.')); + } + if (parameters.properties.enableNonSslPort === null || parameters.properties.enableNonSslPort === undefined) { + return callback(new Error('parameters.properties.enableNonSslPort cannot be null.')); + } + if (parameters.properties.redisVersion === null || parameters.properties.redisVersion === undefined) { + return callback(new Error('parameters.properties.redisVersion cannot be null.')); + } + if (parameters.properties.sku === null || parameters.properties.sku === undefined) { + return callback(new Error('parameters.properties.sku cannot be null.')); + } + if (parameters.properties.sku.capacity === null || parameters.properties.sku.capacity === undefined) { + return callback(new Error('parameters.properties.sku.capacity cannot be null.')); + } + if (parameters.properties.sku.family === null || parameters.properties.sku.family === undefined) { + return callback(new Error('parameters.properties.sku.family cannot be null.')); + } + if (parameters.properties.sku.name === null || parameters.properties.sku.name === undefined) { + return callback(new Error('parameters.properties.sku.name cannot be null.')); + } + + // Tracing + + // Construct URL + var url2 = ''; + url2 = url2 + '/subscriptions/'; + if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) { + url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId); + } + url2 = url2 + '/resourceGroups/'; + url2 = url2 + encodeURIComponent(resourceGroupName); + url2 = url2 + '/providers/'; + url2 = url2 + 'Microsoft.Cache'; + url2 = url2 + '/Redis/'; + url2 = url2 + encodeURIComponent(name); + var queryParameters = []; + queryParameters.push('api-version=2015-03-01'); + if (queryParameters.length > 0) { + url2 = url2 + '?' + queryParameters.join('&'); + } + var baseUrl = this.client.baseUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.length - 1] === '/') { + baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0); + } + if (url2[0] === '/') { + url2 = url2.substring(1); + } + url2 = baseUrl + '/' + url2; + url2 = url2.replace(' ', '%20'); + + // Create HTTP transport objects + var httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.headers = {}; + httpRequest.url = url2; + + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json'; + + // Serialize Request + var requestContent = null; + var requestDoc = null; + + var redisCreateOrUpdateParametersValue = {}; + requestDoc = redisCreateOrUpdateParametersValue; + + var propertiesValue = {}; + redisCreateOrUpdateParametersValue['properties'] = propertiesValue; + + propertiesValue['redisVersion'] = parameters.properties.redisVersion; + + var skuValue = {}; + propertiesValue['sku'] = skuValue; + + skuValue['name'] = parameters.properties.sku.name; + + skuValue['family'] = parameters.properties.sku.family; + + skuValue['capacity'] = parameters.properties.sku.capacity; + + if (parameters.properties.redisConfiguration !== null && parameters.properties.redisConfiguration !== undefined) { + var redisConfigurationDictionary = {}; + for (var redisConfigurationKey in parameters.properties.redisConfiguration) { + var redisConfigurationValue = parameters.properties.redisConfiguration[redisConfigurationKey]; + redisConfigurationDictionary[redisConfigurationKey] = redisConfigurationValue; + } + propertiesValue['redisConfiguration'] = redisConfigurationDictionary; + } + + propertiesValue['enableNonSslPort'] = parameters.properties.enableNonSslPort; + + redisCreateOrUpdateParametersValue['location'] = parameters.location; + + if (parameters.tags !== null && parameters.tags !== undefined) { + var tagsDictionary = {}; + for (var tagsKey in parameters.tags) { + var tagsValue = parameters.tags[tagsKey]; + tagsDictionary[tagsKey] = tagsValue; + } + redisCreateOrUpdateParametersValue['tags'] = tagsDictionary; + } + + requestContent = JSON.stringify(requestDoc); + httpRequest.body = requestContent; + httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8'); + // Send Request + return this.client.pipeline(httpRequest, function (err, response, body) { + if (err !== null && err !== undefined) { + return callback(err); + } + var statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201) { + var error = new Error(body); + error.statusCode = response.statusCode; + return callback(error); + } + + // Create Result + var result = null; + // Deserialize Response + if (statusCode === 200 || statusCode === 201) { + var responseContent = body; + result = {}; + var responseDoc = null; + if (responseContent) { + responseDoc = JSON.parse(responseContent); + } + + if (responseDoc !== null && responseDoc !== undefined) { + var resourceInstance = { tags: {} }; + result.resource = resourceInstance; + + var propertiesValue2 = responseDoc['properties']; + if (propertiesValue2 !== null && propertiesValue2 !== undefined) { + var propertiesInstance = { redisConfiguration: {} }; + resourceInstance.properties = propertiesInstance; + + var accessKeysValue = propertiesValue2['accessKeys']; + if (accessKeysValue !== null && accessKeysValue !== undefined) { + var accessKeysInstance = {}; + propertiesInstance.accessKeys = accessKeysInstance; + + var primaryKeyValue = accessKeysValue['primaryKey']; + if (primaryKeyValue !== null && primaryKeyValue !== undefined) { + var primaryKeyInstance = primaryKeyValue; + accessKeysInstance.primaryKey = primaryKeyInstance; + } + + var secondaryKeyValue = accessKeysValue['secondaryKey']; + if (secondaryKeyValue !== null && secondaryKeyValue !== undefined) { + var secondaryKeyInstance = secondaryKeyValue; + accessKeysInstance.secondaryKey = secondaryKeyInstance; + } + } + + var provisioningStateValue = propertiesValue2['provisioningState']; + if (provisioningStateValue !== null && provisioningStateValue !== undefined) { + var provisioningStateInstance = provisioningStateValue; + propertiesInstance.provisioningState = provisioningStateInstance; + } + + var hostNameValue = propertiesValue2['hostName']; + if (hostNameValue !== null && hostNameValue !== undefined) { + var hostNameInstance = hostNameValue; + propertiesInstance.hostName = hostNameInstance; + } + + var portValue = propertiesValue2['port']; + if (portValue !== null && portValue !== undefined) { + var portInstance = portValue; + propertiesInstance.port = portInstance; + } + + var sslPortValue = propertiesValue2['sslPort']; + if (sslPortValue !== null && sslPortValue !== undefined) { + var sslPortInstance = sslPortValue; + propertiesInstance.sslPort = sslPortInstance; + } + + var redisVersionValue = propertiesValue2['redisVersion']; + if (redisVersionValue !== null && redisVersionValue !== undefined) { + var redisVersionInstance = redisVersionValue; + propertiesInstance.redisVersion = redisVersionInstance; + } + + var skuValue2 = propertiesValue2['sku']; + if (skuValue2 !== null && skuValue2 !== undefined) { + var skuInstance = {}; + propertiesInstance.sku = skuInstance; + + var nameValue = skuValue2['name']; + if (nameValue !== null && nameValue !== undefined) { + var nameInstance = nameValue; + skuInstance.name = nameInstance; + } + + var familyValue = skuValue2['family']; + if (familyValue !== null && familyValue !== undefined) { + var familyInstance = familyValue; + skuInstance.family = familyInstance; + } + + var capacityValue = skuValue2['capacity']; + if (capacityValue !== null && capacityValue !== undefined) { + var capacityInstance = capacityValue; + skuInstance.capacity = capacityInstance; + } + } + + var redisConfigurationSequenceElement = propertiesValue2['redisConfiguration']; + if (redisConfigurationSequenceElement !== null && redisConfigurationSequenceElement !== undefined) { + for (var property in redisConfigurationSequenceElement) { + var redisConfigurationKey2 = property; + var redisConfigurationValue2 = redisConfigurationSequenceElement[property]; + propertiesInstance.redisConfiguration[redisConfigurationKey2] = redisConfigurationValue2; + } + } + + var enableNonSslPortValue = propertiesValue2['enableNonSslPort']; + if (enableNonSslPortValue !== null && enableNonSslPortValue !== undefined) { + var enableNonSslPortInstance = enableNonSslPortValue; + propertiesInstance.enableNonSslPort = enableNonSslPortInstance; + } + } + + var idValue = responseDoc['id']; + if (idValue !== null && idValue !== undefined) { + var idInstance = idValue; + resourceInstance.id = idInstance; + } + + var nameValue2 = responseDoc['name']; + if (nameValue2 !== null && nameValue2 !== undefined) { + var nameInstance2 = nameValue2; + resourceInstance.name = nameInstance2; + } + + var typeValue = responseDoc['type']; + if (typeValue !== null && typeValue !== undefined) { + var typeInstance = typeValue; + resourceInstance.type = typeInstance; + } + + var locationValue = responseDoc['location']; + if (locationValue !== null && locationValue !== undefined) { + var locationInstance = locationValue; + resourceInstance.location = locationInstance; + } + + var tagsSequenceElement = responseDoc['tags']; + if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) { + for (var property2 in tagsSequenceElement) { + var tagsKey2 = property2; + var tagsValue2 = tagsSequenceElement[property2]; + resourceInstance.tags[tagsKey2] = tagsValue2; + } + } + } + + } + result.statusCode = statusCode; + result.requestId = response.headers['x-ms-request-id']; + + return callback(null, result); + }); + }; + + /** + * Deletes a redis cache. This operation takes a while to complete. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} name The name of the redis cache. + * + * @param {function} callback + * + * @returns {Stream} The response stream. + */ + RedisOperations.prototype.deleteMethod = function(resourceGroupName, name, callback) { + if (callback === null || callback === undefined) { + throw new Error('callback cannot be null.'); + } + // Validate + if (resourceGroupName === null || resourceGroupName === undefined) { + return callback(new Error('resourceGroupName cannot be null.')); + } + if (name === null || name === undefined) { + return callback(new Error('name cannot be null.')); + } + + // Tracing + + // Construct URL + var url2 = ''; + url2 = url2 + '/subscriptions/'; + if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) { + url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId); + } + url2 = url2 + '/resourceGroups/'; + url2 = url2 + encodeURIComponent(resourceGroupName); + url2 = url2 + '/providers/'; + url2 = url2 + 'Microsoft.Cache'; + url2 = url2 + '/Redis/'; + url2 = url2 + encodeURIComponent(name); + var queryParameters = []; + queryParameters.push('api-version=2015-03-01'); + if (queryParameters.length > 0) { + url2 = url2 + '?' + queryParameters.join('&'); + } + var baseUrl = this.client.baseUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.length - 1] === '/') { + baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0); + } + if (url2[0] === '/') { + url2 = url2.substring(1); + } + url2 = baseUrl + '/' + url2; + url2 = url2.replace(' ', '%20'); + + // Create HTTP transport objects + var httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.headers = {}; + httpRequest.url = url2; + + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json'; + + // Send Request + return this.client.pipeline(httpRequest, function (err, response, body) { + if (err !== null && err !== undefined) { + return callback(err); + } + var statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 202 && statusCode !== 404) { + var error = new Error(body); + error.statusCode = response.statusCode; + return callback(error); + } + + // Create Result + var result = null; + // Deserialize Response + result = {}; + result.statusCode = statusCode; + result.requestId = response.headers['x-ms-request-id']; + + return callback(null, result); + }); + }; + + /** + * Gets a redis cache (resource description). + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} name The name of the redis cache. + * + * @param {function} callback + * + * @returns {Stream} The response stream. + */ + RedisOperations.prototype.get = function(resourceGroupName, name, callback) { + if (callback === null || callback === undefined) { + throw new Error('callback cannot be null.'); + } + // Validate + if (resourceGroupName === null || resourceGroupName === undefined) { + return callback(new Error('resourceGroupName cannot be null.')); + } + if (name === null || name === undefined) { + return callback(new Error('name cannot be null.')); + } + + // Tracing + + // Construct URL + var url2 = ''; + url2 = url2 + '/subscriptions/'; + if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) { + url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId); + } + url2 = url2 + '/resourceGroups/'; + url2 = url2 + encodeURIComponent(resourceGroupName); + url2 = url2 + '/providers/'; + url2 = url2 + 'Microsoft.Cache'; + url2 = url2 + '/Redis/'; + url2 = url2 + encodeURIComponent(name); + var queryParameters = []; + queryParameters.push('api-version=2015-03-01'); + if (queryParameters.length > 0) { + url2 = url2 + '?' + queryParameters.join('&'); + } + var baseUrl = this.client.baseUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.length - 1] === '/') { + baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0); + } + if (url2[0] === '/') { + url2 = url2.substring(1); + } + url2 = baseUrl + '/' + url2; + url2 = url2.replace(' ', '%20'); + + // Create HTTP transport objects + var httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.headers = {}; + httpRequest.url = url2; + + // Set Headers + + // Send Request + return this.client.pipeline(httpRequest, function (err, response, body) { + if (err !== null && err !== undefined) { + return callback(err); + } + var statusCode = response.statusCode; + if (statusCode !== 200) { + var error = new Error(body); + error.statusCode = response.statusCode; + return callback(error); + } + + // Create Result + var result = null; + // Deserialize Response + if (statusCode === 200) { + var responseContent = body; + result = {}; + var responseDoc = null; + if (responseContent) { + responseDoc = JSON.parse(responseContent); + } + + if (responseDoc !== null && responseDoc !== undefined) { + var resourceInstance = { tags: {} }; + result.resource = resourceInstance; + + var propertiesValue = responseDoc['properties']; + if (propertiesValue !== null && propertiesValue !== undefined) { + var propertiesInstance = { redisConfiguration: {} }; + resourceInstance.properties = propertiesInstance; + + var provisioningStateValue = propertiesValue['provisioningState']; + if (provisioningStateValue !== null && provisioningStateValue !== undefined) { + var provisioningStateInstance = provisioningStateValue; + propertiesInstance.provisioningState = provisioningStateInstance; + } + + var hostNameValue = propertiesValue['hostName']; + if (hostNameValue !== null && hostNameValue !== undefined) { + var hostNameInstance = hostNameValue; + propertiesInstance.hostName = hostNameInstance; + } + + var portValue = propertiesValue['port']; + if (portValue !== null && portValue !== undefined) { + var portInstance = portValue; + propertiesInstance.port = portInstance; + } + + var sslPortValue = propertiesValue['sslPort']; + if (sslPortValue !== null && sslPortValue !== undefined) { + var sslPortInstance = sslPortValue; + propertiesInstance.sslPort = sslPortInstance; + } + + var redisVersionValue = propertiesValue['redisVersion']; + if (redisVersionValue !== null && redisVersionValue !== undefined) { + var redisVersionInstance = redisVersionValue; + propertiesInstance.redisVersion = redisVersionInstance; + } + + var skuValue = propertiesValue['sku']; + if (skuValue !== null && skuValue !== undefined) { + var skuInstance = {}; + propertiesInstance.sku = skuInstance; + + var nameValue = skuValue['name']; + if (nameValue !== null && nameValue !== undefined) { + var nameInstance = nameValue; + skuInstance.name = nameInstance; + } + + var familyValue = skuValue['family']; + if (familyValue !== null && familyValue !== undefined) { + var familyInstance = familyValue; + skuInstance.family = familyInstance; + } + + var capacityValue = skuValue['capacity']; + if (capacityValue !== null && capacityValue !== undefined) { + var capacityInstance = capacityValue; + skuInstance.capacity = capacityInstance; + } + } + + var redisConfigurationSequenceElement = propertiesValue['redisConfiguration']; + if (redisConfigurationSequenceElement !== null && redisConfigurationSequenceElement !== undefined) { + for (var property in redisConfigurationSequenceElement) { + var redisConfigurationKey = property; + var redisConfigurationValue = redisConfigurationSequenceElement[property]; + propertiesInstance.redisConfiguration[redisConfigurationKey] = redisConfigurationValue; + } + } + + var enableNonSslPortValue = propertiesValue['enableNonSslPort']; + if (enableNonSslPortValue !== null && enableNonSslPortValue !== undefined) { + var enableNonSslPortInstance = enableNonSslPortValue; + propertiesInstance.enableNonSslPort = enableNonSslPortInstance; + } + } + + var idValue = responseDoc['id']; + if (idValue !== null && idValue !== undefined) { + var idInstance = idValue; + resourceInstance.id = idInstance; + } + + var nameValue2 = responseDoc['name']; + if (nameValue2 !== null && nameValue2 !== undefined) { + var nameInstance2 = nameValue2; + resourceInstance.name = nameInstance2; + } + + var typeValue = responseDoc['type']; + if (typeValue !== null && typeValue !== undefined) { + var typeInstance = typeValue; + resourceInstance.type = typeInstance; + } + + var locationValue = responseDoc['location']; + if (locationValue !== null && locationValue !== undefined) { + var locationInstance = locationValue; + resourceInstance.location = locationInstance; + } + + var tagsSequenceElement = responseDoc['tags']; + if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) { + for (var property2 in tagsSequenceElement) { + var tagsKey = property2; + var tagsValue = tagsSequenceElement[property2]; + resourceInstance.tags[tagsKey] = tagsValue; + } + } + } + + } + result.statusCode = statusCode; + result.requestId = response.headers['x-ms-request-id']; + + return callback(null, result); + }); + }; + + /** + * Gets all redis caches in a resource group (if provided) otherwise all in + * subscription. + * + * @param {string} [resourceGroupName] The name of the resource group. + * + * @param {function} callback + * + * @returns {Stream} The response stream. + */ + RedisOperations.prototype.list = function(resourceGroupName, callback) { + if (callback === null || callback === undefined) { + throw new Error('callback cannot be null.'); + } + // Validate + + // Tracing + + // Construct URL + var url2 = ''; + url2 = url2 + '/subscriptions/'; + if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) { + url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId); + } + if (resourceGroupName !== null && resourceGroupName !== undefined) { + url2 = url2 + '/resourceGroups/' + encodeURIComponent(resourceGroupName); + } + url2 = url2 + '/providers/'; + url2 = url2 + 'Microsoft.Cache'; + url2 = url2 + '/Redis/'; + var queryParameters = []; + queryParameters.push('api-version=2015-03-01'); + if (queryParameters.length > 0) { + url2 = url2 + '?' + queryParameters.join('&'); + } + var baseUrl = this.client.baseUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.length - 1] === '/') { + baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0); + } + if (url2[0] === '/') { + url2 = url2.substring(1); + } + url2 = baseUrl + '/' + url2; + url2 = url2.replace(' ', '%20'); + + // Create HTTP transport objects + var httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.headers = {}; + httpRequest.url = url2; + + // Set Headers + + // Send Request + return this.client.pipeline(httpRequest, function (err, response, body) { + if (err !== null && err !== undefined) { + return callback(err); + } + var statusCode = response.statusCode; + if (statusCode !== 200) { + var error = new Error(body); + error.statusCode = response.statusCode; + return callback(error); + } + + // Create Result + var result = null; + // Deserialize Response + if (statusCode === 200) { + var responseContent = body; + result = { value: [] }; + var responseDoc = null; + if (responseContent) { + responseDoc = JSON.parse(responseContent); + } + + if (responseDoc !== null && responseDoc !== undefined) { + var valueArray = responseDoc['value']; + if (valueArray !== null && valueArray !== undefined) { + for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) { + var valueValue = valueArray[loweredIndex1]; + var redisResourceInstance = { tags: {} }; + result.value.push(redisResourceInstance); + + var propertiesValue = valueValue['properties']; + if (propertiesValue !== null && propertiesValue !== undefined) { + var propertiesInstance = { redisConfiguration: {} }; + redisResourceInstance.properties = propertiesInstance; + + var provisioningStateValue = propertiesValue['provisioningState']; + if (provisioningStateValue !== null && provisioningStateValue !== undefined) { + var provisioningStateInstance = provisioningStateValue; + propertiesInstance.provisioningState = provisioningStateInstance; + } + + var hostNameValue = propertiesValue['hostName']; + if (hostNameValue !== null && hostNameValue !== undefined) { + var hostNameInstance = hostNameValue; + propertiesInstance.hostName = hostNameInstance; + } + + var portValue = propertiesValue['port']; + if (portValue !== null && portValue !== undefined) { + var portInstance = portValue; + propertiesInstance.port = portInstance; + } + + var sslPortValue = propertiesValue['sslPort']; + if (sslPortValue !== null && sslPortValue !== undefined) { + var sslPortInstance = sslPortValue; + propertiesInstance.sslPort = sslPortInstance; + } + + var redisVersionValue = propertiesValue['redisVersion']; + if (redisVersionValue !== null && redisVersionValue !== undefined) { + var redisVersionInstance = redisVersionValue; + propertiesInstance.redisVersion = redisVersionInstance; + } + + var skuValue = propertiesValue['sku']; + if (skuValue !== null && skuValue !== undefined) { + var skuInstance = {}; + propertiesInstance.sku = skuInstance; + + var nameValue = skuValue['name']; + if (nameValue !== null && nameValue !== undefined) { + var nameInstance = nameValue; + skuInstance.name = nameInstance; + } + + var familyValue = skuValue['family']; + if (familyValue !== null && familyValue !== undefined) { + var familyInstance = familyValue; + skuInstance.family = familyInstance; + } + + var capacityValue = skuValue['capacity']; + if (capacityValue !== null && capacityValue !== undefined) { + var capacityInstance = capacityValue; + skuInstance.capacity = capacityInstance; + } + } + + var redisConfigurationSequenceElement = propertiesValue['redisConfiguration']; + if (redisConfigurationSequenceElement !== null && redisConfigurationSequenceElement !== undefined) { + for (var property in redisConfigurationSequenceElement) { + var redisConfigurationKey = property; + var redisConfigurationValue = redisConfigurationSequenceElement[property]; + propertiesInstance.redisConfiguration[redisConfigurationKey] = redisConfigurationValue; + } + } + + var enableNonSslPortValue = propertiesValue['enableNonSslPort']; + if (enableNonSslPortValue !== null && enableNonSslPortValue !== undefined) { + var enableNonSslPortInstance = enableNonSslPortValue; + propertiesInstance.enableNonSslPort = enableNonSslPortInstance; + } + } + + var idValue = valueValue['id']; + if (idValue !== null && idValue !== undefined) { + var idInstance = idValue; + redisResourceInstance.id = idInstance; + } + + var nameValue2 = valueValue['name']; + if (nameValue2 !== null && nameValue2 !== undefined) { + var nameInstance2 = nameValue2; + redisResourceInstance.name = nameInstance2; + } + + var typeValue = valueValue['type']; + if (typeValue !== null && typeValue !== undefined) { + var typeInstance = typeValue; + redisResourceInstance.type = typeInstance; + } + + var locationValue = valueValue['location']; + if (locationValue !== null && locationValue !== undefined) { + var locationInstance = locationValue; + redisResourceInstance.location = locationInstance; + } + + var tagsSequenceElement = valueValue['tags']; + if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) { + for (var property2 in tagsSequenceElement) { + var tagsKey = property2; + var tagsValue = tagsSequenceElement[property2]; + redisResourceInstance.tags[tagsKey] = tagsValue; + } + } + } + } + + var nextLinkValue = responseDoc['nextLink']; + if (nextLinkValue !== null && nextLinkValue !== undefined) { + var nextLinkInstance = nextLinkValue; + result.nextLink = nextLinkInstance; + } + } + + } + result.statusCode = statusCode; + result.requestId = response.headers['x-ms-request-id']; + + return callback(null, result); + }); + }; + + /** + * Retrieve a redis cache's access keys. This operation requires write + * permission to the cache resource. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} name The name of the redis cache. + * + * @param {function} callback + * + * @returns {Stream} The response stream. + */ + RedisOperations.prototype.listKeys = function(resourceGroupName, name, callback) { + if (callback === null || callback === undefined) { + throw new Error('callback cannot be null.'); + } + // Validate + if (resourceGroupName === null || resourceGroupName === undefined) { + return callback(new Error('resourceGroupName cannot be null.')); + } + if (name === null || name === undefined) { + return callback(new Error('name cannot be null.')); + } + + // Tracing + + // Construct URL + var url2 = ''; + url2 = url2 + '/subscriptions/'; + if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) { + url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId); + } + url2 = url2 + '/resourceGroups/'; + url2 = url2 + encodeURIComponent(resourceGroupName); + url2 = url2 + '/providers/'; + url2 = url2 + 'Microsoft.Cache'; + url2 = url2 + '/Redis/'; + url2 = url2 + encodeURIComponent(name); + url2 = url2 + '/listKeys'; + var queryParameters = []; + queryParameters.push('api-version=2015-03-01'); + if (queryParameters.length > 0) { + url2 = url2 + '?' + queryParameters.join('&'); + } + var baseUrl = this.client.baseUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.length - 1] === '/') { + baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0); + } + if (url2[0] === '/') { + url2 = url2.substring(1); + } + url2 = baseUrl + '/' + url2; + url2 = url2.replace(' ', '%20'); + + // Create HTTP transport objects + var httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.headers = {}; + httpRequest.url = url2; + + // Set Headers + + // Send Request + return this.client.pipeline(httpRequest, function (err, response, body) { + if (err !== null && err !== undefined) { + return callback(err); + } + var statusCode = response.statusCode; + if (statusCode !== 200) { + var error = new Error(body); + error.statusCode = response.statusCode; + return callback(error); + } + + // Create Result + var result = null; + // Deserialize Response + if (statusCode === 200) { + var responseContent = body; + result = {}; + var responseDoc = null; + if (responseContent) { + responseDoc = JSON.parse(responseContent); + } + + if (responseDoc !== null && responseDoc !== undefined) { + var primaryKeyValue = responseDoc['primaryKey']; + if (primaryKeyValue !== null && primaryKeyValue !== undefined) { + var primaryKeyInstance = primaryKeyValue; + result.primaryKey = primaryKeyInstance; + } + + var secondaryKeyValue = responseDoc['secondaryKey']; + if (secondaryKeyValue !== null && secondaryKeyValue !== undefined) { + var secondaryKeyInstance = secondaryKeyValue; + result.secondaryKey = secondaryKeyInstance; + } + } + + } + result.statusCode = statusCode; + result.requestId = response.headers['x-ms-request-id']; + + return callback(null, result); + }); + }; + + /** + * Gets all redis caches using next link. + * + * @param {string} nextLink NextLink from the previous successful call to + * List operation. + * + * @param {function} callback + * + * @returns {Stream} The response stream. + */ + RedisOperations.prototype.listNext = function(nextLink, callback) { + if (callback === null || callback === undefined) { + throw new Error('callback cannot be null.'); + } + // Validate + if (nextLink === null || nextLink === undefined) { + return callback(new Error('nextLink cannot be null.')); + } + + // Tracing + + // Construct URL + var url2 = ''; + url2 = url2 + nextLink; + url2 = url2.replace(' ', '%20'); + + // Create HTTP transport objects + var httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.headers = {}; + httpRequest.url = url2; + + // Set Headers + + // Send Request + return this.client.pipeline(httpRequest, function (err, response, body) { + if (err !== null && err !== undefined) { + return callback(err); + } + var statusCode = response.statusCode; + if (statusCode !== 200) { + var error = new Error(body); + error.statusCode = response.statusCode; + return callback(error); + } + + // Create Result + var result = null; + // Deserialize Response + if (statusCode === 200) { + var responseContent = body; + result = { value: [] }; + var responseDoc = null; + if (responseContent) { + responseDoc = JSON.parse(responseContent); + } + + if (responseDoc !== null && responseDoc !== undefined) { + var valueArray = responseDoc['value']; + if (valueArray !== null && valueArray !== undefined) { + for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) { + var valueValue = valueArray[loweredIndex1]; + var redisResourceInstance = { tags: {} }; + result.value.push(redisResourceInstance); + + var propertiesValue = valueValue['properties']; + if (propertiesValue !== null && propertiesValue !== undefined) { + var propertiesInstance = { redisConfiguration: {} }; + redisResourceInstance.properties = propertiesInstance; + + var provisioningStateValue = propertiesValue['provisioningState']; + if (provisioningStateValue !== null && provisioningStateValue !== undefined) { + var provisioningStateInstance = provisioningStateValue; + propertiesInstance.provisioningState = provisioningStateInstance; + } + + var hostNameValue = propertiesValue['hostName']; + if (hostNameValue !== null && hostNameValue !== undefined) { + var hostNameInstance = hostNameValue; + propertiesInstance.hostName = hostNameInstance; + } + + var portValue = propertiesValue['port']; + if (portValue !== null && portValue !== undefined) { + var portInstance = portValue; + propertiesInstance.port = portInstance; + } + + var sslPortValue = propertiesValue['sslPort']; + if (sslPortValue !== null && sslPortValue !== undefined) { + var sslPortInstance = sslPortValue; + propertiesInstance.sslPort = sslPortInstance; + } + + var redisVersionValue = propertiesValue['redisVersion']; + if (redisVersionValue !== null && redisVersionValue !== undefined) { + var redisVersionInstance = redisVersionValue; + propertiesInstance.redisVersion = redisVersionInstance; + } + + var skuValue = propertiesValue['sku']; + if (skuValue !== null && skuValue !== undefined) { + var skuInstance = {}; + propertiesInstance.sku = skuInstance; + + var nameValue = skuValue['name']; + if (nameValue !== null && nameValue !== undefined) { + var nameInstance = nameValue; + skuInstance.name = nameInstance; + } + + var familyValue = skuValue['family']; + if (familyValue !== null && familyValue !== undefined) { + var familyInstance = familyValue; + skuInstance.family = familyInstance; + } + + var capacityValue = skuValue['capacity']; + if (capacityValue !== null && capacityValue !== undefined) { + var capacityInstance = capacityValue; + skuInstance.capacity = capacityInstance; + } + } + + var redisConfigurationSequenceElement = propertiesValue['redisConfiguration']; + if (redisConfigurationSequenceElement !== null && redisConfigurationSequenceElement !== undefined) { + for (var property in redisConfigurationSequenceElement) { + var redisConfigurationKey = property; + var redisConfigurationValue = redisConfigurationSequenceElement[property]; + propertiesInstance.redisConfiguration[redisConfigurationKey] = redisConfigurationValue; + } + } + + var enableNonSslPortValue = propertiesValue['enableNonSslPort']; + if (enableNonSslPortValue !== null && enableNonSslPortValue !== undefined) { + var enableNonSslPortInstance = enableNonSslPortValue; + propertiesInstance.enableNonSslPort = enableNonSslPortInstance; + } + } + + var idValue = valueValue['id']; + if (idValue !== null && idValue !== undefined) { + var idInstance = idValue; + redisResourceInstance.id = idInstance; + } + + var nameValue2 = valueValue['name']; + if (nameValue2 !== null && nameValue2 !== undefined) { + var nameInstance2 = nameValue2; + redisResourceInstance.name = nameInstance2; + } + + var typeValue = valueValue['type']; + if (typeValue !== null && typeValue !== undefined) { + var typeInstance = typeValue; + redisResourceInstance.type = typeInstance; + } + + var locationValue = valueValue['location']; + if (locationValue !== null && locationValue !== undefined) { + var locationInstance = locationValue; + redisResourceInstance.location = locationInstance; + } + + var tagsSequenceElement = valueValue['tags']; + if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) { + for (var property2 in tagsSequenceElement) { + var tagsKey = property2; + var tagsValue = tagsSequenceElement[property2]; + redisResourceInstance.tags[tagsKey] = tagsValue; + } + } + } + } + + var nextLinkValue = responseDoc['nextLink']; + if (nextLinkValue !== null && nextLinkValue !== undefined) { + var nextLinkInstance = nextLinkValue; + result.nextLink = nextLinkInstance; + } + } + + } + result.statusCode = statusCode; + result.requestId = response.headers['x-ms-request-id']; + + return callback(null, result); + }); + }; + + /** + * Regenerate redis cache's access keys. This operation requires write + * permission to the cache resource. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} name The name of the redis cache. + * + * @param {RedisRegenerateKeyParameters} parameters Specifies which key to + * reset. + * + * @param {RedisKeyType} parameters.keyType Which redis access key to reset + * + * @param {function} callback + * + * @returns {Stream} The response stream. + */ + RedisOperations.prototype.regenerateKey = function(resourceGroupName, name, parameters, callback) { + if (callback === null || callback === undefined) { + throw new Error('callback cannot be null.'); + } + // Validate + if (resourceGroupName === null || resourceGroupName === undefined) { + return callback(new Error('resourceGroupName cannot be null.')); + } + if (name === null || name === undefined) { + return callback(new Error('name cannot be null.')); + } + if (parameters === null || parameters === undefined) { + return callback(new Error('parameters cannot be null.')); + } + if (parameters.keyType === null || parameters.keyType === undefined) { + return callback(new Error('parameters.keyType cannot be null.')); + } + + // Tracing + + // Construct URL + var url2 = ''; + url2 = url2 + '/subscriptions/'; + if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) { + url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId); + } + url2 = url2 + '/resourceGroups/'; + url2 = url2 + encodeURIComponent(resourceGroupName); + url2 = url2 + '/providers/'; + url2 = url2 + 'Microsoft.Cache'; + url2 = url2 + '/Redis/'; + url2 = url2 + encodeURIComponent(name); + url2 = url2 + '/regenerateKey'; + var queryParameters = []; + queryParameters.push('api-version=2015-03-01'); + if (queryParameters.length > 0) { + url2 = url2 + '?' + queryParameters.join('&'); + } + var baseUrl = this.client.baseUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.length - 1] === '/') { + baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0); + } + if (url2[0] === '/') { + url2 = url2.substring(1); + } + url2 = baseUrl + '/' + url2; + url2 = url2.replace(' ', '%20'); + + // Create HTTP transport objects + var httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.headers = {}; + httpRequest.url = url2; + + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json'; + + // Serialize Request + var requestContent = null; + var requestDoc = null; + + var redisRegenerateKeyParametersValue = {}; + requestDoc = redisRegenerateKeyParametersValue; + + redisRegenerateKeyParametersValue['keyType'] = parameters.keyType !== null && parameters.keyType !== undefined ? parameters.keyType.toString() : 'Primary'; + + requestContent = JSON.stringify(requestDoc); + httpRequest.body = requestContent; + httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8'); + // Send Request + return this.client.pipeline(httpRequest, function (err, response, body) { + if (err !== null && err !== undefined) { + return callback(err); + } + var statusCode = response.statusCode; + if (statusCode !== 200) { + var error = new Error(body); + error.statusCode = response.statusCode; + return callback(error); + } + + // Create Result + var result = null; + // Deserialize Response + result = {}; + result.statusCode = statusCode; + result.requestId = response.headers['x-ms-request-id']; + + return callback(null, result); + }); + }; + + return RedisOperations; +})(); diff --git a/lib/services/rediscachemanagement/lib/rediscache.js b/lib/services/rediscachemanagement/lib/rediscache.js new file mode 100644 index 0000000000..35f1063147 --- /dev/null +++ b/lib/services/rediscachemanagement/lib/rediscache.js @@ -0,0 +1,19 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +var exports = module.exports; + +exports.RedisManagementClient = require('./RedisManagementClient').RedisManagementClient; \ No newline at end of file diff --git a/lib/services/rediscachemanagement/package.json b/lib/services/rediscachemanagement/package.json new file mode 100644 index 0000000000..1390efc8f0 --- /dev/null +++ b/lib/services/rediscachemanagement/package.json @@ -0,0 +1,43 @@ +{ + "name": "azure-arm-rediscache", + "author": "Microsoft Corporation", + "contributors": [ + "Thaniyulla Parambath, Alfan ", + "Dacosta, Carlyle ", + "Zavery, Amar " + ], + "version": "0.0.1", + "description": "Microsoft Azure Redis Cache Client Library for node", + "tags": [ + "azure", + "sdk" + ], + "keywords": [ + "node", + "azure" + ], + "main": "./lib/rediscache.js", + "engines": { + "node": ">= 0.6.15" + }, + "licenses": [ + { + "type": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0" + } + ], + "dependencies": { + "azure-common": "^0.9.13" + }, + "homepage": "http://github.com/Azure/azure-sdk-for-node", + "repository": { + "type": "git", + "url": "git@github.com:Azure/azure-sdk-for-node.git" + }, + "bugs": { + "url": "http://github.com/Azure/azure-sdk-for-node/issues" + }, + "scripts": { + "test": "npm -s run-script jshint" + } +} \ No newline at end of file