Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Catch all for read-modify-write cycle
// https://cloud.google.com/bigquery/docs/api-performance#read-patch-write
this.interceptors.push({
request: function(reqOpts) {
if (reqOpts.method === 'PATCH' && reqOpts.json.etag) {
reqOpts.headers = reqOpts.headers || {};
reqOpts.headers['If-Match'] = reqOpts.json.etag;
}
return reqOpts;
}
});
}
util.inherits(Table, common.ServiceObject);
/**
* Convert a comma-separated name:type string to a table schema object.
*
* @static
* @private
*
* @param {string} str - Comma-separated schema string.
* @return {object} Table schema in the format the API expects.
*/
Table.createSchemaFromString_ = function(str) {
return str.split(/\s*,\s*/).reduce(function(acc, pair) {
acc.fields.push({
name: pair.split(':')[0],
type: (pair.split(':')[1] || 'STRING').toUpperCase()
});
* don't have to individually control each instance in your project.
*
* @see [Creating Groups of Instances]{@link https://cloud.google.com/compute/docs/instance-groups}
* @see [Unmanaged Instance Groups]{@link https://cloud.google.com/compute/docs/instance-groups/creating-groups-of-unmanaged-instances}
*
* @class
* @param {Zone} zone
* @param {string} name
*
* @example
* const Compute = require('@google-cloud/compute');
* const compute = new Compute();
* const zone = compute.zone('us-central1-a');
* const instanceGroup = zone.instanceGroup('web-servers');
*/
class InstanceGroup extends common.ServiceObject {
constructor(zone, name) {
const methods = {
/**
* Create an instance group.
*
* @method InstanceGroup#create
* @param {object=} options - See {@link Zone#createInstanceGroup}.
*
* @example
* const Compute = require('@google-cloud/compute');
* const compute = new Compute();
* const zone = compute.zone('us-central1-a');
* const instanceGroup = zone.instanceGroup('web-servers');
*
* function onCreated(err, instanceGroup, operation, apiResponse) {
* // `instanceGroup` is an InstanceGroup object.
*/
/*!
* @module compute/rule
*/
'use strict';
var common = require('@google-cloud/common');
var nodeutil = require('util');
/**
* @type {module:common/service-object}
* @private
*/
var ServiceObject = common.ServiceObject;
/**
* @type {module:common/util}
* @private
*/
var util = common.util;
/*! Developer Documentation
*
* @param {module:compute|module:compute/region} scope - The parent scope this
* firewall rule belongs to.
* @param {string} name - Rule name.
*/
/**
* Forwarding rules work in conjunction with target pools and target instances
* to support load balancing and protocol forwarding features. To use load
/**
* An Image object allows you to interact with a Google Compute Engine image.
*
* @see [Images Overview]{@link https://cloud.google.com/compute/docs/images}
* @see [Image Resource]{@link https://cloud.google.com/compute/docs/reference/v1/images}
*
* @class
* @param {Compute} compute - The parent Compute instance this Image belongs to.
* @param {string} name - Image name.
*
* @example
* const Compute = require('@google-cloud/compute');
* const compute = new Compute();
* const image = compute.image('image-name');
*/
class Image extends common.ServiceObject {
constructor(compute, name) {
const methods = {
/**
* Create an image.
*
* @method Image#create
* @param {Disk} disk - See {@link Compute#createImage}.
* @param {object} [options] - See {@link Compute#createImage}.
*
* @example
* const Compute = require('@google-cloud/compute');
* const compute = new Compute();
* const zone = compute.zone('us-central1-a');
* const disk = zone.disk('disk1');
* const image = compute.image('image-name');
*
import {Common} from '../types/common';
export const common: Common = require('@google-cloud/common');
import * as assert from 'assert';
import * as http from 'http';
import * as qs from 'querystring';
import {Debug} from '../client/stackdriver/debug';
import {Debuggee} from '../debuggee';
import * as stackdriver from '../types/stackdriver';
/** @const {string} Cloud Debug API endpoint */
const API = 'https://clouddebugger.googleapis.com/v2/controller';
export class Controller extends common.ServiceObject {
private nextWaitToken: string|null;
/**
* @constructor
*/
constructor(debug: Debug) {
super({parent: debug, baseUrl: '/controller'});
/** @private {string} */
this.nextWaitToken = null;
}
/**
* Register to the API (implementation)
*
* @param {!function(?Error,Object=)} callback
/**
* Create a Bucket object to interact with a Cloud Storage bucket.
*
* @class
* @hideconstructor
*
* @param {Storage} storage A {@link Storage} instance.
* @param {string} name The name of the bucket.
* @param {object} [options] Configuration object.
* @param {string} [options.userProject] User project.
*
* @example
* const storage = require('@google-cloud/storage')();
* const bucket = storage.bucket('albums');
*/
class Bucket extends common.ServiceObject {
constructor(storage, name, options) {
options = options || {};
name = name.replace(/^gs:\/\//, '');
const methods = {
/**
* Create a bucket.
*
* @method Bucket#create
* @param {CreateBucketRequest} [metadata] Metadata to set for the bucket.
* @param {CreateBucketCallback} [callback] Callback function.
* @returns {Promise}
*
* @example
* const storage = require('@google-cloud/storage')();
*/
/*!
* @module dns/change
*/
'use strict';
var common = require('@google-cloud/common');
var nodeutil = require('util');
/**
* @type {module:common/service-object}
* @private
*/
var ServiceObject = common.ServiceObject;
/**
* @constructor
* @alias module:dns/change
*
* @param {module:dns/zone} zone - The parent zone object.
* @param {string} id - ID of the change.
*
* @example
* var gcloud = require('google-cloud');
*
* var dns = gcloud.dns({
* keyFilename: '/path/to/keyfile.json',
* projectId: 'grape-spaceship-123'
* });
*
* @type {module:compute/operation}
* @private
*/
var Operation = require('./operation.js');
/**
* @type {module:compute/rule}
* @private
*/
var Rule = require('./rule.js');
/**
* @type {module:common/service-object}
* @private
*/
var ServiceObject = common.ServiceObject;
/**
* @type {module:compute/subnetwork}
* @private
*/
var Subnetwork = require('./subnetwork.js');
/**
* @type {module:common/stream-router}
* @private
*/
var streamRouter = common.streamRouter;
/*! Developer Documentation
*
* @param {module:compute} compute - Compute object this region belongs to.
request(reqOpts, callback) {
const zone = this.zone;
const request = common.ServiceObject.prototype.request;
request.call(this, reqOpts, function(err, resp) {
if (err) {
callback(err, null, resp);
return;
}
const operation = zone.operation(resp.name);
operation.metadata = resp;
callback(null, operation, resp);
});
}
}
common.ServiceObject.call(this, {
parent: compute,
baseUrl: '/zones',
id: name,
methods: methods
});
this.compute = compute;
this.name = name;
this.gceImages = gceImages({
authClient: compute.authClient
});
}
util.inherits(Zone, common.ServiceObject);
/**
* Get a reference to a Google Compute Engine autoscaler in this zone.
*
* @param {string} name - Name of the autoscaler.
* @return {module:compute/autoscaler}
*
* @example
* var autoscaler = zone.autoscaler('autoscaler-name');
*/
Zone.prototype.autoscaler = function(name) {
return new Autoscaler(this, name);
};
/**
* Create an autoscaler in this zone.