@@ -64,7 +64,7 @@ function Resource(options) {
6464 }
6565
6666 var config = {
67- baseUrl : 'https://cloudresourcemanager.googleapis.com/v1beta1 ' ,
67+ baseUrl : 'https://cloudresourcemanager.googleapis.com/v1 ' ,
6868 scopes : [ 'https://www.googleapis.com/auth/cloud-platform' ] ,
6969 projectIdRequired : false ,
7070 packageJson : require ( '../package.json' )
@@ -84,31 +84,51 @@ util.inherits(Resource, common.Service);
8484 * gcloud SDK.**
8585 *
8686 * @resource [Projects Overview]{@link https://cloud.google.com/compute/docs/networking#networks}
87- * @resource [projects: create API Documentation]{@link https://cloud.google.com/resource-manager/reference/rest/v1beta1 /projects/create}
87+ * @resource [projects: create API Documentation]{@link https://cloud.google.com/resource-manager/reference/rest/v1 /projects/create}
8888 *
89- * @param {string } name - Name of the project.
89+ * @param {string } id - ID of the project.
9090 * @param {object= } options - See a
91- * [Project resource](https://cloud.google.com/resource-manager/reference/rest/v1beta1 /projects#Project).
91+ * [Project resource](https://cloud.google.com/resource-manager/reference/rest/v1 /projects#Project).
9292 * @param {function= } callback - The callback function.
9393 * @param {?error } callback.err - An error returned while making this request.
9494 * @param {module:resource/project } callback.project - The created Project
9595 * object.
9696 * @param {object } callback.apiResponse - The full API response.
9797 *
9898 * @example
99- * resource.createProject('new project name', function(err, project) {
100- * if (!err) {
101- * // `project` is a new Project instance.
99+ * var id = 'new-project-id';
100+ *
101+ * resource.createProject(id, function(err, project, operation, apiResponse) {
102+ * if (err) {
103+ * // Error handling omitted.
102104 * }
105+ *
106+ * // `project` is a new Project instance.
107+ * // `operation` will emit `error` or `complete` when the status updates.
108+ *
109+ * operation
110+ * .on('error', function(err) {})
111+ * .on('complete', function() {
112+ * // Project was created successfully!
113+ * });
103114 * });
104115 *
105116 * //-
106117 * // If the callback is omitted, we'll return a Promise.
107118 * //-
108- * resource.createProject('new project name').then(function(data) {
109- * var project = data[0];
110- * var apiResponse = data[1];
111- * });
119+ * resource.createProject(id)
120+ * .then(function(data) {
121+ * var project = data[0];
122+ * var operation = data[1];
123+ * var apiResponse = data[2];
124+ *
125+ * return operation.promise();
126+ * })
127+ * .then(function(data) {
128+ * var operationMetadata = data[0];
129+ *
130+ * // Project created successfully!
131+ * });
112132 */
113133Resource . prototype . createProject = function ( id , options , callback ) {
114134 var self = this ;
@@ -131,17 +151,19 @@ Resource.prototype.createProject = function(id, options, callback) {
131151 }
132152
133153 var project = self . project ( resp . projectId ) ;
134- project . metadata = resp ;
135154
136- callback ( null , project , resp ) ;
155+ var operation = self . operation ( resp . name ) ;
156+ operation . metadata = resp ;
157+
158+ callback ( null , project , operation , resp ) ;
137159 } ) ;
138160} ;
139161
140162/**
141163 * Get a list of projects.
142164 *
143- * @resource [Projects Overview]{@link https://cloud.google.com/resource-manager/reference/rest/v1beta1 /projects}
144- * @resource [projects: list API Documentation]{@link https://cloud.google.com/resource-manager/reference/rest/v1beta1 /projects/list}
165+ * @resource [Projects Overview]{@link https://cloud.google.com/resource-manager/reference/rest/v1 /projects}
166+ * @resource [projects: list API Documentation]{@link https://cloud.google.com/resource-manager/reference/rest/v1 /projects/list}
145167 *
146168 * @param {object= } options - Operation search options.
147169 * @param {boolean } options.autoPaginate - Have pagination handled
@@ -251,6 +273,31 @@ Resource.prototype.getProjects = function(options, callback) {
251273Resource . prototype . getProjectsStream =
252274 common . paginator . streamify ( 'getProjects' ) ;
253275
276+ /*! Developer Documentation
277+ *
278+ * @returns {module:common/operation }
279+ */
280+ /**
281+ * Get a reference to an existing operation.
282+ *
283+ * @throws {Error } If a name is not provided.
284+ *
285+ * @param {string } name - The name of the operation.
286+ *
287+ * @example
288+ * var operation = resource.operation('68850831366825');
289+ */
290+ Resource . prototype . operation = function ( name ) {
291+ if ( ! name ) {
292+ throw new Error ( 'A name must be specified for an operation.' ) ;
293+ }
294+
295+ return new common . Operation ( {
296+ parent : this ,
297+ id : name
298+ } ) ;
299+ } ;
300+
254301/**
255302 * Create a Project object. See {module:resoucemanager/createProject} to create
256303 * a project.
@@ -285,7 +332,10 @@ common.paginator.extend(Resource, ['getProjects']);
285332 * that a callback is omitted.
286333 */
287334common . util . promisifyAll ( Resource , {
288- exclude : [ 'project' ]
335+ exclude : [
336+ 'operation' ,
337+ 'project'
338+ ]
289339} ) ;
290340
291341Resource . Project = Project ;
0 commit comments