@@ -50,6 +50,12 @@ var Network = require('./network.js');
5050 */
5151var Operation = require ( './operation.js' ) ;
5252
53+ /**
54+ * @type {module: compute/project }
55+ * @private
56+ */
57+ var Project = require ( './project.js' ) ;
58+
5359/**
5460 * @type {module:compute/region }
5561 * @private
@@ -1734,6 +1740,84 @@ Compute.prototype.getOperations = function(options, callback) {
17341740Compute . prototype . getOperationsStream =
17351741 common . paginator . streamify ( 'getOperations' ) ;
17361742
1743+ /**
1744+ * Return the regions available to your project.
1745+ *
1746+ * @resource [Project Overview]{@link https://cloud.google.com/compute/docs/projects}
1747+ *
1748+ * @param {function } callback - The callback function.
1749+ * @param {?error } callback.err - An error returned while making this request.
1750+ * @param {module:compute/project } callback.project - Project objects with
1751+ * details
1752+ * @param {object } callback.apiResponse - The full API response.
1753+ *
1754+ * @example
1755+ * gce.getProject(function(err, project) {
1756+ * // `project` is an object with metadata
1757+ * });
1758+ *
1759+ *
1760+ *
1761+ * //-
1762+ * // If the callback is omitted, we'll return a Promise.
1763+ * //-
1764+ * gce.getProject().then(function(data) {
1765+ * var project = data[0];
1766+ * });
1767+ */
1768+ Compute . prototype . getProject = function ( options , callback ) {
1769+ var self = this ;
1770+
1771+ if ( is . fn ( options ) ) {
1772+ callback = options ;
1773+ options = { } ;
1774+ }
1775+
1776+ this . request ( {
1777+ uri : '' ,
1778+ qs : options
1779+ } , function ( err , resp ) {
1780+
1781+ if ( err ) {
1782+ callback ( err , null , null , resp ) ;
1783+ return ;
1784+ }
1785+
1786+ var project = new Project ( self ) ;
1787+ project . metadata = resp ;
1788+
1789+ callback ( null , project , null , resp ) ;
1790+ } ) ;
1791+ } ;
1792+
1793+ /**
1794+ * Get a list of global {module:compute/project} objects as a readable object
1795+ * stream.
1796+ *
1797+ * @return {stream }
1798+ *
1799+ * @example
1800+ * gce.getProjectStream()
1801+ * .on('error', console.error)
1802+ * .on('data', function(operation) {
1803+ * // `operation` is a `Operation` object.
1804+ * })
1805+ * .on('end', function() {
1806+ * // All operations retrieved.
1807+ * });
1808+ *
1809+ * //-
1810+ * // If you anticipate many results, you can end a stream early to prevent
1811+ * // unnecessary processing and API requests.
1812+ * //-
1813+ * gce.getProjectStream()
1814+ * .on('data', function(operation) {
1815+ * this.end();
1816+ * });
1817+ */
1818+ Compute . prototype . getProjectStream =
1819+ common . paginator . streamify ( 'getProject' ) ;
1820+
17371821/**
17381822 * Return the regions available to your project.
17391823 *
@@ -2632,6 +2716,21 @@ Compute.prototype.operation = function(name) {
26322716 return new Operation ( this , name ) ;
26332717} ;
26342718
2719+ /**
2720+ * Get a reference to your Google Compute Engine project.
2721+ *
2722+ * @resource [Projects Overview]{@link https://cloud.google.com/compute/docs/reference/v1/projects}
2723+ *
2724+ * @param {string } name - Name of the existing operation.
2725+ * @return {module:compute/project }
2726+ *
2727+ * @example
2728+ * var project = gce.project();
2729+ */
2730+ Compute . prototype . project = function ( ) {
2731+ return new Project ( this ) ;
2732+ } ;
2733+
26352734/**
26362735 * Get a reference to a Google Compute Engine region.
26372736 *
@@ -2771,6 +2870,7 @@ common.util.promisifyAll(Compute, {
27712870 'machineType' ,
27722871 'network' ,
27732872 'operation' ,
2873+ 'project' ,
27742874 'region' ,
27752875 'rule' ,
27762876 'service' ,
@@ -2785,6 +2885,7 @@ Compute.Firewall = Firewall;
27852885Compute . HealthCheck = HealthCheck ;
27862886Compute . Network = Network ;
27872887Compute . Operation = Operation ;
2888+ Compute . Project = Project ;
27882889Compute . Region = Region ;
27892890Compute . Rule = Rule ;
27902891Compute . Service = Service ;
0 commit comments