Skip to content

Commit 6de83a5

Browse files
preparing for testing
1 parent 23a8de0 commit 6de83a5

29 files changed

Lines changed: 2080 additions & 1777 deletions

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
This client supports the following Google Cloud Platform services:
1212

1313
* [Google BigQuery](#google-bigquery)
14+
* [Google Compute Engine](#google-compute-engine)
1415
* [Google Cloud Datastore](#google-cloud-datastore)
1516
* [Google Cloud DNS](#google-cloud-dns)
1617
* [Google Cloud Storage](#google-cloud-storage)
@@ -113,6 +114,43 @@ job.getQueryResults().on('data', function(row) {});
113114
```
114115

115116

117+
## Google Compute Engine
118+
119+
- [API Documentation][gcloud-compute-docs]
120+
- [Official Documentation][cloud-compute-docs]
121+
122+
#### Preview
123+
124+
```js
125+
var gcloud = require('gcloud');
126+
127+
// Authorizing on a per-API-basis. You don't need to do this if you auth on a
128+
// global basis (see Authorization section above).
129+
130+
var gce = gcloud.compute({
131+
projectId: 'my-project',
132+
keyFilename: '/path/to/keyfile.json'
133+
});
134+
135+
// Create a new instance using the latest OS image of your choice
136+
var zone = gce.zone('us-central1-a');
137+
138+
var config = {
139+
os: 'ubuntu'
140+
};
141+
142+
zone.createInstance('ubuntu-http', config, function(err, instance, operation) {
143+
// `operation` lets you check the status of long-running tasks.
144+
145+
operation.onComplete(function(err, metadata) {
146+
if (!err) {
147+
// Instance created!
148+
}
149+
});
150+
});
151+
```
152+
153+
116154
## Google Cloud Datastore
117155

118156
- [API Documentation][gcloud-datastore-docs]
@@ -359,6 +397,7 @@ Apache 2.0 - See [COPYING](COPYING) for more information.
359397
[gcloud-homepage]: https://googlecloudplatform.github.io/gcloud-node/
360398
[gcloud-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs
361399
[gcloud-bigquery-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/bigquery
400+
[gcloud-compute-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/compute
362401
[gcloud-datastore-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/datastore
363402
[gcloud-dns-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/dns
364403
[gcloud-pubsub-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/pubsub
@@ -378,6 +417,8 @@ Apache 2.0 - See [COPYING](COPYING) for more information.
378417

379418
[cloud-bigquery-docs]: https://cloud.google.com/bigquery/what-is-bigquery
380419

420+
[cloud-compute-docs]: https://cloud.google.com/compute/docs
421+
381422
[cloud-datastore-docs]: https://cloud.google.com/datastore/docs
382423
[cloud-datastore-activation]: https://cloud.google.com/datastore/docs/activate
383424

docs/json/master/compute/.gitkeep

Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<h3>Compute Engine Overview</h3>
2+
<p>
3+
The object returned from <code>gcloud.compute</code> gives you complete control of your Compute Engine instances, snapshots, addresses, firewalls, and more.
4+
</p>
5+
<p>
6+
To learn more about Compute Engine, see <a href="https://cloud.google.com/compute/docs">What is Google Compute Engine?</a>
7+
</p>

docs/site/components/docs/docs-values.js

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,49 @@ angular.module('gcloud.docs')
3939
]
4040
},
4141

42+
compute: {
43+
title: 'Compute',
44+
_url: '{baseUrl}/compute',
45+
pages: [
46+
{
47+
title: 'Address',
48+
url: '/address'
49+
},
50+
{
51+
title: 'Disk',
52+
url: '/disk'
53+
},
54+
{
55+
title: 'Firewall',
56+
url: '/firewall'
57+
},
58+
{
59+
title: 'Instance',
60+
url: '/instance'
61+
},
62+
{
63+
title: 'Network',
64+
url: '/network'
65+
},
66+
{
67+
title: 'Operation',
68+
url: '/operation'
69+
},
70+
{
71+
title: 'Region',
72+
url: '/region'
73+
},
74+
{
75+
title: 'Snapshot',
76+
url: '/snapshot'
77+
},
78+
{
79+
title: 'Zone',
80+
url: '/zone'
81+
}
82+
]
83+
},
84+
4285
datastore: {
4386
title: 'Datastore',
4487
_url: '{baseUrl}/datastore',
@@ -180,6 +223,9 @@ angular.module('gcloud.docs')
180223
'>=0.16.0': ['search'],
181224

182225
// introduce dns api.
183-
'>=0.18.0': ['dns']
226+
'>=0.18.0': ['dns'],
227+
228+
// introduce compute api.
229+
'>=0.19.0': ['compute']
184230
}
185231
});

docs/site/components/docs/docs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ <h3 class="sub-heading">
4444
</article>
4545
<hr>
4646

47-
<article ng-repeat="service in ['bigquery', 'datastore', 'dns', 'pubsub', 'search', 'storage']"
47+
<article ng-repeat="service in ['bigquery', 'compute', 'datastore', 'dns', 'pubsub', 'search', 'storage']"
4848
ng-if="isActiveDoc(service)"
4949
ng-include="'site/components/docs/' + service + '-overview.html'">
5050
</article>

lib/compute/address.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Copyright 2014 Google Inc. All Rights Reserved.
2+
* Copyright 2015 Google Inc. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,70 +26,66 @@
2626
*/
2727
var util = require('../common/util.js');
2828

29+
/*! Developer Documentation
30+
*
31+
* @param {module:region} region - Region this address belongs to.
32+
* @param {string} name - The name of the address.
33+
*/
2934
/**
30-
* Create an Address object to interact with a Google Compute Engine address.
35+
* An Address object allows you to interact with a Google Compute Engine
36+
* address.
3137
*
3238
* @constructor
33-
* @alias module:region/address
34-
*
35-
* @throws {Error} if an address name or a region are not provided.
36-
*
37-
* @param {module:region} region - The Google Compute Engine region this
38-
* address belongs to.
39-
* @param {string} name - The name of the address.
40-
* @param {object=} metadata - Address metadata.
39+
* @alias module:compute/address
4140
*
4241
* @example
4342
* var gcloud = require('gcloud')({
44-
* keyFilename: '/path/to/keyfile.json'
43+
* keyFilename: '/path/to/keyfile.json',
44+
* projectId: 'grape-spaceship-123'
4545
* });
4646
*
4747
* var compute = gcloud.compute();
4848
*
49-
* var myRegion = compute.region('region-name');
49+
* var region = compute.region('region-name');
5050
*
51-
* var address = myRegion.address('address1');
51+
* var address = region.address('address1');
5252
*/
53-
function Address(region, name, metadata) {
53+
function Address(region, name) {
5454
this.region = region;
5555
this.name = name;
56-
this.metadata = metadata;
57-
58-
if (!util.is(this.name, 'string')) {
59-
throw new Error('A name is needed to use a Compute Engine Address.');
60-
}
61-
if (!this.region) {
62-
throw new Error('A region is needed to use a Compute Engine Address.');
63-
}
6456
}
6557

6658
/**
6759
* Delete the address.
6860
*
69-
* @param {function} callback - The callback function.
61+
* @param {function=} callback - The callback function.
7062
*
7163
* @example
7264
* address.delete(function(err, operation) {
73-
* // `operation` is an Operation object and can be used to check the status
74-
* // of address deletion.
65+
* // `operation` is an Operation object that can be used to check the status
66+
* // of the request.
7567
* });
7668
*/
7769
Address.prototype.delete = function(callback) {
7870
callback = callback || util.noop;
71+
7972
var region = this.region;
80-
this.makeReq_('DELETE', '', null, true, function(err, resp) {
73+
74+
this.makeReq_('DELETE', '', null, null, function(err, resp) {
8175
if (err) {
82-
callback(err);
76+
callback(err, null, resp);
8377
return;
8478
}
79+
8580
var operation = region.operation(resp.name);
8681
operation.metadata = resp;
87-
callback(null, operation);
82+
83+
callback(null, operation, resp);
8884
});
8985
};
9086

9187
/**
92-
* Get the address' metadata.
88+
* Get the metadata of this address.
9389
*
9490
* @param {function=} callback - The callback function.
9591
*
@@ -98,13 +94,17 @@ Address.prototype.delete = function(callback) {
9894
*/
9995
Address.prototype.getMetadata = function(callback) {
10096
callback = callback || util.noop;
97+
10198
var self = this;
99+
102100
this.makeReq_('GET', '', null, null, function(err, resp) {
103101
if (err) {
104-
callback(err);
102+
callback(err, null, resp);
105103
return;
106104
}
105+
107106
self.metadata = resp;
107+
108108
callback(null, self.metadata, resp);
109109
});
110110
};
@@ -126,4 +126,4 @@ Address.prototype.makeReq_ = function(method, path, query, body, callback) {
126126
this.region.makeReq_(method, path, query, body, callback);
127127
};
128128

129-
module.exports = Address;
129+
module.exports = Address;

0 commit comments

Comments
 (0)