Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.getMetadata(function(err, metadata, apiResponse) {
// Parsing the response body will automatically create an ApiError object if
// the operation failed.
const parsedHttpRespBody = common.util.parseHttpRespBody(apiResponse);
err = err || parsedHttpRespBody.err;
if (err) {
callback(err);
return;
}
if (metadata.status === 'RUNNING' && !self.status) {
self.status = metadata.status;
self.emit('running', metadata);
}
if (metadata.status !== 'DONE') {
callback();
return;
}
self.status = metadata.status;
callback(null, metadata);
});
.on('response', res => {
throughStream.emit('response', res);
common.util.handleResp(null, res, null, onResponse);
})
.resume();
Operation.prototype.cancel = function(callback) {
var protoOpts = {
service: 'Operations',
method: 'cancelOperation',
};
var reqOpts = {
name: this.id,
};
this.request(protoOpts, reqOpts, callback || common.util.noop);
};
});
}
}
/*! Developer Documentation
*
* These methods can be auto-paginated.
*/
common.paginator.extend(Bucket, 'getFiles');
/*! Developer Documentation
*
* All async methods (except for streams) will return a Promise in the event
* that a callback is omitted.
*/
common.util.promisifyAll(Bucket, {
exclude: ['request', 'file', 'notification'],
});
/**
* Reference to the {@link Bucket} class.
* @name module:@google-cloud/storage.Bucket
* @see Bucket
*/
module.exports = Bucket;
return;
}
var operation = zone.operation(resp.name);
operation.metadata = resp;
callback(null, operation, resp);
});
};
/*! Developer Documentation
*
* All async methods (except for streams) will return a Promise in the event
* that a callback is omitted.
*/
common.util.promisifyAll(VM);
module.exports = VM;
function Datastore(options) {
if (!(this instanceof Datastore)) {
options = common.util.normalizeArguments(this, options, {
projectIdRequired: false
});
return new Datastore(options);
}
this.defaultBaseUrl_ = 'datastore.googleapis.com';
this.determineBaseUrl_(options.apiEndpoint);
this.namespace = options.namespace;
this.projectId = process.env.DATASTORE_PROJECT_ID || options.projectId;
var config = {
projectIdRequired: false,
baseUrl: this.baseUrl_,
customEndpoint: this.customEndpoint_,
protosDir: path.resolve(__dirname, '../protos'),
function Storage(options) {
if (!(this instanceof Storage)) {
options = common.util.normalizeArguments(this, options);
return new Storage(options);
}
var config = {
baseUrl: 'https://www.googleapis.com./storage/v1',
projectIdRequired: false,
scopes: [
'https://www.googleapis.com/auth/devstorage.full_control'
],
packageJson: require('../package.json')
};
common.Service.call(this, config, options);
}
this.createJob(reqOpts, callback);
};
/*! Developer Documentation
*
* These methods can be auto-paginated.
*/
common.paginator.extend(BigQuery, ['getDatasets', 'getJobs']);
/*! Developer Documentation
*
* All async methods (except for streams) will return a Promise in the event
* that a callback is omitted.
*/
common.util.promisifyAll(BigQuery, {
exclude: [
'dataset',
'date',
'datetime',
'job',
'time',
'timestamp'
]
});
BigQuery.Dataset = Dataset;
BigQuery.Job = Job;
BigQuery.Table = Table;
module.exports = BigQuery;
Subscription.prototype.modifyAckDeadline_ = function(ackIds, deadline, connId) {
var self = this;
var promise;
ackIds = arrify(ackIds);
if (!this.isConnected_()) {
promise = common.util.promisify(this.request).call(this, {
client: 'subscriberClient',
method: 'modifyAckDeadline',
reqOpts: {
subscription: self.name,
ackDeadlineSeconds: deadline,
ackIds
}
});
} else {
promise = new Promise(function(resolve, reject) {
self.connectionPool.acquire(connId, function(err, connection) {
if (err) {
reject(err);
return;
}
/*!
* @module commonGrpc/service
*/
'use strict';
var dotProp = require('dot-prop');
var duplexify = require('duplexify');
var extend = require('extend');
var grpc = require('grpc');
var is = require('is');
var nodeutil = require('util');
var retryRequest = require('retry-request');
var Service = require('@google-cloud/common').Service;
var through = require('through2');
var util = require('@google-cloud/common').util;
/**
* @const {object} - A map of protobuf codes to HTTP status codes.
* @private
*/
var GRPC_ERROR_CODE_TO_HTTP = {
0: {
code: 200,
message: 'OK'
},
1: {
code: 499,
message: 'Client Closed Request'
},