@@ -50,6 +50,12 @@ var Network = require('./network.js');
50
50
*/
51
51
var Operation = require ( './operation.js' ) ;
52
52
53
+ /**
54
+ * @type {module: compute/project }
55
+ * @private
56
+ */
57
+ var Project = require ( './project.js' ) ;
58
+
53
59
/**
54
60
* @type {module:compute/region }
55
61
* @private
@@ -1734,6 +1740,84 @@ Compute.prototype.getOperations = function(options, callback) {
1734
1740
Compute . prototype . getOperationsStream =
1735
1741
common . paginator . streamify ( 'getOperations' ) ;
1736
1742
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
+
1737
1821
/**
1738
1822
* Return the regions available to your project.
1739
1823
*
@@ -2632,6 +2716,21 @@ Compute.prototype.operation = function(name) {
2632
2716
return new Operation ( this , name ) ;
2633
2717
} ;
2634
2718
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
+
2635
2734
/**
2636
2735
* Get a reference to a Google Compute Engine region.
2637
2736
*
@@ -2771,6 +2870,7 @@ common.util.promisifyAll(Compute, {
2771
2870
'machineType' ,
2772
2871
'network' ,
2773
2872
'operation' ,
2873
+ 'project' ,
2774
2874
'region' ,
2775
2875
'rule' ,
2776
2876
'service' ,
@@ -2785,6 +2885,7 @@ Compute.Firewall = Firewall;
2785
2885
Compute . HealthCheck = HealthCheck ;
2786
2886
Compute . Network = Network ;
2787
2887
Compute . Operation = Operation ;
2888
+ Compute . Project = Project ;
2788
2889
Compute . Region = Region ;
2789
2890
Compute . Rule = Rule ;
2790
2891
Compute . Service = Service ;
0 commit comments