2121'use strict' ;
2222
2323var arrify = require ( 'arrify' ) ;
24+ var common = require ( '@google-cloud/common' ) ;
2425var is = require ( 'is' ) ;
2526var util = require ( 'util' ) ;
2627
@@ -107,6 +108,14 @@ function Acl(options) {
107108 * entity: 'user-email@example .com',
108109 * role: gcs.acl.OWNER_ROLE
109110 * }, function(err, aclObject) {});
111+ *
112+ * //-
113+ * // If the callback is omitted, we'll return a Promise.
114+ * //-
115+ * myFile.acl.owners.addUser('[email protected] ').then(function(data) { 116+ * var aclObject = data[0];
117+ * var apiResponse = data[1];
118+ * });
110119 */
111120Acl . prototype . owners = { } ;
112121
@@ -144,6 +153,14 @@ Acl.prototype.owners = {};
144153 * entity: 'user-email@example .com',
145154 * role: gcs.acl.READER_ROLE
146155 * }, function(err, aclObject) {});
156+ *
157+ * //-
158+ * // If the callback is omitted, we'll return a Promise.
159+ * //-
160+ * myFile.acl.readers.addUser('[email protected] ').then(function(data) { 161+ * var aclObject = data[0];
162+ * var apiResponse = data[1];
163+ * });
147164 */
148165Acl . prototype . readers = { } ;
149166
@@ -181,6 +198,14 @@ Acl.prototype.readers = {};
181198 * entity: 'user-email@example .com',
182199 * role: gcs.acl.WRITER_ROLE
183200 * }, function(err, aclObject) {});
201+ *
202+ * //-
203+ * // If the callback is omitted, we'll return a Promise.
204+ * //-
205+ * myFile.acl.writers.addUser('[email protected] ').then(function(data) { 206+ * var aclObject = data[0];
207+ * var apiResponse = data[1];
208+ * });
184209 */
185210Acl . prototype . writers = { } ;
186211
@@ -204,10 +229,12 @@ util.inherits(Acl, AclRoleAccessorMethods);
204229 * @param {object } callback.apiResponse - The full API response.
205230 *
206231 * @example
207- * myBucket.acl.add( {
232+ * var options = {
208233 * entity: 'user-useremail@example .com',
209234 * role: gcs.acl.OWNER_ROLE
210- * }, function(err, aclObject, apiResponse) {});
235+ * };
236+ *
237+ * myBucket.acl.add(options, function(err, aclObject, apiResponse) {});
211238 *
212239 * //-
213240 * // For file ACL operations, you can also specify a `generation` property.
@@ -219,6 +246,14 @@ util.inherits(Acl, AclRoleAccessorMethods);
219246 * role: gcs.acl.OWNER_ROLE,
220247 * generation: 1
221248 * }, function(err, aclObject, apiResponse) {});
249+ *
250+ * //-
251+ * // If the callback is omitted, we'll return a Promise.
252+ * //-
253+ * myBucket.acl.add(options).then(function(data) {
254+ * var aclObject = data[0];
255+ * var apiResponse = data[1];
256+ * });
222257 */
223258Acl . prototype . add = function ( options , callback ) {
224259 var self = this ;
@@ -273,6 +308,13 @@ Acl.prototype.add = function(options, callback) {
273308 * entity: 'user-useremail@example .com',
274309 * generation: 1
275310 * }, function(err, apiResponse) {});
311+ *
312+ * //-
313+ * // If the callback is omitted, we'll return a Promise.
314+ * //-
315+ * myFile.acl.delete().then(function(data) {
316+ * var apiResponse = data[0];
317+ * });
276318 */
277319Acl . prototype . delete = function ( options , callback ) {
278320 var query = { } ;
@@ -333,6 +375,14 @@ Acl.prototype.delete = function(options, callback) {
333375 * entity: 'user-useremail@example .com',
334376 * generation: 1
335377 * }, function(err, aclObject, apiResponse) {});
378+ *
379+ * //-
380+ * // If the callback is omitted, we'll return a Promise.
381+ * //-
382+ * myBucket.acl.get().then(function(data) {
383+ * var aclObject = data[0];
384+ * var apiResponse = data[1];
385+ * });
336386 */
337387Acl . prototype . get = function ( options , callback ) {
338388 var self = this ;
@@ -389,10 +439,12 @@ Acl.prototype.get = function(options, callback) {
389439 * @param {object } callback.apiResponse - The full API response.
390440 *
391441 * @example
392- * myBucket.acl.update( {
442+ * var options = {
393443 * entity: 'user-useremail@example .com',
394444 * role: gcs.acl.WRITER_ROLE
395- * }, function(err, aclObject, apiResponse) {});
445+ * };
446+ *
447+ * myBucket.acl.update(options, function(err, aclObject, apiResponse) {});
396448 *
397449 * //-
398450 * // For file ACL operations, you can also specify a `generation` property.
@@ -402,6 +454,14 @@ Acl.prototype.get = function(options, callback) {
402454 * role: gcs.acl.WRITER_ROLE,
403455 * generation: 1
404456 * }, function(err, aclObject, apiResponse) {});
457+ *
458+ * //-
459+ * // If the callback is omitted, we'll return a Promise.
460+ * //-
461+ * myFile.acl.update(options).then(function(data) {
462+ * var aclObject = data[0];
463+ * var apiResponse = data[1];
464+ * });
405465 */
406466Acl . prototype . update = function ( options , callback ) {
407467 var self = this ;
@@ -463,6 +523,13 @@ Acl.prototype.request = function(reqOpts, callback) {
463523 this . request_ ( reqOpts , callback ) ;
464524} ;
465525
526+ /*! Developer Documentation
527+ *
528+ * All async methods (except for streams) will return a Promise in the event
529+ * that a callback is omitted.
530+ */
531+ common . util . promisifyAll ( Acl ) ;
532+
466533module . exports = Acl ;
467534
468535/**
@@ -539,7 +606,7 @@ AclRoleAccessorMethods.prototype._assignAccessMethods = function(role) {
539606 callback = entityId ;
540607 }
541608
542- self [ accessMethod ] ( {
609+ return self [ accessMethod ] ( {
543610 entity : apiEntity ,
544611 role : role
545612 } , callback ) ;
0 commit comments