Skip to content

Commit

Permalink
Integrate resource manager support
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenplusplus committed Sep 14, 2015
1 parent 7714afa commit 040d25a
Show file tree
Hide file tree
Showing 13 changed files with 1,425 additions and 10 deletions.
52 changes: 46 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ This client supports the following Google Cloud Platform services:
* [Google Cloud Pub/Sub](#google-cloud-pubsub)
* [Google Cloud Storage](#google-cloud-storage)
* [Google Compute Engine](#google-compute-engine)
* [Google Cloud Resource Manager](#google-cloud-resource-manager-beta) (Beta)
* [Google Cloud Search](#google-cloud-search-alpha) (Alpha)

If you need support for other Google APIs, check out the [Google Node.js API Client library][googleapis].
Expand Down Expand Up @@ -181,8 +182,8 @@ var gcloud = require('gcloud');
// global basis (see Authorization section above).

var dns = gcloud.dns({
keyFilename: '/path/to/keyfile.json',
projectId: 'my-project'
projectId: 'my-project',
keyFilename: '/path/to/keyfile.json'
});

// Create a managed zone.
Expand Down Expand Up @@ -264,8 +265,8 @@ var gcloud = require('gcloud');
// global basis (see Authorization section above).

var gcs = gcloud.storage({
keyFilename: '/path/to/keyfile.json',
projectId: 'my-project'
projectId: 'my-project',
keyFilename: '/path/to/keyfile.json'
});

// Create a new bucket.
Expand Down Expand Up @@ -335,6 +336,42 @@ zone.createVM(name, { os: 'ubuntu' }, function(err, vm, operation) {
```


## Google Cloud Resource Manager (Beta)

> This is a *Beta* release of Google Cloud Resource Manager. This feature is not covered by any SLA or deprecation policy and may be subject to backward-incompatible changes.
- [API Documentation][gcloud-resource-docs]
- [Official Documentation][cloud-resource-docs]

#### Preview

```js
var gcloud = require('gcloud');

// Authorizing on a per-API-basis. You don't need to do this if you auth on a
// global basis (see Authorization section above).

var resource = gcloud.resource({
projectId: 'my-project',
keyFilename: '/path/to/keyfile.json'
});

// Get all of the projects you maintain.
resource.getProjects(function(err, projects) {
if (!err) {
// `projects` contains all of your projects.
}
});

// Get the metadata from your project. (defaults to `my-project`)
var project = resource.project();

project.getMetadata(function(err, metadata) {
// `metadata` describes your project.
});
```


## Google Cloud Search (Alpha)

> This is an *Alpha* release of Google Cloud Search. This feature is not covered by any SLA or deprecation policy and may be subject to backward-incompatible changes.
Expand All @@ -351,8 +388,8 @@ var gcloud = require('gcloud');
// global basis (see Authorization section above).

var search = gcloud.search({
keyFilename: '/path/to/keyfile.json',
projectId: 'my-project'
projectId: 'my-project',
keyFilename: '/path/to/keyfile.json'
});

// Create a document in a new index.
Expand Down Expand Up @@ -396,6 +433,7 @@ Apache 2.0 - See [COPYING](COPYING) for more information.
[gcloud-datastore-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/datastore
[gcloud-dns-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/dns
[gcloud-pubsub-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/pubsub
[gcloud-resource-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/resource
[gcloud-search-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/search
[gcloud-storage-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/storage

Expand All @@ -421,6 +459,8 @@ Apache 2.0 - See [COPYING](COPYING) for more information.

[cloud-pubsub-docs]: https://cloud.google.com/pubsub/docs

[cloud-resource-docs]: https://cloud.google.com/resource-manager

[cloud-search-docs]: https://cloud.google.com/search/

[cloud-storage-docs]: https://cloud.google.com/storage/docs/overview
Empty file.
16 changes: 15 additions & 1 deletion docs/site/components/docs/docs-values.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,17 @@ angular.module('gcloud.docs')
]
},

resource: {
title: 'Resource',
_url: '{baseUrl}/resource',
pages: [
{
title: 'Project',
url: '/project'
}
]
},

search: {
title: 'Search',
_url: '{baseUrl}/search',
Expand Down Expand Up @@ -226,6 +237,9 @@ angular.module('gcloud.docs')
'>=0.18.0': ['dns'],

// introduce compute api.
'>=0.20.0': ['compute']
'>=0.20.0': ['compute'],

// introduce resource api.
'>=0.22.0': ['resource']
}
});
2 changes: 1 addition & 1 deletion docs/site/components/docs/docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h3 class="sub-heading">
</article>
<hr>

<article ng-repeat="service in ['bigquery', 'compute', 'datastore', 'dns', 'pubsub', 'search', 'storage']"
<article ng-repeat="service in ['bigquery', 'compute', 'datastore', 'dns', 'pubsub', 'resource', 'search', 'storage']"
ng-if="isActiveDoc(service)"
ng-include="'site/components/docs/' + service + '-overview.html'">
</article>
Expand Down
10 changes: 10 additions & 0 deletions docs/site/components/docs/resource-overview.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<h3>Resource Overview</h3>
<p class="notice">
<strong>This is a Beta release of Cloud Resource Manager.</strong> This feature is not covered by any SLA or deprecation policy and may be subject to backward-incompatible changes.
</p>
<p>
The object returned from <code>gcloud.resource</code> gives you complete access to your projects.
</p>
<p>
To learn more about Resource Manager, see <a href="https://cloud.google.com/resource-manager">What is the Google Cloud Resource Manager?</a>
</p>
6 changes: 4 additions & 2 deletions lib/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,11 +473,13 @@ util.decorateRequest = decorateRequest;
* @param {?object} localConfig - api level configurations
* @return {object} config - merged and validated configurations
*/
function normalizeArguments(globalContext, localConfig) {
function normalizeArguments(globalContext, localConfig, options) {
var globalConfig = globalContext && globalContext.config_ || {};
var config = util.extendGlobalConfig(globalConfig, localConfig);

if (!config.projectId) {
options = options || {};

if (!config.projectId && options.projectIdRequired !== false) {
throw util.missingProjectIdError;
}

Expand Down
23 changes: 23 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,29 @@ var apis = {
*/
pubsub: require('./pubsub'),

/**
* [The Cloud Resource Manager](https://cloud.google.com/resource-manager/)
* provides methods that you can use to programmatically manage your projects
* in the Google Cloud Platform. With this API, you can do the following:
*
* - Get a list of all projects associated with an account.
* - Create new projects.
* - Update existing projects.
* - Delete projects.
* - Recover projects.
*
* <p class="notice">
* **This is a *Beta* release of Cloud Resource Manager.** This feature is
* not covered by any SLA or deprecation policy and may be subject to
* backward-incompatible changes.
* </p>
*
* @type {module:resource}
*
* @return {module:resource}
*/
resource: require('./resource'),

/**
* [Google Cloud Search](https://cloud.google.com/search/) allows you to
* quickly perform full-text and geospatial searches against your data without
Expand Down
Loading

0 comments on commit 040d25a

Please sign in to comment.