Skip to content

Commit

Permalink
Add Google Cloud DNS
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenplusplus committed Jul 21, 2015
1 parent b249f36 commit d6348d9
Show file tree
Hide file tree
Showing 18 changed files with 3,643 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
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.17.0': ['dns']
}
});
49 changes: 49 additions & 0 deletions lib/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,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
62 changes: 62 additions & 0 deletions lib/dns/change.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*!
* 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.
*/
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.
*/
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 d6348d9

Please sign in to comment.