azure-arm-resource
Advanced tools
Comparing version 0.10.7 to 1.0.0-preview
@@ -16,85 +16,9 @@ // | ||
// | ||
'use strict'; | ||
var exports = module.exports; | ||
exports.AuthorizationClient = require('./authorization/authorizationClient'); | ||
exports.FeatureClient = require('./feature/featureClient'); | ||
exports.SubscriptionClient = require('./subscription/subscriptionClient'); | ||
exports.ResourceManagementClient = require('./resource/resourceManagementClient'); | ||
var ResourceManagementClient = require('./resourceManagementClient'); | ||
exports.ResourceManagementClient = ResourceManagementClient; | ||
/** | ||
* Creates a new {@link ResourceManagementClient} object. | ||
* | ||
* @param {string} [credentials.subscriptionId] The subscription identifier. | ||
* @param {string} [credentials.token] The access token. | ||
* @param {string} [baseUri] The base uri. | ||
* @return {ResourceManagementClient} A new ResourceManagementClient object. | ||
*/ | ||
exports.createResourceManagementClient = function (credentials, baseUri) { | ||
return new exports.ResourceManagementClient.ResourceManagementClient(credentials, baseUri); | ||
}; | ||
var ResourceSubscriptionClient = require('./subscriptionClient'); | ||
exports.ResourceSubscriptionClient = ResourceSubscriptionClient; | ||
/** | ||
* Creates a new {@link ResourceSubscriptionClient} object. | ||
* | ||
* @param {string} [credentials.token] The access token. | ||
* @param {string} [baseUri] The base uri. | ||
* @return {ResourceSubscriptionClient} A new ResourceSubscriptionClient object. | ||
*/ | ||
exports.createResourceSubscriptionClient = function (credentials, baseUri) { | ||
return new exports.ResourceSubscriptionClient.SubscriptionClient(credentials, baseUri); | ||
}; | ||
var ResourceFeatureClient = require('./featureClient'); | ||
exports.ResourceFeatureClient = ResourceFeatureClient; | ||
/** | ||
* Creates a new {@link ResourceFeatureClient} object. | ||
* | ||
* @param {string} [credentials.token] The access token. | ||
* @param {string} [baseUri] The base uri. | ||
* @return {ResourceFeatureClient} A new ResourceFeatureClient object. | ||
*/ | ||
exports.createResourceFeatureClient = function (credentials, baseUri) { | ||
return new exports.ResourceFeatureClient.FeatureClient(credentials, baseUri); | ||
}; | ||
function getProviderName(resourceType) { | ||
var firstIndex = resourceType.indexOf('/'); | ||
var providerName; | ||
if (firstIndex !== -1){ | ||
providerName = resourceType.substr(0, firstIndex); | ||
} | ||
return providerName; | ||
} | ||
function getResourceTypeName(resourceType) { | ||
var lastIndex = resourceType.lastIndexOf('/'); | ||
var resourceTypeName; | ||
if (lastIndex !== -1){ | ||
resourceTypeName = resourceType.substr(lastIndex+1); | ||
} | ||
return resourceTypeName; | ||
} | ||
/** | ||
* Creates a new Resource Identity object. | ||
* | ||
* @param {string} name The resource name | ||
* @param {string} resourceType The resource type. | ||
* @param {string} apiVersion The api version. | ||
* @param {string} [parent] The parent resource. | ||
* @return {object} The resource identity. | ||
*/ | ||
exports.createResourceIdentity = function (name, resourceType, apiVersion, parent) { | ||
var identity = { | ||
resourceName: name, | ||
resourceProviderNamespace: getProviderName(resourceType), | ||
resourceProviderApiVersion: apiVersion, | ||
resourceType: getResourceTypeName(resourceType), | ||
parentResourcePath: !!parent ? parent : '' | ||
}; | ||
return identity; | ||
}; | ||
exports = module.exports; |
@@ -5,11 +5,7 @@ { | ||
"contributors": [ | ||
"Block, Glenn <gblock@microsoft.com>", | ||
"Cowlishaw, Mark <markcowl@microsoft.com>", | ||
"Dejardin, Louis <loudej@microsoft.com>", | ||
"Georgiev, Yavor <yavorg@microsoft.com>", | ||
"Janczuk, Tomasz <tjanczuk@microsoft.com>", | ||
"Rodrigues, Andre <andrerod@microsoft.com>", | ||
"Tavares, Chris <ctavares@microsoft.com>" | ||
"Wang, Yugang <yugangw@microsoft.com>", | ||
"Zavery, Amar <amzavery@microsoft.com>", | ||
"Srinivasan, Vivek <visriniv@microsoft.com>" | ||
], | ||
"version": "0.10.7", | ||
"version": "1.0.0-preview", | ||
"description": "Microsoft Azure Resource Management Client Library for node", | ||
@@ -26,3 +22,3 @@ "tags": [ | ||
"engines": { | ||
"node": ">= 0.6.15" | ||
"node": ">= 0.10.0" | ||
}, | ||
@@ -36,4 +32,4 @@ "licenses": [ | ||
"dependencies": { | ||
"azure-common": "^0.9.13", | ||
"underscore": "1.4.x" | ||
"ms-rest": "^1.8.0", | ||
"ms-rest-azure": "^1.8.0" | ||
}, | ||
@@ -40,0 +36,0 @@ "homepage": "http://github.com/Azure/azure-sdk-for-node", |
137
README.md
# Microsoft Azure SDK for Node.js - Resource Management | ||
This project provides a Node.js package that makes it easy to manage Azure resources. Right now it supports: | ||
- **Node.js version: 0.6.15 or higher** | ||
- **API version: 2013-08-01** | ||
- **Node.js version: 0.10.0 or higher** | ||
- **API version: 2015-11-01** | ||
@@ -21,3 +21,9 @@ ## Features | ||
- TODO: Describe tokens | ||
```javascript | ||
var msrestAzure = require('ms-rest-azure'); | ||
//user authentication | ||
var credentials = new msRestAzure.UserTokenCredentials('your-client-id', 'your-domain', 'your-username', 'your-password', 'your-redirect-uri'); | ||
//service principal authentication | ||
var credentials = new msRestAzure.ApplicationTokenCredentials('your-client-id', 'your-domain', 'your-secret'); | ||
``` | ||
@@ -27,14 +33,123 @@ ### Create the ResourceManagementClient | ||
```javascript | ||
var fs = require("fs"), | ||
common = require("azure-common"), | ||
resourceManagement = require("azure-arm-resource"); | ||
var resourceManagement = require("azure-arm-resource"); | ||
var client = new resourceManagement.ResourceManagementClient(credentials, 'your-subscription-id'); | ||
``` | ||
var resourceManagementClient = resourceManagement.createResourceManagementClient(new common.TokenCloudCredentials({ | ||
subscriptionId: "<your subscription id>", | ||
token: "<your token here>" | ||
})); | ||
## Creating a Resource Group | ||
```javascript | ||
var util = require('util'); | ||
var groupParameters = { | ||
location: 'West US', | ||
tags: { | ||
tag1: 'val1', | ||
tag2: 'val2' | ||
} | ||
}; | ||
var groupName = 'testGroup1'; | ||
client.resourceGroups.createOrUpdate(groupName, groupParameters, function (err, result, request, response) { | ||
if (err) { | ||
console.log(err); | ||
/*err has reference to the actual request and response, so you can see what was sent and received on the wire. | ||
The structure of err looks like this: | ||
err: { | ||
code: 'Error Code', | ||
message: 'Error Message', | ||
body: 'The response body if any', | ||
request: reference to a stripped version of http request | ||
response: reference to a stripped version of the response | ||
} | ||
*/ | ||
} else { | ||
console.log('result is: ' + util.inspect(result, {depth: null})); | ||
} | ||
}); | ||
``` | ||
## Create a Generic Resource in a Resource Group | ||
```javascript | ||
var groupName = 'testGroup1'; | ||
var resourceName = 'autorestsite102'; | ||
var params = { 'location': 'West US', 'properties' : { 'SiteMode': 'Limited', 'ComputeMode': 'Shared' }, 'Name': resourceName }; | ||
var resourceType = 'sites'; | ||
var parentResourcePath = ''; | ||
var resourceProviderNamespace = 'Microsoft.Web'; | ||
var apiVersion = '2014-04-01'; | ||
client.resources.createOrUpdate(groupName, resourceProviderNamespace, parentResourcePath, | ||
resourceType, resourceName , apiVersion, params, function (err, result, request, response) { | ||
if (err) { | ||
console.log(err); | ||
} else { | ||
console.log(result); | ||
} | ||
}); | ||
``` | ||
## Get a Generic Resource in a Resource Group | ||
```javascript | ||
var groupName = 'testGroup1'; | ||
var resourceName = 'autorestsite102'; | ||
var resourceType = 'sites'; | ||
var parentResourcePath = ''; | ||
var resourceProviderNamespace = 'Microsoft.Web'; | ||
var apiVersion = '2014-04-01'; | ||
client.resources.get(groupName, resourceProviderNamespace, parentResourcePath, | ||
resourceType, resourceName, apiVersion, function (err, result, request, response) { | ||
if (err) { | ||
console.log(err); | ||
} else { | ||
console.log(result); | ||
} | ||
}); | ||
``` | ||
## Listing all resources in your subscription | ||
```javascript | ||
client.resources.list(function (err, result, request, response) { | ||
if (err) { | ||
console.log(err); | ||
} else { | ||
console.log(result); | ||
} | ||
}); | ||
``` | ||
## Deleting a Generic Resource in a Resource Group | ||
```javascript | ||
var groupName = 'testGroup1'; | ||
var resourceName = 'autorestsite102'; | ||
var resourceType = 'sites'; | ||
var parentResourcePath = ''; | ||
var resourceProviderNamespace = 'Microsoft.Web'; | ||
var apiVersion = '2014-04-01'; | ||
client.resources.deleteMethod(groupName, resourceProviderNamespace, parentResourcePath, | ||
resourceType, resourceName, apiVersion, function (err, result, request, response) { | ||
if (err) { | ||
console.log(err); | ||
} else { | ||
console.log(result); | ||
} | ||
}); | ||
``` | ||
## Deleting the Resource Group | ||
```javascript | ||
var groupName = 'testGroup1'; | ||
client.resourceGroups.deleteMethod(groupName, function (err, result, request, response) { | ||
if (err) { | ||
console.log(err); | ||
} else { | ||
console.log(result); | ||
} | ||
}); | ||
``` | ||
Please take a look at the tests over [here](https://github.com/Azure/azure-sdk-for-node/tree/autorest/test/services/resourceManagement) for more examples. | ||
## Related projects | ||
- [Microsoft Azure SDK for Node.js - All-up](https://github.com/WindowsAzure/azure-sdk-for-node) | ||
- [Microsoft Azure SDK for Node.js - All-up](https://github.com/Azure/azure-sdk-for-node) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
884710
110
21728
0
154
1
+ Addedms-rest@^1.8.0
+ Addedms-rest-azure@^1.8.0
+ Added@types/node@8.10.66(transitive)
+ Addedadal-node@0.1.28(transitive)
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedassert-plus@0.2.0(transitive)
+ Addedasync@0.2.72.6.43.2.6(transitive)
+ Addedaws-sign2@0.6.0(transitive)
+ Addedazure-arm-resource@1.6.1-preview(transitive)
+ Addedbl@1.1.2(transitive)
+ Addedboom@2.10.1(transitive)
+ Addedbuffer-equal-constant-time@1.0.1(transitive)
+ Addedcaseless@0.11.0(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedcryptiles@2.0.5(transitive)
+ Addeddate-utils@1.2.21(transitive)
+ Addedecdsa-sig-formatter@1.0.11(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedform-data@1.0.1(transitive)
+ Addedgenerate-function@2.3.1(transitive)
+ Addedgenerate-object-property@1.2.0(transitive)
+ Addedhar-validator@2.0.6(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedhawk@3.1.3(transitive)
+ Addedhoek@2.16.3(transitive)
+ Addedhttp-signature@1.1.1(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-my-ip-valid@1.0.1(transitive)
+ Addedis-my-json-valid@2.20.6(transitive)
+ Addedis-property@1.0.2(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedjsonpointer@5.0.1(transitive)
+ Addedjwa@1.4.1(transitive)
+ Addedjws@3.2.2(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedmoment@2.30.1(transitive)
+ Addedms-rest@1.15.7(transitive)
+ Addedms-rest-azure@1.15.7(transitive)
+ Addednode-uuid@1.4.8(transitive)
+ Addedoauth-sign@0.8.2(transitive)
+ Addedpinkie@2.0.4(transitive)
+ Addedpinkie-promise@2.0.1(transitive)
+ Addedprocess-nextick-args@1.0.7(transitive)
+ Addedpunycode@1.4.1(transitive)
+ Addedqs@6.2.4(transitive)
+ Addedreadable-stream@2.0.6(transitive)
+ Addedrequest@2.74.0(transitive)
+ Addedsntp@1.0.9(transitive)
+ Addedstring_decoder@0.10.31(transitive)
+ Addedstringstream@0.0.6(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.0(transitive)
+ Addedtough-cookie@2.3.4(transitive)
+ Addedtunnel-agent@0.4.3(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedxmldom@0.6.0(transitive)
+ Addedxpath.js@1.1.0(transitive)
+ Addedxtend@4.0.2(transitive)
- Removedazure-common@^0.9.13
- Removedunderscore@1.4.x
- Removedajv@6.12.6(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedazure-common@0.9.27(transitive)
- Removedcaseless@0.12.0(transitive)
- Removeddateformat@1.0.2-1.2.3(transitive)
- Removedenvconf@0.0.4(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedform-data@2.3.3(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.10.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsax@1.4.1(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedunderscore@1.4.4(transitive)
- Removeduri-js@4.4.1(transitive)
- Removedvalidator@13.7.0(transitive)
- Removedxml2js@0.4.23(transitive)
- Removedxmlbuilder@11.0.115.1.1(transitive)