Skip to content

Commit

Permalink
Merge pull request #706 from stephenplusplus/spp--dns
Browse files Browse the repository at this point in the history
Add Google Cloud DNS
  • Loading branch information
stephenplusplus committed Jul 29, 2015
2 parents a108687 + ad63809 commit f57d3b1
Show file tree
Hide file tree
Showing 19 changed files with 3,722 additions and 1 deletion.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ To run the system tests, first create and configure a project in the Google Deve

- **GCLOUD_TESTS_PROJECT_ID**: Developers Console project's ID (e.g. bamboo-shift-455)
- **GCLOUD_TESTS_KEY**: The path to the JSON key file.
- ***GCLOUD_TESTS_DNS_DOMAIN*** (*optional*): A domain you own managed by Google Cloud DNS (expected format: `'gcloud-node.com.'`).

Install the [gcloud command-line tool][gcloudcli] to your machine and use it to create the indexes used in the datastore system tests with indexes found in `system-test/data/index/yaml`:

Expand Down
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This client supports the following Google Cloud Platform services:

* [Google BigQuery](#google-bigquery)
* [Google Cloud Datastore](#google-cloud-datastore)
* [Google Cloud DNS](#google-cloud-dns)
* [Google Cloud Storage](#google-cloud-storage)
* [Google Cloud Pub/Sub](#google-cloud-pubsub-beta) (Beta)
* [Google Cloud Search](#google-cloud-search-alpha) (Alpha)
Expand Down Expand Up @@ -165,6 +166,46 @@ dataset.save({
```


## Google Cloud DNS

- [API Documentation][gcloud-dns-docs]
- [Official Documentation][cloud-dns-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 dns = gcloud.dns({
keyFilename: '/path/to/keyfile.json',
projectId: 'my-project'
});

// Create a managed zone.
dns.createZone('my-new-zone', {
dnsName: 'my-domain.com.'
}, function(err, zone) {});

// Reference an existing zone.
var zone = dns.zone('my-existing-zone');

// Create an NS record.
var nsRecord = zone.record('ns', {
ttl: 86400,
name: 'my-domain.com.',
data: 'ns-cloud1.googledomains.com.'
});

zone.addRecord(nsRecord, function(err, change) {});

// Create a zonefile from the records in your zone.
zone.export('/zonefile.zone', function(err) {});
```


## Google Cloud Storage

- [API Documentation][gcloud-storage-docs]
Expand Down Expand Up @@ -319,6 +360,7 @@ Apache 2.0 - See [COPYING](COPYING) for more information.
[gcloud-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs
[gcloud-bigquery-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/bigquery
[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-search-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/search
[gcloud-storage-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/storage
Expand All @@ -339,6 +381,8 @@ Apache 2.0 - See [COPYING](COPYING) for more information.
[cloud-datastore-docs]: https://cloud.google.com/datastore/docs
[cloud-datastore-activation]: https://cloud.google.com/datastore/docs/activate

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

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

[cloud-search-docs]: https://cloud.google.com/search/
Expand Down
File renamed without changes.
24 changes: 23 additions & 1 deletion docs/site/components/docs/docs-values.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,25 @@ angular.module('gcloud.docs')
]
},

dns: {
title: 'DNS',
_url: '{baseUrl}/dns',
pages: [
{
title: 'Zone',
url: '/zone'
},
{
title: 'Record',
url: '/record'
},
{
title: 'Change',
url: '/change'
}
]
},

pubsub: {
title: 'PubSub',
_url: '{baseUrl}/pubsub',
Expand Down Expand Up @@ -158,6 +177,9 @@ angular.module('gcloud.docs')
'>=0.10.0': ['bigquery'],

// introduce search api.
'>=0.16.0': ['search']
'>=0.16.0': ['search'],

// introduce dns api.
'>=0.18.0': ['dns']
}
});
49 changes: 49 additions & 0 deletions lib/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,55 @@ function getType(value) {
return Object.prototype.toString.call(value).match(/\s(\w+)\]/)[1];
}

/**
* Iterate through an array, invoking a function by the provided name.
*
* @param {string} name - The name of the function that exists as a property on
* each member of the iterated array.
* @return {function}
*
* @example
* var people = [
* {
* getName: function() { return 'Stephen'; }
* },
* {
* getName: function() { return 'Dave'; }
* }
* };
*
* var names = people.map(exec('getName'));
* // names = [ 'Stephen', 'Dave' ]
*
* //-
* // Aguments can also be provided.
* //-
* var people = [
* {
* getName: function(prefix) { return prefix + ' Stephen'; }
* },
* {
* getName: function(prefix) { return prefix + ' Dave'; }
* }
* ];
*
* var names = people.map(exec('getName', 'Mr.'));
* // names = [ 'Mr. Stephen', 'Mr. Dave' ];
*/
function exec(name) {
var initialArguments = [].slice.call(arguments, 1);

return function(item) {
if (util.is(item[name], 'function')) {
var invokedArguments = [].slice.call(arguments, 1);
return item[name].apply(item, initialArguments.concat(invokedArguments));
}
return item[name];
};
}

util.exec = exec;

/**
* Used in an Array iterator usually, this will return the value of a property
* in an object by its name.
Expand Down
87 changes: 87 additions & 0 deletions lib/dns/change.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*!
* Copyright 2014 Google Inc. 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.
*/

/*!
* @module dns/change
*/

'use strict';

/**
* @constructor
* @alias module:dns/change
*
* @param {module:dns/zone} zone - The parent zone object.
* @param {string} id - ID of the change.
*
* @example
* var gcloud = require('gcloud');
*
* var dns = gcloud.dns({
* keyFilename: '/path/to/keyfile.json',
* projectId: 'grape-spaceship-123'
* });
*
* var zone = dns.zone('zone-id');
* var change = zone.change('change-id');
*/
function Change(zone, id) {
this.zoneName = zone.name;
this.id = id;

this.metadata = {};
this.makeReq_ = zone.dns.makeReq_.bind(zone.dns);
}

/**
* Get the metadata for the change in the zone.
*
* @param {function} callback - The callback function.
* @param {?error} callback.err - An API error.
* @param {?object} callback.metadata - Metadata of the change from the API.
* @param {object} callback.apiResponse - Raw API response.
*
* @example
* change.getMetadata(function(err, metadata, apiResponse) {
* if (!err) {
* // metadata = {
* // kind: 'dns#change',
* // additions: [{...}],
* // deletions: [{...}],
* // startTime: '2015-07-21T14:40:06.056Z',
* // id: '1',
* // status: 'done'
* // }
* }
* });
*/
Change.prototype.getMetadata = function(callback) {
var self = this;
var path = '/managedZones/' + this.zoneName + '/changes/' + this.id;

this.makeReq_('GET', path, null, null, function(err, resp) {
if (err) {
callback(err, null, resp);
return;
}

self.metadata = resp;

callback(null, self.metadata, resp);
});
};

module.exports = Change;
Loading

0 comments on commit f57d3b1

Please sign in to comment.