Files

Return to Package Diff Home.
Brought to you by Intrinsic.

Package Diff: google-gax @ 0.25.6 .. 0.26.0

build/src/apiCallable.d.ts

@@ -1,119 +0,0 @@
-import { CallSettings } from './gax';
-import { GoogleError } from './GoogleError';
-export interface ArgumentFunction {
- (argument: {}, callback: APICallback): void;
-}
-/**
- * @callback APICallback
- * @param {?Error} error
- * @param {?Object} response
- */
-export declare type APICallback = (err: GoogleError | null, response?: any, next?: {} | null, rawResponse?: {} | null) => void;
-/**
- * @callback APIFunc
- * @param {Object} argument
- * @param {grpc.Metadata} metadata
- * @param {Object} options
- * @param {APICallback} callback
- */
-export declare type APIFunc = (argument: {}, metadata: {}, options: {}, callback: APICallback) => Canceller;
-/**
- * @callback APICall
- * @param {Object} argument
- * @param {CallOptions} callOptions
- * @param {APICallback} callback
- * @return {Promise|Stream|undefined}
- */
-export interface APICall {
- (argument?: {} | null, callOptions?: {} | null, callback?: APICallback): any;
-}
-export declare class Canceller {
- callback?: APICallback;
- cancelFunc?: () => void;
- completed: boolean;
- /**
- * Canceller manages callback, API calls, and cancellation
- * of the API calls.
- * @param {APICallback=} callback
- * The callback to be called asynchronously when the API call
- * finishes.
- * @constructor
- * @property {APICallback} callback
- * The callback function to be called.
- * @private
- */
- constructor(callback?: APICallback);
- /**
- * Cancels the ongoing promise.
- */
- cancel(): void;
- /**
- * Call calls the specified function. Result will be used to fulfill
- * the promise.
- *
- * @param {function(Object, APICallback=)} aFunc
- * A function for an API call.
- * @param {Object} argument
- * A request object.
- */
- call(aFunc: (obj: {}, callback: APICallback) => PromiseCanceller, argument: {}): void;
-}
-export interface CancellablePromise<T = any> extends Promise<T> {
- cancel(): void;
-}
-export declare class PromiseCanceller<T = any> extends Canceller {
- promise: CancellablePromise<T>;
- /**
- * PromiseCanceller is Canceller, but it holds a promise when
- * the API call finishes.
- * @param {Function} PromiseCtor - A constructor for a promise that implements
- * the ES6 specification of promise.
- * @constructor
- * @private
- */
- constructor(PromiseCtor: PromiseConstructor);
-}
-export interface ApiCallOtherArgs {
- options?: {
- deadline?: Date;
- };
- headers?: {};
- metadataBuilder: (abTests?: {}, headers?: {}) => {};
-}
-export interface NormalApiCallerSettings {
- promise: PromiseConstructor;
-}
-/**
- * Creates an API caller for normal methods.
- *
- * @private
- * @constructor
- */
-export declare class NormalApiCaller {
- init(settings: NormalApiCallerSettings, callback: APICallback): PromiseCanceller | Canceller;
- wrap(func: Function): Function;
- call(apiCall: APICall, argument: {}, settings: {}, canceller: PromiseCanceller): void;
- fail(canceller: PromiseCanceller, err: GoogleError): void;
- result(canceller: PromiseCanceller): CancellablePromise<any> | undefined;
-}
-/**
- * Converts an rpc call into an API call governed by the settings.
- *
- * In typical usage, `func` will be a promsie to a callable used to make an rpc
- * request. This will mostly likely be a bound method from a request stub used
- * to make an rpc call. It is not a direct function but a Promise instance,
- * because of its asynchronism (typically, obtaining the auth information).
- *
- * The result is a function which manages the API call with the given settings
- * and the options on the invocation.
- *
- * @param {Promise.<APIFunc>} funcWithAuth - is a promise to be used to make
- * a bare rpc call. This is a Promise instead of a bare function because
- * the rpc call will be involeved with asynchronous authentications.
- * @param {CallSettings} settings - provides the settings for this call
- * @param {Object=} optDescriptor - optionally specify the descriptor for
- * the method call.
- * @return {APICall} func - a bound method on a request stub used
- * to make an rpc call.
- */
-export declare function createApiCall(funcWithAuth: Promise<APIFunc>, settings: CallSettings, optDescriptor?: any): APICall;

build/src/apiCallable.js

@@ -1,332 +0,0 @@
-"use strict";
-/*
- * Copyright 2016, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-Object.defineProperty(exports, "__esModule", { value: true });
-/**
- * Provides function wrappers that implement page streaming and retrying.
- */
-const grpc_1 = require("grpc");
-const GoogleError_1 = require("./GoogleError");
-class Canceller {
- /**
- * Canceller manages callback, API calls, and cancellation
- * of the API calls.
- * @param {APICallback=} callback
- * The callback to be called asynchronously when the API call
- * finishes.
- * @constructor
- * @property {APICallback} callback
- * The callback function to be called.
- * @private
- */
- constructor(callback) {
- this.callback = callback;
- this.completed = false;
- }
- /**
- * Cancels the ongoing promise.
- */
- cancel() {
- if (this.completed) {
- return;
- }
- this.completed = true;
- if (this.cancelFunc) {
- this.cancelFunc();
- }
- else {
- const error = new GoogleError_1.GoogleError('cancelled');
- error.code = grpc_1.status.CANCELLED;
- this.callback(error);
- }
- }
- /**
- * Call calls the specified function. Result will be used to fulfill
- * the promise.
- *
- * @param {function(Object, APICallback=)} aFunc
- * A function for an API call.
- * @param {Object} argument
- * A request object.
- */
- call(aFunc, argument) {
- if (this.completed) {
- return;
- }
- // tslint:disable-next-line no-any
- const canceller = aFunc(argument, (...args) => {
- this.completed = true;
- setImmediate(this.callback, ...args);
- });
- this.cancelFunc = () => canceller.cancel();
- }
-}
-exports.Canceller = Canceller;
-// tslint:disable-next-line no-any
-class PromiseCanceller extends Canceller {
- /**
- * PromiseCanceller is Canceller, but it holds a promise when
- * the API call finishes.
- * @param {Function} PromiseCtor - A constructor for a promise that implements
- * the ES6 specification of promise.
- * @constructor
- * @private
- */
- // tslint:disable-next-line variable-name
- constructor(PromiseCtor) {
- super();
- this.promise = new PromiseCtor((resolve, reject) => {
- this.callback = (err, response, next, rawResponse) => {
- if (err) {
- reject(err);
- }
- else {
- resolve([response, next, rawResponse]);
- }
- };
- });
- this.promise.cancel = () => {
- this.cancel();
- };
- }
-}
-exports.PromiseCanceller = PromiseCanceller;
-/**
- * Updates aFunc so that it gets called with the timeout as its final arg.
- *
- * This converts a function, aFunc, into another function with updated deadline.
- *
- * @private
- *
- * @param {APIFunc} aFunc - a function to be updated.
- * @param {number} timeout - to be added to the original function as it final
- * positional arg.
- * @param {Object} otherArgs - the additional arguments to be passed to aFunc.
- * @param {Object=} abTests - the A/B testing key/value pairs.
- * @return {function(Object, APICallback)}
- * the function with other arguments and the timeout.
- */
-function addTimeoutArg(aFunc, timeout, otherArgs, abTests) {
- // TODO: this assumes the other arguments consist of metadata and options,
- // which is specific to gRPC calls. Remove the hidden dependency on gRPC.
- return function timeoutFunc(argument, callback) {
- const now = new Date();
- const options = otherArgs.options || {};
- options.deadline = new Date(now.getTime() + timeout);
- const metadata = otherArgs.metadataBuilder ?
- otherArgs.metadataBuilder(abTests, otherArgs.headers || {}) :
- null;
- return aFunc(argument, metadata, options, callback);
- };
-}
-/**
- * Creates a function equivalent to aFunc, but that retries on certain
- * exceptions.
- *
- * @private
- *
- * @param {APIFunc} aFunc - A function.
- * @param {RetryOptions} retry - Configures the exceptions upon which the
- * function eshould retry, and the parameters to the exponential backoff retry
- * algorithm.
- * @param {Object} otherArgs - the additional arguments to be passed to aFunc.
- * @return {function(Object, APICallback)} A function that will retry.
- */
-function retryable(aFunc, retry, otherArgs) {
- const delayMult = retry.backoffSettings.retryDelayMultiplier;
- const maxDelay = retry.backoffSettings.maxRetryDelayMillis;
- const timeoutMult = retry.backoffSettings.rpcTimeoutMultiplier;
- const maxTimeout = retry.backoffSettings.maxRpcTimeoutMillis;
- let delay = retry.backoffSettings.initialRetryDelayMillis;
- let timeout = retry.backoffSettings.initialRpcTimeoutMillis;
- /**
- * Equivalent to ``aFunc``, but retries upon transient failure.
- *
- * Retrying is done through an exponential backoff algorithm configured
- * by the options in ``retry``.
- * @param {Object} argument The request object.
- * @param {APICallback} callback The callback.
- * @return {function()} cancel function.
- */
- return function retryingFunc(argument, callback) {
- let canceller;
- let timeoutId;
- let now = new Date();
- let deadline;
- if (retry.backoffSettings.totalTimeoutMillis) {
- deadline = now.getTime() + retry.backoffSettings.totalTimeoutMillis;
- }
- let retries = 0;
- const maxRetries = retry.backoffSettings.maxRetries;
- // TODO: define A/B testing values for retry behaviors.
- /** Repeat the API call as long as necessary. */
- function repeat() {
- timeoutId = null;
- if (deadline && now.getTime() >= deadline) {
- const error = new GoogleError_1.GoogleError('Retry total timeout exceeded before any response was received');
- error.code = grpc_1.status.DEADLINE_EXCEEDED;
- callback(error);
- return;
- }
- if (retries && retries >= maxRetries) {
- const error = new GoogleError_1.GoogleError('Exceeded maximum number of retries before any ' +
- 'response was received');
- error.code = grpc_1.status.DEADLINE_EXCEEDED;
- callback(error);
- return;
- }
- retries++;
- const toCall = addTimeoutArg(aFunc, timeout, otherArgs);
- canceller = toCall(argument, (err, response, next, rawResponse) => {
- if (!err) {
- callback(null, response, next, rawResponse);
- return;
- }
- canceller = null;
- if (retry.retryCodes.indexOf(err.code) < 0) {
- err.note = 'Exception occurred in retry method that was ' +
- 'not classified as transient';
- callback(err);
- }
- else {
- const toSleep = Math.random() * delay;
- timeoutId = setTimeout(() => {
- now = new Date();
- delay = Math.min(delay * delayMult, maxDelay);
- timeout = Math.min(timeout * timeoutMult, maxTimeout, deadline - now.getTime());
- repeat();
- }, toSleep);
- }
- });
- }
- if (maxRetries && deadline) {
- const error = new GoogleError_1.GoogleError('Cannot set both totalTimeoutMillis and maxRetries ' +
- 'in backoffSettings.');
- error.code = grpc_1.status.INVALID_ARGUMENT;
- callback(error);
- }
- else {
- repeat();
- }
- return {
- cancel() {
- if (timeoutId) {
- clearTimeout(timeoutId);
- }
- if (canceller) {
- canceller.cancel();
- }
- else {
- const error = new GoogleError_1.GoogleError('cancelled');
- error.code = grpc_1.status.CANCELLED;
- callback(error);
- }
- },
- };
- };
-}
-/**
- * Creates an API caller for normal methods.
- *
- * @private
- * @constructor
- */
-class NormalApiCaller {
- init(settings, callback) {
- if (callback) {
- return new Canceller(callback);
- }
- return new PromiseCanceller(settings.promise);
- }
- wrap(func) {
- return func;
- }
- call(apiCall, argument, settings, canceller) {
- canceller.call(apiCall, argument);
- }
- fail(canceller, err) {
- canceller.callback(err);
- }
- result(canceller) {
- if (canceller.promise) {
- return canceller.promise;
- }
- return;
- }
-}
-exports.NormalApiCaller = NormalApiCaller;
-/**
- * Converts an rpc call into an API call governed by the settings.
- *
- * In typical usage, `func` will be a promsie to a callable used to make an rpc
- * request. This will mostly likely be a bound method from a request stub used
- * to make an rpc call. It is not a direct function but a Promise instance,
- * because of its asynchronism (typically, obtaining the auth information).
- *
- * The result is a function which manages the API call with the given settings
- * and the options on the invocation.
- *
- * @param {Promise.<APIFunc>} funcWithAuth - is a promise to be used to make
- * a bare rpc call. This is a Promise instead of a bare function because
- * the rpc call will be involeved with asynchronous authentications.
- * @param {CallSettings} settings - provides the settings for this call
- * @param {Object=} optDescriptor - optionally specify the descriptor for
- * the method call.
- * @return {APICall} func - a bound method on a request stub used
- * to make an rpc call.
- */
-function createApiCall(funcWithAuth, settings,
-// tslint:disable-next-line no-any
-optDescriptor) {
- const apiCaller = optDescriptor ? optDescriptor.apiCaller(settings) : new NormalApiCaller();
- return function apiCallInner(request, callOptions, callback) {
- const thisSettings = settings.merge(callOptions);
- const status = apiCaller.init(thisSettings, callback);
- funcWithAuth
- .then(func => {
- func = apiCaller.wrap(func);
- const retry = thisSettings.retry;
- if (retry && retry.retryCodes && retry.retryCodes.length > 0) {
- return retryable(func, thisSettings.retry, thisSettings.otherArgs);
- }
- return addTimeoutArg(func, thisSettings.timeout, thisSettings.otherArgs);
- })
- .then(apiCall => {
- apiCaller.call(apiCall, request, thisSettings, status);
- })
- .catch(err => {
- apiCaller.fail(status, err);
- });
- return apiCaller.result(status);
- };
-}
-exports.createApiCall = createApiCall;
-//# sourceMappingURL=apiCallable.js.map
\ No newline at end of file

build/src/apiCallable.js.map

@@ -1 +0,0 @@
-{"version":3,"file":"apiCallable.js","sourceRoot":"","sources":["../../src/apiCallable.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAEH;;GAEG;AAEH,+BAA4B;AAE5B,+CAA0C;AAuC1C,MAAa,SAAS;IAKpB;;;;;;;;;;OAUG;IACH,YAAY,QAAsB;QAChC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,IAAI,IAAI,CAAC,SAAS,EAAE;YAClB,OAAO;SACR;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,IAAI,CAAC,UAAU,EAAE,CAAC;SACnB;aAAM;YACL,MAAM,KAAK,GAAG,IAAI,yBAAW,CAAC,WAAW,CAAC,CAAC;YAC3C,KAAK,CAAC,IAAI,GAAG,aAAM,CAAC,SAAS,CAAC;YAC9B,IAAI,CAAC,QAAS,CAAC,KAAK,CAAC,CAAC;SACvB;IACH,CAAC;IAGD;;;;;;;;OAQG;IACH,IAAI,CACA,KAA2D,EAC3D,QAAY;QACd,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AAG,CAAC,EAAE;gBAC5D,OAAO,SAAS,CACZ,IAAI,EAAE,YAAY,CAAC,KAAM,EACzB,YAAY,CAAC,SAA6B,CAAC,CAAC;aACjD;YACD,OAAO,aAAa,CAChB,IAAI,EAAE,YAAY,CAAC,OAAO,EAC1B,YAAY,CAAC,SAA6B,CAAC,CAAC;QAClD,CAAC,CAAC;aACD,IAAI,CAAC,OAAO,CAAC,EAAE;YACd,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;QACzD,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,CAAC,EAAE;YACX,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC;QACP,OAAO,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC,CAAC;AACJ,CAAC;AAhCD,sCAgCC"}
\ No newline at end of file

build/src/apiCaller.d.ts

@@ -0,0 +1,21 @@
+import { APICallback, CancellableStream, GRPCCall, ResultTuple, SimpleCallbackFunction } from './apitypes';
+import { CancellablePromise, OngoingCall, OngoingCallPromise } from './call';
+import { Descriptor } from './descriptor';
+import { CallSettings } from './gax';
+import { GoogleError } from './googleError';
+import { StreamProxy } from './streamingCalls/streaming';
+export interface ApiCallerSettings {
+ promise: PromiseConstructor;
+}
+/**
+ * An interface for all kinds of API callers (normal, that just calls API, and
+ * all special ones: long-running, paginated, bundled, streaming).
+ */
+export interface APICaller {
+ init(settings: ApiCallerSettings, callback?: APICallback): OngoingCallPromise | OngoingCall | StreamProxy;
+ wrap(func: GRPCCall): GRPCCall;
+ call(apiCall: SimpleCallbackFunction, argument: {}, settings: {}, canceller: OngoingCallPromise | OngoingCall | StreamProxy): void;
+ fail(canceller: OngoingCallPromise | OngoingCall | CancellableStream, err: GoogleError): void;
+ result(canceller: OngoingCallPromise | OngoingCall | CancellableStream): CancellablePromise<ResultTuple> | CancellableStream;
+}
+export declare function createAPICaller(settings: CallSettings, descriptor: Descriptor | undefined): APICaller;

build/src/apiCaller.js

@@ -0,0 +1,41 @@
+"use strict";
+/*
+ * Copyright 2019, Google LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+const normalApiCaller_1 = require("./normalCalls/normalApiCaller");
+function createAPICaller(settings, descriptor) {
+ if (!descriptor) {
+ return new normalApiCaller_1.NormalApiCaller();
+ }
+ return descriptor.getApiCaller(settings);
+}
+exports.createAPICaller = createAPICaller;
+//# sourceMappingURL=apiCaller.js.map
\ No newline at end of file

build/src/apiCaller.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"apiCaller.js","sourceRoot":"","sources":["../../src/apiCaller.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAOH,mEAA8D;AAyB9D,SAAgB,eAAe,CAC3B,QAAsB,EAAE,UAAgC;IAC1D,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,IAAI,iCAAe,EAAE,CAAC;KAC9B;IACD,OAAO,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;AAC3C,CAAC;AAND,0CAMC"}
\ No newline at end of file

build/src/apitypes.d.ts

@@ -0,0 +1,43 @@
+/// <reference types="node" />
+import { Duplex } from 'stream';
+import { CancellablePromise } from './call';
+import { CallOptions } from './gax';
+import { GoogleError } from './googleError';
+import { Operation } from './longRunningCalls/longrunning';
+export interface GRPCCallResult {
+ cancel(): void;
+}
+export declare type RequestType = {};
+export declare type ResponseType = {} | null;
+export declare type NextPageRequestType = {
+ [index: string]: string;
+} | null;
+export declare type RawResponseType = Operation | {};
+export declare type ResultTuple = [ResponseType, NextPageRequestType | undefined, RawResponseType | undefined];
+export interface SimpleCallbackFunction {
+ (argument: RequestType, callback: APICallback): GRPCCallResult;
+}
+export declare type APICallback = (err: GoogleError | null, response?: ResponseType, next?: NextPageRequestType, rawResponse?: RawResponseType) => void;
+export declare type UnaryCall = (argument: {}, metadata: {}, options: {}, callback: APICallback) => GRPCCallResult;
+export declare type ServerStreamingCall = (argument: {}, metadata: {}, options: {}) => Duplex & GRPCCallResult;
+export declare type ClientStreamingCall = (metadata: {}, options: {}, callback?: APICallback) => Duplex & GRPCCallResult;
+export declare type BiDiStreamingCall = (metadata: {}, options: {}) => Duplex & GRPCCallResult;
+export declare type GRPCCall = UnaryCall | ServerStreamingCall | ClientStreamingCall | BiDiStreamingCall;
+export declare type CancellableStream = Duplex & GRPCCallResult;
+export declare type GaxCallResult = CancellablePromise<ResultTuple> | CancellableStream;
+export interface GaxCallPromise {
+ (argument: {}, callOptions?: CallOptions, callback?: APICallback): CancellablePromise<ResultTuple>;
+}
+export interface GaxCallStream {
+ (argument: {}, callOptions?: CallOptions, callback?: APICallback): CancellableStream;
+}
+export interface GaxCall {
+ (argument: {}, callOptions?: CallOptions, callback?: APICallback): GaxCallResult;
+}
+export interface GRPCCallOtherArgs {
+ options?: {
+ deadline?: Date;
+ };
+ headers?: {};
+ metadataBuilder: (abTests?: {}, headers?: {}) => {};
+}

build/src/apitypes.js

@@ -0,0 +1,33 @@
+"use strict";
+/*
+ * Copyright 2019 Google LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+//# sourceMappingURL=apitypes.js.map
\ No newline at end of file

build/src/apitypes.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"apitypes.js","sourceRoot":"","sources":["../../src/apitypes.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG"}
\ No newline at end of file

build/src/bundlingCalls/bundleApiCaller.d.ts

@@ -0,0 +1,21 @@
+import { APICaller, ApiCallerSettings } from '../apiCaller';
+import { APICallback, GRPCCall, SimpleCallbackFunction } from '../apitypes';
+import { OngoingCall, OngoingCallPromise } from '../call';
+import { CallSettings } from '../gax';
+import { GoogleError } from '../googleError';
+import { BundleExecutor } from './bundleExecutor';
+/**
+ * An implementation of APICaller for bundled calls.
+ * Uses BundleExecutor to do bundling.
+ */
+export declare class BundleApiCaller implements APICaller {
+ bundler: BundleExecutor;
+ constructor(bundler: BundleExecutor);
+ init(settings: ApiCallerSettings, callback?: APICallback): OngoingCallPromise | OngoingCall;
+ wrap(func: GRPCCall): GRPCCall;
+ call(apiCall: SimpleCallbackFunction, argument: {}, settings: CallSettings, status: OngoingCallPromise): void;
+ fail(canceller: OngoingCallPromise, err: GoogleError): void;
+ result(canceller: OngoingCallPromise): import("../call").CancellablePromise<[import("../apitypes").ResponseType, {
+ [index: string]: string;
+ } | null | undefined, {} | import("..").Operation | undefined]>;
+}

build/src/bundlingCalls/bundleApiCaller.js

@@ -0,0 +1,69 @@
+"use strict";
+/*
+ * Copyright 2019, Google LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+const call_1 = require("../call");
+const googleError_1 = require("../googleError");
+/**
+ * An implementation of APICaller for bundled calls.
+ * Uses BundleExecutor to do bundling.
+ */
+class BundleApiCaller {
+ constructor(bundler) {
+ this.bundler = bundler;
+ }
+ init(settings, callback) {
+ if (callback) {
+ return new call_1.OngoingCall(callback);
+ }
+ return new call_1.OngoingCallPromise(settings.promise);
+ }
+ wrap(func) {
+ return func;
+ }
+ call(apiCall, argument, settings, status) {
+ if (!settings.isBundling) {
+ throw new googleError_1.GoogleError('Bundling enabled with no isBundling!');
+ }
+ status.call((argument, callback) => {
+ this.bundler.schedule(apiCall, argument, callback);
+ return status;
+ }, argument);
+ }
+ fail(canceller, err) {
+ canceller.callback(err);
+ }
+ result(canceller) {
+ return canceller.promise;
+ }
+}
+exports.BundleApiCaller = BundleApiCaller;
+//# sourceMappingURL=bundleApiCaller.js.map
\ No newline at end of file

build/src/bundlingCalls/bundleApiCaller.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"bundleApiCaller.js","sourceRoot":"","sources":["../../../src/bundlingCalls/bundleApiCaller.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAIH,kCAAwD;AAExD,gDAA2C;AAK3C;;;GAGG;AACH,MAAa,eAAe;IAG1B,YAAY,OAAuB;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,IAAI,CAAC,QAA2B,EAAE,QAAsB;QAEtD,IAAI,QAAQ,EAAE;YACZ,OAAO,IAAI,kBAAW,CAAC,QAAQ,CAAC,CAAC;SAClC;QACD,OAAO,IAAI,yBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;IAED,IAAI,CAAC,IAAc;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CACA,OAA+B,EAAE,QAAY,EAAE,QAAsB,EACrE,MAA0B;QAC5B,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE;YACxB,MAAM,IAAI,yBAAW,CAAC,sCAAsC,CAAC,CAAC;SAC/D;QAED,MAAM,CAAC,IAAI,CAAC,CAAC,QAAY,EAAE,QAAsB,EAAE,EAAE;YACnD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACnD,OAAO,MAAM,CAAC;QAChB,CAAC,EAAE,QAAQ,CAAC,CAAC;IACf,CAAC;IAED,IAAI,CAAC,SAA6B,EAAE,GAAgB;QAClD,SAAS,CAAC,QAAS,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,SAA6B;QAClC,OAAO,SAAS,CAAC,OAAO,CAAC;IAC3B,CAAC;CACF;AAvCD,0CAuCC"}
\ No newline at end of file

build/src/bundlingCalls/bundleDescriptor.d.ts

@@ -0,0 +1,42 @@
+import { Descriptor } from '../descriptor';
+import { CallSettings } from '../gax';
+import { NormalApiCaller } from '../normalCalls/normalApiCaller';
+import { BundleApiCaller } from './bundleApiCaller';
+/**
+ * A descriptor for calls that can be bundled into one call.
+ */
+export declare class BundleDescriptor implements Descriptor {
+ bundledField: string;
+ requestDiscriminatorFields: string[];
+ subresponseField: string | null;
+ byteLengthFunction: Function;
+ /**
+ * Describes the structure of bundled call.
+ *
+ * requestDiscriminatorFields may include '.' as a separator, which is used to
+ * indicate object traversal. This allows fields in nested objects to be used
+ * to determine what request to bundle.
+ *
+ * @property {String} bundledField
+ * @property {String} requestDiscriminatorFields
+ * @property {String} subresponseField
+ * @property {Function} byteLengthFunction
+ *
+ * @param {String} bundledField - the repeated field in the request message
+ * that will have its elements aggregated by bundling.
+ * @param {String} requestDiscriminatorFields - a list of fields in the
+ * target request message class that are used to detemrine which request
+ * messages should be bundled together.
+ * @param {String} subresponseField - an optional field, when present it
+ * indicates the field in the response message that should be used to
+ * demultiplex the response into multiple response messages.
+ * @param {Function} byteLengthFunction - a function to obtain the byte
+ * length to be consumed for the bundled field messages. Because Node.JS
+ * protobuf.js/gRPC uses builtin Objects for the user-visible data and
+ * internally they are encoded/decoded in protobuf manner, this function
+ * is actually necessary to calculate the byte length.
+ * @constructor
+ */
+ constructor(bundledField: string, requestDiscriminatorFields: string[], subresponseField: string | null, byteLengthFunction: Function);
+ getApiCaller(settings: CallSettings): NormalApiCaller | BundleApiCaller;
+}

build/src/bundlingCalls/bundleDescriptor.js

@@ -0,0 +1,85 @@
+"use strict";
+/*
+ * Copyright 2019, Google LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+const normalApiCaller_1 = require("../normalCalls/normalApiCaller");
+const bundleApiCaller_1 = require("./bundleApiCaller");
+const bundleExecutor_1 = require("./bundleExecutor");
+/**
+ * A descriptor for calls that can be bundled into one call.
+ */
+class BundleDescriptor {
+ /**
+ * Describes the structure of bundled call.
+ *
+ * requestDiscriminatorFields may include '.' as a separator, which is used to
+ * indicate object traversal. This allows fields in nested objects to be used
+ * to determine what request to bundle.
+ *
+ * @property {String} bundledField
+ * @property {String} requestDiscriminatorFields
+ * @property {String} subresponseField
+ * @property {Function} byteLengthFunction
+ *
+ * @param {String} bundledField - the repeated field in the request message
+ * that will have its elements aggregated by bundling.
+ * @param {String} requestDiscriminatorFields - a list of fields in the
+ * target request message class that are used to detemrine which request
+ * messages should be bundled together.
+ * @param {String} subresponseField - an optional field, when present it
+ * indicates the field in the response message that should be used to
+ * demultiplex the response into multiple response messages.
+ * @param {Function} byteLengthFunction - a function to obtain the byte
+ * length to be consumed for the bundled field messages. Because Node.JS
+ * protobuf.js/gRPC uses builtin Objects for the user-visible data and
+ * internally they are encoded/decoded in protobuf manner, this function
+ * is actually necessary to calculate the byte length.
+ * @constructor
+ */
+ constructor(bundledField, requestDiscriminatorFields, subresponseField, byteLengthFunction) {
+ if (!byteLengthFunction && typeof subresponseField === 'function') {
+ byteLengthFunction = subresponseField;
+ subresponseField = null;
+ }
+ this.bundledField = bundledField;
+ this.requestDiscriminatorFields = requestDiscriminatorFields;
+ this.subresponseField = subresponseField;
+ this.byteLengthFunction = byteLengthFunction;
+ }
+ getApiCaller(settings) {
+ if (settings.isBundling === false) {
+ return new normalApiCaller_1.NormalApiCaller();
+ }
+ return new bundleApiCaller_1.BundleApiCaller(new bundleExecutor_1.BundleExecutor(settings.bundleOptions, this));
+ }
+}
+exports.BundleDescriptor = BundleDescriptor;
+//# sourceMappingURL=bundleDescriptor.js.map
\ No newline at end of file

build/src/bundlingCalls/bundleDescriptor.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"bundleDescriptor.js","sourceRoot":"","sources":["../../../src/bundlingCalls/bundleDescriptor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAIH,oEAA+D;AAE/D,uDAAkD;AAClD,qDAAgD;AAEhD;;GAEG;AACH,MAAa,gBAAgB;IAM3B;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,YACI,YAAoB,EAAE,0BAAoC,EAC1D,gBAA6B,EAAE,kBAA4B;QAC7D,IAAI,CAAC,kBAAkB,IAAI,OAAO,gBAAgB,KAAK,UAAU,EAAE;YACjE,kBAAkB,GAAG,gBAAgB,CAAC;YACtC,gBAAgB,GAAG,IAAI,CAAC;SACzB;QACD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,0BAA0B,GAAG,0BAA0B,CAAC;QAC7D,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;IAC/C,CAAC;IAED,YAAY,CAAC,QAAsB;QACjC,IAAI,QAAQ,CAAC,UAAU,KAAK,KAAK,EAAE;YACjC,OAAO,IAAI,iCAAe,EAAE,CAAC;SAC9B;QACD,OAAO,IAAI,iCAAe,CACtB,IAAI,+BAAc,CAAC,QAAQ,CAAC,aAAc,EAAE,IAAI,CAAC,CAAC,CAAC;IACzD,CAAC;CACF;AArDD,4CAqDC"}
\ No newline at end of file

build/src/bundlingCalls/bundleExecutor.d.ts

@@ -0,0 +1,74 @@
+/// <reference types="node" />
+import { SimpleCallbackFunction } from '../apitypes';
+import { BundleDescriptor } from './bundleDescriptor';
+import { Task, TaskCallback } from './task';
+export interface BundleOptions {
+ elementCountLimit: number;
+ requestByteLimit: number;
+ elementCountThreshold: number;
+ requestByteThreshold: number;
+ delayThreshold: number;
+}
+/**
+ * BundleExecutor stores several timers for each bundle (calls are bundled based
+ * on the options passed, each bundle has unique ID that is calculated based on
+ * field values). Each timer fires and sends a call after certain amount of
+ * time, and if a new request comes to the same bundle, the timer can be
+ * restarted.
+ */
+export declare class BundleExecutor {
+ _options: BundleOptions;
+ _descriptor: BundleDescriptor;
+ _tasks: {
+ [index: string]: Task;
+ };
+ _timers: {
+ [index: string]: NodeJS.Timer;
+ };
+ _invocations: {
+ [index: string]: string;
+ };
+ _invocationId: number;
+ /**
+ * Organizes requests for an api service that requires to bundle them.
+ *
+ * @param {BundleOptions} bundleOptions - configures strategy this instance
+ * uses when executing bundled functions.
+ * @param {BundleDescriptor} bundleDescriptor - the description of the bundling.
+ * @constructor
+ */
+ constructor(bundleOptions: BundleOptions, bundleDescriptor: BundleDescriptor);
+ /**
+ * Schedule a method call.
+ *
+ * @param {function} apiCall - the function for an API call.
+ * @param {Object} request - the request object to be bundled with others.
+ * @param {APICallback} callback - the callback to be called when the method finished.
+ * @return {function()} - the function to cancel the scheduled invocation.
+ */
+ schedule(apiCall: SimpleCallbackFunction, request: {
+ [index: string]: Array<{}> | string;
+ }, callback?: TaskCallback): import("../apitypes").GRPCCallResult;
+ /**
+ * Clears scheduled timeout if it exists.
+ *
+ * @param {String} bundleId - the id for the task whose timeout needs to be
+ * cleared.
+ * @private
+ */
+ private _maybeClearTimeout;
+ /**
+ * Cancels an event.
+ *
+ * @param {String} id - The id for the event in the task.
+ * @private
+ */
+ private _cancel;
+ /**
+ * Invokes a task.
+ *
+ * @param {String} bundleId - The id for the task.
+ * @private
+ */
+ _runNow(bundleId: string): void;
+}

build/src/bundlingCalls/bundleExecutor.js

@@ -0,0 +1,202 @@
+"use strict";
+/*
+ * Copyright 2019 Google LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+const grpc_1 = require("grpc");
+const googleError_1 = require("../googleError");
+const warnings_1 = require("../warnings");
+const bundlingUtils_1 = require("./bundlingUtils");
+const task_1 = require("./task");
+function noop() { }
+/**
+ * BundleExecutor stores several timers for each bundle (calls are bundled based
+ * on the options passed, each bundle has unique ID that is calculated based on
+ * field values). Each timer fires and sends a call after certain amount of
+ * time, and if a new request comes to the same bundle, the timer can be
+ * restarted.
+ */
+class BundleExecutor {
+ /**
+ * Organizes requests for an api service that requires to bundle them.
+ *
+ * @param {BundleOptions} bundleOptions - configures strategy this instance
+ * uses when executing bundled functions.
+ * @param {BundleDescriptor} bundleDescriptor - the description of the bundling.
+ * @constructor
+ */
+ constructor(bundleOptions, bundleDescriptor) {
+ this._options = bundleOptions;
+ this._descriptor = bundleDescriptor;
+ this._tasks = {};
+ this._timers = {};
+ this._invocations = {};
+ this._invocationId = 0;
+ }
+ /**
+ * Schedule a method call.
+ *
+ * @param {function} apiCall - the function for an API call.
+ * @param {Object} request - the request object to be bundled with others.
+ * @param {APICallback} callback - the callback to be called when the method finished.
+ * @return {function()} - the function to cancel the scheduled invocation.
+ */
+ schedule(apiCall, request, callback) {
+ const bundleId = bundlingUtils_1.computeBundleId(request, this._descriptor.requestDiscriminatorFields);
+ callback = (callback || noop);
+ if (bundleId === undefined) {
+ warnings_1.warn('bundling_schedule_bundleid_undefined', 'The request does not have enough information for request bundling. ' +
+ `Invoking immediately. Request: ${JSON.stringify(request)} ` +
+ `discriminator fields: ${this._descriptor.requestDiscriminatorFields}`);
+ return apiCall(request, callback);
+ }
+ if (request[this._descriptor.bundledField] === undefined) {
+ warnings_1.warn('bundling_no_bundled_field', `Request does not contain field ${this._descriptor.bundledField} that must present for bundling. ` +
+ `Invoking immediately. Request: ${JSON.stringify(request)}`);
+ return apiCall(request, callback);
+ }
+ if (!(bundleId in this._tasks)) {
+ this._tasks[bundleId] = new task_1.Task(apiCall, request, this._descriptor.bundledField, this._descriptor.subresponseField);
+ }
+ let task = this._tasks[bundleId];
+ callback.id = String(this._invocationId++);
+ this._invocations[callback.id] = bundleId;
+ const bundledField = request[this._descriptor.bundledField];
+ const elementCount = bundledField.length;
+ let requestBytes = 0;
+ const self = this;
+ bundledField.forEach(obj => {
+ requestBytes += this._descriptor.byteLengthFunction(obj);
+ });
+ const countLimit = this._options.elementCountLimit || 0;
+ const byteLimit = this._options.requestByteLimit || 0;
+ if ((countLimit > 0 && elementCount > countLimit) ||
+ (byteLimit > 0 && requestBytes >= byteLimit)) {
+ let message;
+ if (countLimit > 0 && elementCount > countLimit) {
+ message = 'The number of elements ' + elementCount +
+ ' exceeds the limit ' + this._options.elementCountLimit;
+ }
+ else {
+ message = 'The required bytes ' + requestBytes + ' exceeds the limit ' +
+ this._options.requestByteLimit;
+ }
+ const error = new googleError_1.GoogleError(message);
+ error.code = grpc_1.status.INVALID_ARGUMENT;
+ callback(error);
+ return {
+ cancel: noop,
+ };
+ }
+ const existingCount = task.getElementCount();
+ const existingBytes = task.getRequestByteSize();
+ if ((countLimit > 0 && elementCount + existingCount >= countLimit) ||
+ (byteLimit > 0 && requestBytes + existingBytes >= byteLimit)) {
+ this._runNow(bundleId);
+ this._tasks[bundleId] = new task_1.Task(apiCall, request, this._descriptor.bundledField, this._descriptor.subresponseField);
+ task = this._tasks[bundleId];
+ }
+ task.extend(bundledField, requestBytes, callback);
+ const ret = {
+ cancel() {
+ self._cancel(callback.id);
+ },
+ };
+ const countThreshold = this._options.elementCountThreshold || 0;
+ const sizeThreshold = this._options.requestByteThreshold || 0;
+ if ((countThreshold > 0 && task.getElementCount() >= countThreshold) ||
+ (sizeThreshold > 0 && task.getRequestByteSize() >= sizeThreshold)) {
+ this._runNow(bundleId);
+ return ret;
+ }
+ if (!(bundleId in this._timers) && this._options.delayThreshold > 0) {
+ this._timers[bundleId] = setTimeout(() => {
+ delete this._timers[bundleId];
+ this._runNow(bundleId);
+ }, this._options.delayThreshold);
+ }
+ return ret;
+ }
+ /**
+ * Clears scheduled timeout if it exists.
+ *
+ * @param {String} bundleId - the id for the task whose timeout needs to be
+ * cleared.
+ * @private
+ */
+ _maybeClearTimeout(bundleId) {
+ if (bundleId in this._timers) {
+ const timerId = this._timers[bundleId];
+ delete this._timers[bundleId];
+ clearTimeout(timerId);
+ }
+ }
+ /**
+ * Cancels an event.
+ *
+ * @param {String} id - The id for the event in the task.
+ * @private
+ */
+ _cancel(id) {
+ if (!(id in this._invocations)) {
+ return;
+ }
+ const bundleId = this._invocations[id];
+ if (!(bundleId in this._tasks)) {
+ return;
+ }
+ const task = this._tasks[bundleId];
+ delete this._invocations[id];
+ if (task.cancel(id)) {
+ this._maybeClearTimeout(bundleId);
+ delete this._tasks[bundleId];
+ }
+ }
+ /**
+ * Invokes a task.
+ *
+ * @param {String} bundleId - The id for the task.
+ * @private
+ */
+ _runNow(bundleId) {
+ if (!(bundleId in this._tasks)) {
+ warnings_1.warn('bundle_runnow_bundleid_unknown', `No such bundleid: ${bundleId}`);
+ return;
+ }
+ this._maybeClearTimeout(bundleId);
+ const task = this._tasks[bundleId];
+ delete this._tasks[bundleId];
+ task.run().forEach(id => {
+ delete this._invocations[id];
+ });
+ }
+}
+exports.BundleExecutor = BundleExecutor;
+//# sourceMappingURL=bundleExecutor.js.map
\ No newline at end of file

build/src/bundlingCalls/bundleExecutor.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"bundleExecutor.js","sourceRoot":"","sources":["../../../src/bundlingCalls/bundleExecutor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAEH,+BAA4B;AAG5B,gDAA2C;AAC3C,0CAAiC;AAGjC,mDAAgD;AAChD,iCAA0C;AAE1C,SAAS,IAAI,KAAI,CAAC;AAUlB;;;;;;GAMG;AACH,MAAa,cAAc;IAOzB;;;;;;;OAOG;IACH,YACI,aAA4B,EAAE,gBAAkC;QAClE,IAAI,CAAC,QAAQ,GAAG,aAAa,CAAC;QAC9B,IAAI,CAAC,WAAW,GAAG,gBAAgB,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;IACzB,CAAC;IAED;;;;;;;OAOG;IACH,QAAQ,CACJ,OAA+B,EAC/B,OAA4C,EAAE,QAAuB;QACvE,MAAM,QAAQ,GACV,+BAAe,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,0BAA0B,CAAC,CAAC;QAC1E,QAAQ,GAAG,CAAC,QAAQ,IAAI,IAAI,CAAiB,CAAC;QAC9C,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC1B,eAAI,CACA,sCAAsC,EACtC,qEAAqE;gBACjE,kCAAkC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG;gBAC5D,yBACI,IAAI,CAAC,WAAW,CAAC,0BAA0B,EAAE,CAAC,CAAC;YAC3D,OAAO,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;SACnC;QACD,IAAI,OAAO,CAAC,IAAI,CAAC,WAAW,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;OAKG;IACK,OAAO,CAAC,EAAU;QACxB,IAAI,CAAC,CAAC,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC,EAAE;YAC9B,OAAO;SACR;QACD,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QACvC,IAAI,CAAC,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE;YAC9B,OAAO;SACR;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QAC7B,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE;YACnB,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;YAClC,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;SAC9B;IACH,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,QAAgB;QACtB,IAAI,CAAC,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE;YAC9B,eAAI,CAAC,gCAAgC,EAAE,qBAAqB,QAAQ,EAAE,CAAC,CAAC;YACxE,OAAO;SACR;QACD,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QAClC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAE7B,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;YACtB,OAAO,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA7LD,wCA6LC"}
\ No newline at end of file

build/src/bundlingCalls/bundlingUtils.d.ts

@@ -0,0 +1,13 @@
+import { RequestType } from '../apitypes';
+/**
+ * Compute the identifier of the `obj`. The objects of the same ID
+ * will be bundled together.
+ *
+ * @param {RequestType} obj - The request object.
+ * @param {String[]} discriminatorFields - The array of field names.
+ * A field name may include '.' as a separator, which is used to
+ * indicate object traversal.
+ * @return {String|undefined} - the identifier string, or undefined if any
+ * discriminator fields do not exist.
+ */
+export declare function computeBundleId(obj: RequestType, discriminatorFields: string[]): string | undefined;

build/src/bundlingCalls/bundlingUtils.js

@@ -0,0 +1,67 @@
+"use strict";
+/*
+ * Copyright 2019 Google LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+/**
+ * Provides behavior that supports request bundling.
+ */
+const at = require("lodash.at");
+/**
+ * Compute the identifier of the `obj`. The objects of the same ID
+ * will be bundled together.
+ *
+ * @param {RequestType} obj - The request object.
+ * @param {String[]} discriminatorFields - The array of field names.
+ * A field name may include '.' as a separator, which is used to
+ * indicate object traversal.
+ * @return {String|undefined} - the identifier string, or undefined if any
+ * discriminator fields do not exist.
+ */
+function computeBundleId(obj, discriminatorFields) {
+ const ids = [];
+ let hasIds = false;
+ for (let i = 0; i < discriminatorFields.length; ++i) {
+ const id = at(obj, discriminatorFields[i])[0];
+ if (id === undefined) {
+ ids.push(null);
+ }
+ else {
+ hasIds = true;
+ ids.push(id);
+ }
+ }
+ if (!hasIds) {
+ return undefined;
+ }
+ return JSON.stringify(ids);
+}
+exports.computeBundleId = computeBundleId;
+//# sourceMappingURL=bundlingUtils.js.map
\ No newline at end of file

build/src/bundlingCalls/bundlingUtils.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"bundlingUtils.js","sourceRoot":"","sources":["../../../src/bundlingCalls/bundlingUtils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAEH;;GAEG;AAEH,gCAAiC;AAGjC;;;;;;;;;;GAUG;AACH,SAAgB,eAAe,CAC3B,GAAgB,EAAE,mBAA6B;IACjD,MAAM,GAAG,GAAmB,EAAE,CAAC;IAC/B,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,mBAAmB,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACnD,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9C,IAAI,EAAE,KAAK,SAAS,EAAE;YACpB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAChB;aAAM;YACL,MAAM,GAAG,IAAI,CAAC;YACd,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACd;KACF;IACD,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AAjBD,0CAiBC"}
\ No newline at end of file

build/src/bundlingCalls/task.d.ts

@@ -0,0 +1,85 @@
+import { APICallback, GRPCCallResult, SimpleCallbackFunction } from '../apitypes';
+export interface SubResponseInfo {
+ field: string;
+ start?: number;
+ end?: number;
+}
+export interface TaskElement {
+}
+export interface TaskData {
+ elements: TaskElement[];
+ bytes: number;
+ callback: TaskCallback;
+ cancelled?: boolean;
+}
+export interface TaskCallback extends APICallback {
+ id?: string;
+}
+/**
+ * Creates a deep copy of the object with the consideration of subresponse
+ * fields for bundling.
+ *
+ * @param {Object} obj - The source object.
+ * @param {Object?} subresponseInfo - The information to copy the subset of
+ * the field for the response. Do nothing if it's null.
+ * @param {String} subresponseInfo.field - The field name.
+ * @param {number} subresponseInfo.start - The offset where the copying
+ * element should starts with.
+ * @param {number} subresponseInfo.end - The ending index where the copying
+ * region of the elements ends.
+ * @return {Object} The copied object.
+ * @private
+ */
+export declare function deepCopyForResponse(obj: any, subresponseInfo: SubResponseInfo | null): any;
+export declare class Task {
+ _apiCall: SimpleCallbackFunction;
+ _request: {
+ [index: string]: TaskElement[];
+ };
+ _bundledField: string;
+ _subresponseField?: string | null;
+ _data: TaskData[];
+ callCanceller?: GRPCCallResult;
+ /**
+ * A task coordinates the execution of a single bundle.
+ *
+ * @param {function} apiCall - The function to conduct calling API.
+ * @param {Object} bundlingRequest - The base request object to be used
+ * for the actual API call.
+ * @param {string} bundledField - The name of the field in bundlingRequest
+ * to be bundled.
+ * @param {string=} subresponseField - The name of the field in the response
+ * to be passed to the callback.
+ * @constructor
+ * @private
+ */
+ constructor(apiCall: SimpleCallbackFunction, bundlingRequest: {}, bundledField: string, subresponseField?: string | null);
+ /**
+ * Returns the number of elements in a task.
+ * @return {number} The number of elements.
+ */
+ getElementCount(): number;
+ /**
+ * Returns the total byte size of the elements in a task.
+ * @return {number} The byte size.
+ */
+ getRequestByteSize(): number;
+ /**
+ * Invokes the actual API call with current elements.
+ * @return {string[]} - the list of ids for invocations to be run.
+ */
+ run(): string[];
+ /**
+ * Appends the list of elements into the task.
+ * @param {Object[]} elements - the new list of elements.
+ * @param {number} bytes - the byte size required to encode elements in the API.
+ * @param {APICallback} callback - the callback of the method call.
+ */
+ extend(elements: TaskElement[], bytes: number, callback: TaskCallback): void;
+ /**
+ * Cancels a part of elements.
+ * @param {string} id - The identifier of the part of elements.
+ * @return {boolean} Whether the entire task will be canceled or not.
+ */
+ cancel(id: string): boolean;
+}

build/src/bundlingCalls/task.js

@@ -0,0 +1,242 @@
+"use strict";
+/*
+ * Copyright 2019 Google LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+const grpc_1 = require("grpc");
+const googleError_1 = require("../googleError");
+/**
+ * Creates a deep copy of the object with the consideration of subresponse
+ * fields for bundling.
+ *
+ * @param {Object} obj - The source object.
+ * @param {Object?} subresponseInfo - The information to copy the subset of
+ * the field for the response. Do nothing if it's null.
+ * @param {String} subresponseInfo.field - The field name.
+ * @param {number} subresponseInfo.start - The offset where the copying
+ * element should starts with.
+ * @param {number} subresponseInfo.end - The ending index where the copying
+ * region of the elements ends.
+ * @return {Object} The copied object.
+ * @private
+ */
+function deepCopyForResponse(
+// tslint:disable-next-line no-any
+obj, subresponseInfo) {
+ // tslint:disable-next-line no-any
+ let result;
+ if (obj === null) {
+ return null;
+ }
+ if (obj === undefined) {
+ return undefined;
+ }
+ if (Array.isArray(obj)) {
+ result = [];
+ obj.forEach(element => {
+ result.push(deepCopyForResponse(element, null));
+ });
+ return result;
+ }
+ // Some objects (such as ByteBuffer) have copy method.
+ if (obj.copy !== undefined) {
+ return obj.copy();
+ }
+ // ArrayBuffer should be copied through slice().
+ if (obj instanceof ArrayBuffer) {
+ return obj.slice(0);
+ }
+ if (typeof obj === 'object') {
+ result = {};
+ Object.keys(obj).forEach(key => {
+ if (subresponseInfo && key === subresponseInfo.field &&
+ Array.isArray(obj[key])) {
+ // Note that subresponses are not deep-copied. This is safe because
+ // those subresponses are not shared among callbacks.
+ result[key] =
+ obj[key].slice(subresponseInfo.start, subresponseInfo.end);
+ }
+ else {
+ result[key] = deepCopyForResponse(obj[key], null);
+ }
+ });
+ return result;
+ }
+ return obj;
+}
+exports.deepCopyForResponse = deepCopyForResponse;
+class Task {
+ /**
+ * A task coordinates the execution of a single bundle.
+ *
+ * @param {function} apiCall - The function to conduct calling API.
+ * @param {Object} bundlingRequest - The base request object to be used
+ * for the actual API call.
+ * @param {string} bundledField - The name of the field in bundlingRequest
+ * to be bundled.
+ * @param {string=} subresponseField - The name of the field in the response
+ * to be passed to the callback.
+ * @constructor
+ * @private
+ */
+ constructor(apiCall, bundlingRequest, bundledField, subresponseField) {
+ this._apiCall = apiCall;
+ this._request = bundlingRequest;
+ this._bundledField = bundledField;
+ this._subresponseField = subresponseField;
+ this._data = [];
+ }
+ /**
+ * Returns the number of elements in a task.
+ * @return {number} The number of elements.
+ */
+ getElementCount() {
+ let count = 0;
+ for (let i = 0; i < this._data.length; ++i) {
+ count += this._data[i].elements.length;
+ }
+ return count;
+ }
+ /**
+ * Returns the total byte size of the elements in a task.
+ * @return {number} The byte size.
+ */
+ getRequestByteSize() {
+ let size = 0;
+ for (let i = 0; i < this._data.length; ++i) {
+ size += this._data[i].bytes;
+ }
+ return size;
+ }
+ /**
+ * Invokes the actual API call with current elements.
+ * @return {string[]} - the list of ids for invocations to be run.
+ */
+ run() {
+ if (this._data.length === 0) {
+ return [];
+ }
+ const request = this._request;
+ const elements = [];
+ const ids = [];
+ for (let i = 0; i < this._data.length; ++i) {
+ elements.push.apply(elements, this._data[i].elements);
+ ids.push(this._data[i].callback.id);
+ }
+ request[this._bundledField] = elements;
+ const self = this;
+ this.callCanceller =
+ this._apiCall(request, (err, response) => {
+ const responses = [];
+ if (err) {
+ self._data.forEach(() => {
+ responses.push(undefined);
+ });
+ }
+ else {
+ let subresponseInfo = null;
+ if (self._subresponseField) {
+ subresponseInfo = {
+ field: self._subresponseField,
+ start: 0,
+ };
+ }
+ self._data.forEach(data => {
+ if (subresponseInfo) {
+ subresponseInfo.end =
+ subresponseInfo.start + data.elements.length;
+ }
+ responses.push(deepCopyForResponse(response, subresponseInfo));
+ if (subresponseInfo) {
+ subresponseInfo.start = subresponseInfo.end;
+ }
+ });
+ }
+ for (let i = 0; i < self._data.length; ++i) {
+ if (self._data[i].cancelled) {
+ const error = new googleError_1.GoogleError('cancelled');
+ error.code = grpc_1.status.CANCELLED;
+ self._data[i].callback(error);
+ }
+ else {
+ self._data[i].callback(err, responses[i]);
+ }
+ }
+ });
+ return ids;
+ }
+ /**
+ * Appends the list of elements into the task.
+ * @param {Object[]} elements - the new list of elements.
+ * @param {number} bytes - the byte size required to encode elements in the API.
+ * @param {APICallback} callback - the callback of the method call.
+ */
+ extend(elements, bytes, callback) {
+ this._data.push({
+ elements,
+ bytes,
+ callback,
+ });
+ }
+ /**
+ * Cancels a part of elements.
+ * @param {string} id - The identifier of the part of elements.
+ * @return {boolean} Whether the entire task will be canceled or not.
+ */
+ cancel(id) {
+ if (this.callCanceller) {
+ let allCancelled = true;
+ this._data.forEach(d => {
+ if (d.callback.id === id) {
+ d.cancelled = true;
+ }
+ if (!d.cancelled) {
+ allCancelled = false;
+ }
+ });
+ if (allCancelled) {
+ this.callCanceller.cancel();
+ }
+ return allCancelled;
+ }
+ for (let i = 0; i < this._data.length; ++i) {
+ if (this._data[i].callback.id === id) {
+ const error = new googleError_1.GoogleError('cancelled');
+ error.code = grpc_1.status.CANCELLED;
+ this._data[i].callback(error);
+ this._data.splice(i, 1);
+ break;
+ }
+ }
+ return this._data.length === 0;
+ }
+}
+exports.Task = Task;
+//# sourceMappingURL=task.js.map
\ No newline at end of file

build/src/bundlingCalls/task.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"task.js","sourceRoot":"","sources":["../../../src/bundlingCalls/task.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAEH,+BAA4B;AAG5B,gDAA2C;AAqB3C;;;;;;;;;;;;;;GAcG;AACH,SAAgB,mBAAmB;AAC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AC,CAAC,CAAC;YACH,IAAI,YAAY,EAAE;gBAChB,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC;aAC7B;YACD,OAAO,YAAY,CAAC;SACrB;QACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;YAC1C,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,EAAE;gBACpC,MAAM,KAAK,GAAG,IAAI,yBAAW,CAAC,WAAW,CAAC,CAAC;gBAC3C,KAAK,CAAC,IAAI,GAAG,aAAM,CAAC,SAAS,CAAC;gBAC9B,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBAC9B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBACxB,MAAM;aACP;SACF;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;IACjC,CAAC;CACF;AAvJD,oBAuJC"}
\ No newline at end of file

build/src/bundling.d.ts

@@ -1,216 +0,0 @@
-/// <reference types="node" />
-import { NormalApiCaller, APICall, PromiseCanceller, APICallback } from './apiCallable';
-import { CallSettings } from './gax';
-/**
- * Compute the identifier of the `obj`. The objects of the same ID
- * will be bundled together.
- *
- * @param {Object} obj - The request object.
- * @param {String[]} discriminatorFields - The array of field names.
- * A field name may include '.' as a separator, which is used to
- * indicate object traversal.
- * @return {String|undefined} - the identifier string, or undefined if any
- * discriminator.
- * fields do not exist.
- */
-export declare function computeBundleId(obj: {}, discriminatorFields: string[]): string | undefined;
-export interface SubResponseInfo {
- field: string;
- start?: number;
- end?: number;
-}
-export interface TaskElement {
-}
-export interface TaskData {
- elements: TaskElement[];
- bytes: number;
- callback: TaskCallback;
- cancelled?: boolean;
-}
-export interface TaskCallback extends APICallback {
- id?: string;
-}
-/**
- * Creates a deep copy of the object with the consideration of subresponse
- * fields for bundling.
- *
- * @param {Object} obj - The source object.
- * @param {Object?} subresponseInfo - The information to copy the subset of
- * the field for the response. Do nothing if it's null.
- * @param {String} subresponseInfo.field - The field name.
- * @param {number} subresponseInfo.start - The offset where the copying
- * element should starts with.
- * @param {number} subresponseInfo.end - The ending index where the copying
- * region of the elements ends.
- * @return {Object} The copied object.
- * @private
- */
-export declare function deepCopyForResponse(obj: any, subresponseInfo: SubResponseInfo | null): any;
-export declare class Task {
- _apiCall: APICall;
- _request: {
- [index: string]: TaskElement[];
- };
- _bundledField: string;
- _subresponseField?: string | null;
- _data: TaskData[];
- callCanceller?: PromiseCanceller;
- /**
- * A task coordinates the execution of a single bundle.
- *
- * @param {function} apiCall - The function to conduct calling API.
- * @param {Object} bundlingRequest - The base request object to be used
- * for the actual API call.
- * @param {string} bundledField - The name of the field in bundlingRequest
- * to be bundled.
- * @param {string=} subresponseField - The name of the field in the response
- * to be passed to the callback.
- * @constructor
- * @private
- */
- constructor(apiCall: APICall, bundlingRequest: {}, bundledField: string, subresponseField?: string | null);
- /**
- * Returns the number of elements in a task.
- * @return {number} The number of elements.
- */
- getElementCount(): number;
- /**
- * Returns the total byte size of the elements in a task.
- * @return {number} The byte size.
- */
- getRequestByteSize(): number;
- /**
- * Invokes the actual API call with current elements.
- * @return {string[]} - the list of ids for invocations to be run.
- */
- run(): string[];
- /**
- * Appends the list of elements into the task.
- * @param {Object[]} elements - the new list of elements.
- * @param {number} bytes - the byte size required to encode elements in the API.
- * @param {APICallback} callback - the callback of the method call.
- */
- extend(elements: TaskElement[], bytes: number, callback: TaskCallback): void;
- /**
- * Cancels a part of elements.
- * @param {string} id - The identifier of the part of elements.
- * @return {boolean} Whether the entire task will be canceled or not.
- */
- cancel(id: string): boolean;
-}
-export interface BundleOptions {
- elementCountLimit: number;
- requestByteLimit: number;
- elementCountThreshold: number;
- requestByteThreshold: number;
- delayThreshold: number;
-}
-export declare class BundleExecutor {
- _options: BundleOptions;
- _descriptor: BundleDescriptor;
- _tasks: {
- [index: string]: Task;
- };
- _timers: {
- [index: string]: NodeJS.Timer;
- };
- _invocations: {
- [index: string]: string;
- };
- _invocationId: number;
- /**
- * Organizes requests for an api service that requires to bundle them.
- *
- * @param {BundleOptions} bundleOptions - configures strategy this instance
- * uses when executing bundled functions.
- * @param {BundleDescriptor} bundleDescriptor - the description of the bundling.
- * @constructor
- */
- constructor(bundleOptions: BundleOptions, bundleDescriptor: BundleDescriptor);
- /**
- * Schedule a method call.
- *
- * @param {function} apiCall - the function for an API call.
- * @param {Object} request - the request object to be bundled with others.
- * @param {APICallback} callback - the callback to be called when the method finished.
- * @return {function()} - the function to cancel the scheduled invocation.
- */
- schedule(apiCall: APICall, request: {
- [index: string]: Array<{}> | string;
- }, callback?: TaskCallback): any;
- /**
- * Clears scheduled timeout if it exists.
- *
- * @param {String} bundleId - the id for the task whose timeout needs to be
- * cleared.
- * @private
- */
- _maybeClearTimeout(bundleId: string): void;
- /**
- * Cancels an event.
- *
- * @param {String} id - The id for the event in the task.
- * @private
- */
- _cancel(id: string): void;
- /**
- * Invokes a task.
- *
- * @param {String} bundleId - The id for the task.
- * @private
- */
- _runNow(bundleId: string): void;
-}
-export declare class Bundleable extends NormalApiCaller {
- bundler: BundleExecutor;
- /**
- * Creates an API caller that bundles requests.
- *
- * @private
- * @constructor
- * @param {BundleExecutor} bundler - bundles API calls.
- */
- constructor(bundler: BundleExecutor);
- call(apiCall: APICall, argument: {}, settings: CallSettings, status: any): void;
-}
-export declare class BundleDescriptor {
- bundledField: string;
- requestDiscriminatorFields: string[];
- subresponseField: string | null;
- byteLengthFunction: Function;
- /**
- * Describes the structure of bundled call.
- *
- * requestDiscriminatorFields may include '.' as a separator, which is used to
- * indicate object traversal. This allows fields in nested objects to be used
- * to determine what request to bundle.
- *
- * @property {String} bundledField
- * @property {String} requestDiscriminatorFields
- * @property {String} subresponseField
- * @property {Function} byteLengthFunction
- *
- * @param {String} bundledField - the repeated field in the request message
- * that will have its elements aggregated by bundling.
- * @param {String} requestDiscriminatorFields - a list of fields in the
- * target request message class that are used to detemrine which request
- * messages should be bundled together.
- * @param {String} subresponseField - an optional field, when present it
- * indicates the field in the response message that should be used to
- * demultiplex the response into multiple response messages.
- * @param {Function} byteLengthFunction - a function to obtain the byte
- * length to be consumed for the bundled field messages. Because Node.JS
- * protobuf.js/gRPC uses builtin Objects for the user-visible data and
- * internally they are encoded/decoded in protobuf manner, this function
- * is actually necessary to calculate the byte length.
- * @constructor
- */
- constructor(bundledField: string, requestDiscriminatorFields: string[], subresponseField: string | null, byteLengthFunction: Function);
- /**
- * Returns a new API caller.
- * @private
- * @param {CallSettings} settings - the current settings.
- * @return {Bundleable} - the new bundling API caller.
- */
- apiCaller(settings: CallSettings): Bundleable;
-}

build/src/bundling.js

@@ -1,514 +0,0 @@
-"use strict";
-/*
- * Copyright 2016, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-Object.defineProperty(exports, "__esModule", { value: true });
-/**
- * Provides behavior that supports request bundling.
- */
-const at = require("lodash.at");
-const grpc_1 = require("grpc");
-const apiCallable_1 = require("./apiCallable");
-const GoogleError_1 = require("./GoogleError");
-const warnings_1 = require("./warnings");
-/**
- * A function which does nothing. Used for an empty cancellation funciton.
- * @private
- */
-function noop() { }
-/**
- * Compute the identifier of the `obj`. The objects of the same ID
- * will be bundled together.
- *
- * @param {Object} obj - The request object.
- * @param {String[]} discriminatorFields - The array of field names.
- * A field name may include '.' as a separator, which is used to
- * indicate object traversal.
- * @return {String|undefined} - the identifier string, or undefined if any
- * discriminator.
- * fields do not exist.
- */
-function computeBundleId(obj, discriminatorFields) {
- const ids = [];
- let hasIds = false;
- for (let i = 0; i < discriminatorFields.length; ++i) {
- const id = at(obj, discriminatorFields[i])[0];
- if (id === undefined) {
- ids.push(null);
- }
- else {
- hasIds = true;
- ids.push(id);
- }
- }
- if (!hasIds) {
- return undefined;
- }
- return JSON.stringify(ids);
-}
-exports.computeBundleId = computeBundleId;
-/**
- * Creates a deep copy of the object with the consideration of subresponse
- * fields for bundling.
- *
- * @param {Object} obj - The source object.
- * @param {Object?} subresponseInfo - The information to copy the subset of
- * the field for the response. Do nothing if it's null.
- * @param {String} subresponseInfo.field - The field name.
- * @param {number} subresponseInfo.start - The offset where the copying
- * element should starts with.
- * @param {number} subresponseInfo.end - The ending index where the copying
- * region of the elements ends.
- * @return {Object} The copied object.
- * @private
- */
-function deepCopyForResponse(
-// tslint:disable-next-line no-any
-obj, subresponseInfo) {
- // tslint:disable-next-line no-any
- let result;
- if (obj === null) {
- return null;
- }
- if (obj === undefined) {
- return undefined;
- }
- if (Array.isArray(obj)) {
- result = [];
- obj.forEach(element => {
- result.push(deepCopyForResponse(element, null));
- });
- return result;
- }
- // Some objects (such as ByteBuffer) have copy method.
- if (obj.copy !== undefined) {
- return obj.copy();
- }
- // ArrayBuffer should be copied through slice().
- if (obj instanceof ArrayBuffer) {
- return obj.slice(0);
- }
- if (typeof obj === 'object') {
- result = {};
- Object.keys(obj).forEach(key => {
- if (subresponseInfo && key === subresponseInfo.field &&
- Array.isArray(obj[key])) {
- // Note that subresponses are not deep-copied. This is safe because
- // those subresponses are not shared among callbacks.
- result[key] =
- obj[key].slice(subresponseInfo.start, subresponseInfo.end);
- }
- else {
- result[key] = deepCopyForResponse(obj[key], null);
- }
- });
- return result;
- }
- return obj;
-}
-exports.deepCopyForResponse = deepCopyForResponse;
-class Task {
- /**
- * A task coordinates the execution of a single bundle.
- *
- * @param {function} apiCall - The function to conduct calling API.
- * @param {Object} bundlingRequest - The base request object to be used
- * for the actual API call.
- * @param {string} bundledField - The name of the field in bundlingRequest
- * to be bundled.
- * @param {string=} subresponseField - The name of the field in the response
- * to be passed to the callback.
- * @constructor
- * @private
- */
- constructor(apiCall, bundlingRequest, bundledField, subresponseField) {
- this._apiCall = apiCall;
- this._request = bundlingRequest;
- this._bundledField = bundledField;
- this._subresponseField = subresponseField;
- this._data = [];
- }
- /**
- * Returns the number of elements in a task.
- * @return {number} The number of elements.
- */
- getElementCount() {
- let count = 0;
- for (let i = 0; i < this._data.length; ++i) {
- count += this._data[i].elements.length;
- }
- return count;
- }
- /**
- * Returns the total byte size of the elements in a task.
- * @return {number} The byte size.
- */
- getRequestByteSize() {
- let size = 0;
- for (let i = 0; i < this._data.length; ++i) {
- size += this._data[i].bytes;
- }
- return size;
- }
- /**
- * Invokes the actual API call with current elements.
- * @return {string[]} - the list of ids for invocations to be run.
- */
- run() {
- if (this._data.length === 0) {
- return [];
- }
- const request = this._request;
- const elements = [];
- const ids = [];
- for (let i = 0; i < this._data.length; ++i) {
- elements.push.apply(elements, this._data[i].elements);
- ids.push(this._data[i].callback.id);
- }
- request[this._bundledField] = elements;
- const self = this;
- this.callCanceller =
- this._apiCall(request, (err, response) => {
- const responses = [];
- if (err) {
- self._data.forEach(() => {
- responses.push(null);
- });
- }
- else {
- let subresponseInfo = null;
- if (self._subresponseField) {
- subresponseInfo = {
- field: self._subresponseField,
- start: 0,
- };
- }
- self._data.forEach(data => {
- if (subresponseInfo) {
- subresponseInfo.end =
- subresponseInfo.start + data.elements.length;
- }
- responses.push(deepCopyForResponse(response, subresponseInfo));
- if (subresponseInfo) {
- subresponseInfo.start = subresponseInfo.end;
- }
- });
- }
- for (let i = 0; i < self._data.length; ++i) {
- if (self._data[i].cancelled) {
- const error = new GoogleError_1.GoogleError('cancelled');
- error.code = grpc_1.status.CANCELLED;
- self._data[i].callback(error);
- }
- else {
- self._data[i].callback(err, responses[i]);
- }
- }
- });
- return ids;
- }
- /**
- * Appends the list of elements into the task.
- * @param {Object[]} elements - the new list of elements.
- * @param {number} bytes - the byte size required to encode elements in the API.
- * @param {APICallback} callback - the callback of the method call.
- */
- extend(elements, bytes, callback) {
- this._data.push({
- elements,
- bytes,
- callback,
- });
- }
- /**
- * Cancels a part of elements.
- * @param {string} id - The identifier of the part of elements.
- * @return {boolean} Whether the entire task will be canceled or not.
- */
- cancel(id) {
- if (this.callCanceller) {
- let allCancelled = true;
- this._data.forEach(d => {
- if (d.callback.id === id) {
- d.cancelled = true;
- }
- if (!d.cancelled) {
- allCancelled = false;
- }
- });
- if (allCancelled) {
- this.callCanceller.cancel();
- }
- return allCancelled;
- }
- for (let i = 0; i < this._data.length; ++i) {
- if (this._data[i].callback.id === id) {
- const error = new GoogleError_1.GoogleError('cancelled');
- error.code = grpc_1.status.CANCELLED;
- this._data[i].callback(error);
- this._data.splice(i, 1);
- break;
- }
- }
- return this._data.length === 0;
- }
-}
-exports.Task = Task;
-class BundleExecutor {
- /**
- * Organizes requests for an api service that requires to bundle them.
- *
- * @param {BundleOptions} bundleOptions - configures strategy this instance
- * uses when executing bundled functions.
- * @param {BundleDescriptor} bundleDescriptor - the description of the bundling.
- * @constructor
- */
- constructor(bundleOptions, bundleDescriptor) {
- this._options = bundleOptions;
- this._descriptor = bundleDescriptor;
- this._tasks = {};
- this._timers = {};
- this._invocations = {};
- this._invocationId = 0;
- }
- /**
- * Schedule a method call.
- *
- * @param {function} apiCall - the function for an API call.
- * @param {Object} request - the request object to be bundled with others.
- * @param {APICallback} callback - the callback to be called when the method finished.
- * @return {function()} - the function to cancel the scheduled invocation.
- */
- schedule(apiCall, request, callback) {
- const bundleId = computeBundleId(request, this._descriptor.requestDiscriminatorFields);
- callback = (callback || noop);
- if (bundleId === undefined) {
- warnings_1.warn('bundling_schedule_bundleid_undefined', 'The request does not have enough information for request bundling. ' +
- `Invoking immediately. Request: ${JSON.stringify(request)} ` +
- `discriminator fields: ${this._descriptor.requestDiscriminatorFields}`);
- return apiCall(request, callback);
- }
- if (request[this._descriptor.bundledField] === undefined) {
- warnings_1.warn('bundling_no_bundled_field', `Request does not contain field ${this._descriptor.bundledField} that must present for bundling. ` +
- `Invoking immediately. Request: ${JSON.stringify(request)}`);
- return apiCall(request, callback);
- }
- if (!(bundleId in this._tasks)) {
- this._tasks[bundleId] = new Task(apiCall, request, this._descriptor.bundledField, this._descriptor.subresponseField);
- }
- let task = this._tasks[bundleId];
- callback.id = String(this._invocationId++);
- this._invocations[callback.id] = bundleId;
- const bundledField = request[this._descriptor.bundledField];
- const elementCount = bundledField.length;
- let requestBytes = 0;
- const self = this;
- bundledField.forEach(obj => {
- requestBytes += this._descriptor.byteLengthFunction(obj);
- });
- const countLimit = this._options.elementCountLimit || 0;
- const byteLimit = this._options.requestByteLimit || 0;
- if ((countLimit > 0 && elementCount > countLimit) ||
- (byteLimit > 0 && requestBytes >= byteLimit)) {
- let message;
- if (countLimit > 0 && elementCount > countLimit) {
- message = 'The number of elements ' + elementCount +
- ' exceeds the limit ' + this._options.elementCountLimit;
- }
- else {
- message = 'The required bytes ' + requestBytes + ' exceeds the limit ' +
- this._options.requestByteLimit;
- }
- const error = new GoogleError_1.GoogleError(message);
- error.code = grpc_1.status.INVALID_ARGUMENT;
- callback(error);
- return {
- cancel: noop,
- };
- }
- const existingCount = task.getElementCount();
- const existingBytes = task.getRequestByteSize();
- if ((countLimit > 0 && elementCount + existingCount >= countLimit) ||
- (byteLimit > 0 && requestBytes + existingBytes >= byteLimit)) {
- this._runNow(bundleId);
- this._tasks[bundleId] = new Task(apiCall, request, this._descriptor.bundledField, this._descriptor.subresponseField);
- task = this._tasks[bundleId];
- }
- task.extend(bundledField, requestBytes, callback);
- const ret = {
- cancel() {
- self._cancel(callback.id);
- },
- };
- const countThreshold = this._options.elementCountThreshold || 0;
- const sizeThreshold = this._options.requestByteThreshold || 0;
- if ((countThreshold > 0 && task.getElementCount() >= countThreshold) ||
- (sizeThreshold > 0 && task.getRequestByteSize() >= sizeThreshold)) {
- this._runNow(bundleId);
- return ret;
- }
- if (!(bundleId in this._timers) && this._options.delayThreshold > 0) {
- this._timers[bundleId] = setTimeout(() => {
- delete this._timers[bundleId];
- this._runNow(bundleId);
- }, this._options.delayThreshold);
- }
- return ret;
- }
- /**
- * Clears scheduled timeout if it exists.
- *
- * @param {String} bundleId - the id for the task whose timeout needs to be
- * cleared.
- * @private
- */
- _maybeClearTimeout(bundleId) {
- if (bundleId in this._timers) {
- const timerId = this._timers[bundleId];
- delete this._timers[bundleId];
- clearTimeout(timerId);
- }
- }
- /**
- * Cancels an event.
- *
- * @param {String} id - The id for the event in the task.
- * @private
- */
- _cancel(id) {
- if (!(id in this._invocations)) {
- return;
- }
- const bundleId = this._invocations[id];
- if (!(bundleId in this._tasks)) {
- return;
- }
- const task = this._tasks[bundleId];
- delete this._invocations[id];
- if (task.cancel(id)) {
- this._maybeClearTimeout(bundleId);
- delete this._tasks[bundleId];
- }
- }
- /**
- * Invokes a task.
- *
- * @param {String} bundleId - The id for the task.
- * @private
- */
- _runNow(bundleId) {
- if (!(bundleId in this._tasks)) {
- warnings_1.warn('bundle_runnow_bundleid_unknown', `No such bundleid: ${bundleId}`);
- return;
- }
- this._maybeClearTimeout(bundleId);
- const task = this._tasks[bundleId];
- delete this._tasks[bundleId];
- task.run().forEach(id => {
- delete this._invocations[id];
- });
- }
-}
-exports.BundleExecutor = BundleExecutor;
-class Bundleable extends apiCallable_1.NormalApiCaller {
- /**
- * Creates an API caller that bundles requests.
- *
- * @private
- * @constructor
- * @param {BundleExecutor} bundler - bundles API calls.
- */
- constructor(bundler) {
- super();
- this.bundler = bundler;
- }
- // tslint:disable-next-line no-any
- call(apiCall, argument, settings, status) {
- if (settings.isBundling) {
- status.call((argument, callback) => {
- this.bundler.schedule(apiCall, argument, callback);
- }, argument);
- }
- else {
- apiCallable_1.NormalApiCaller.prototype.call.call(this, apiCall, argument, settings, status);
- }
- }
-}
-exports.Bundleable = Bundleable;
-class BundleDescriptor {
- /**
- * Describes the structure of bundled call.
- *
- * requestDiscriminatorFields may include '.' as a separator, which is used to
- * indicate object traversal. This allows fields in nested objects to be used
- * to determine what request to bundle.
- *
- * @property {String} bundledField
- * @property {String} requestDiscriminatorFields
- * @property {String} subresponseField
- * @property {Function} byteLengthFunction
- *
- * @param {String} bundledField - the repeated field in the request message
- * that will have its elements aggregated by bundling.
- * @param {String} requestDiscriminatorFields - a list of fields in the
- * target request message class that are used to detemrine which request
- * messages should be bundled together.
- * @param {String} subresponseField - an optional field, when present it
- * indicates the field in the response message that should be used to
- * demultiplex the response into multiple response messages.
- * @param {Function} byteLengthFunction - a function to obtain the byte
- * length to be consumed for the bundled field messages. Because Node.JS
- * protobuf.js/gRPC uses builtin Objects for the user-visible data and
- * internally they are encoded/decoded in protobuf manner, this function
- * is actually necessary to calculate the byte length.
- * @constructor
- */
- constructor(bundledField, requestDiscriminatorFields, subresponseField, byteLengthFunction) {
- if (!byteLengthFunction && typeof subresponseField === 'function') {
- byteLengthFunction = subresponseField;
- subresponseField = null;
- }
- this.bundledField = bundledField;
- this.requestDiscriminatorFields = requestDiscriminatorFields;
- this.subresponseField = subresponseField;
- this.byteLengthFunction = byteLengthFunction;
- }
- /**
- * Returns a new API caller.
- * @private
- * @param {CallSettings} settings - the current settings.
- * @return {Bundleable} - the new bundling API caller.
- */
- apiCaller(settings) {
- return new Bundleable(new BundleExecutor(settings.bundleOptions, this));
- }
-}
-exports.BundleDescriptor = BundleDescriptor;
-//# sourceMappingURL=bundling.js.map
\ No newline at end of file

build/src/bundling.js.map

@@ -1 +0,0 @@
-{"version":3,"file":"bundling.js","sourceRoot":"","sources":["../../src/bundling.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAEH;;GAEG;AAEH,gCAAiC;AACjC,+BAA4B;AAC5B,+CAAsF;AACtF,+CAA0C;AAE1C,yCAAgC;AAEhC;;;GAGG;AACH,SAAS,IAAI,KAAI,CAAC;AAElB;;;;;;;;;;;GAWG;AACH,SAAgB,eAAe,CAAC,GAAO,EAAE,mBAA6B;IACpE,MAAM,GAAG,GAAmB,EAAE,CAAC;IAC/B,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,mBAAmB,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACnD,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9C,IAAI,EAAE,KAAK,SAAS,EAAE;YACpB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAChB;aAAM;YACL,MAAM,GAAG,IAAI,CAAC;YACd,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACd;KACF;IACD,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,SAAS,CAAC;KAClB;IACD,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,CAAC;SACzB;QACD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,0BAA0B,GAAG,0BAA0B,CAAC;QAC7D,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;IAC/C,CAAC;IAGD;;;;;OAKG;IACH,SAAS,CAAC,QAAsB;QAC9B,OAAO,IAAI,UAAU,CAAC,IAAI,cAAc,CAAC,QAAQ,CAAC,aAAc,EAAE,IAAI,CAAC,CAAC,CAAC;IAC3E,CAAC;CACF;AAxDD,4CAwDC"}
\ No newline at end of file

build/src/call.d.ts

@@ -0,0 +1,47 @@
+import { APICallback, RequestType, ResultTuple, SimpleCallbackFunction } from './apitypes';
+export declare class OngoingCall {
+ callback?: APICallback;
+ cancelFunc?: () => void;
+ completed: boolean;
+ /**
+ * OngoingCall manages callback, API calls, and cancellation
+ * of the API calls.
+ * @param {APICallback=} callback
+ * The callback to be called asynchronously when the API call
+ * finishes.
+ * @constructor
+ * @property {APICallback} callback
+ * The callback function to be called.
+ * @private
+ */
+ constructor(callback?: APICallback);
+ /**
+ * Cancels the ongoing promise.
+ */
+ cancel(): void;
+ /**
+ * Call calls the specified function. Result will be used to fulfill
+ * the promise.
+ *
+ * @param {SimpleCallbackFunction} func
+ * A function for an API call.
+ * @param {Object} argument
+ * A request object.
+ */
+ call(func: SimpleCallbackFunction, argument: RequestType): void;
+}
+export interface CancellablePromise<T> extends Promise<T> {
+ cancel(): void;
+}
+export declare class OngoingCallPromise extends OngoingCall {
+ promise: CancellablePromise<ResultTuple>;
+ /**
+ * GaxPromise is GRPCCallbackWrapper, but it holds a promise when
+ * the API call finishes.
+ * @param {Function} PromiseCtor - A constructor for a promise that implements
+ * the ES6 specification of promise.
+ * @constructor
+ * @private
+ */
+ constructor(PromiseCtor: PromiseConstructor);
+}

build/src/call.js

@@ -0,0 +1,122 @@
+"use strict";
+/*
+ * Copyright 2019 Google LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+const grpc_1 = require("grpc");
+const googleError_1 = require("./googleError");
+class OngoingCall {
+ /**
+ * OngoingCall manages callback, API calls, and cancellation
+ * of the API calls.
+ * @param {APICallback=} callback
+ * The callback to be called asynchronously when the API call
+ * finishes.
+ * @constructor
+ * @property {APICallback} callback
+ * The callback function to be called.
+ * @private
+ */
+ constructor(callback) {
+ this.callback = callback;
+ this.completed = false;
+ }
+ /**
+ * Cancels the ongoing promise.
+ */
+ cancel() {
+ if (this.completed) {
+ return;
+ }
+ this.completed = true;
+ if (this.cancelFunc) {
+ this.cancelFunc();
+ }
+ else {
+ const error = new googleError_1.GoogleError('cancelled');
+ error.code = grpc_1.status.CANCELLED;
+ this.callback(error);
+ }
+ }
+ /**
+ * Call calls the specified function. Result will be used to fulfill
+ * the promise.
+ *
+ * @param {SimpleCallbackFunction} func
+ * A function for an API call.
+ * @param {Object} argument
+ * A request object.
+ */
+ call(func, argument) {
+ if (this.completed) {
+ return;
+ }
+ // tslint:disable-next-line no-any
+ const canceller = func(argument, (...args) => {
+ this.completed = true;
+ setImmediate(this.callback, ...args);
+ });
+ this.cancelFunc = () => canceller.cancel();
+ }
+}
+exports.OngoingCall = OngoingCall;
+class OngoingCallPromise extends OngoingCall {
+ /**
+ * GaxPromise is GRPCCallbackWrapper, but it holds a promise when
+ * the API call finishes.
+ * @param {Function} PromiseCtor - A constructor for a promise that implements
+ * the ES6 specification of promise.
+ * @constructor
+ * @private
+ */
+ // tslint:disable-next-line variable-name
+ constructor(PromiseCtor) {
+ super();
+ this.promise = new PromiseCtor((resolve, reject) => {
+ this.callback =
+ (err, response, next, rawResponse) => {
+ if (err) {
+ reject(err);
+ }
+ else if (response !== undefined) {
+ resolve([response, next, rawResponse]);
+ }
+ else {
+ throw new googleError_1.GoogleError('Neither error nor response are defined');
+ }
+ };
+ });
+ this.promise.cancel = () => {
+ this.cancel();
+ };
+ }
+}
+exports.OngoingCallPromise = OngoingCallPromise;
+//# sourceMappingURL=call.js.map
\ No newline at end of file

build/src/call.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"call.js","sourceRoot":"","sources":["../../src/call.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAEH,+BAA4B;AAG5B,+CAA0C;AAE1C,MAAa,WAAW;IAKtB;;;;;;;;;;OAUG;IACH,YAAY,QAAsB;Q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AAG,EAAE;wBACP,MAAM,CAAC,GAAG,CAAC,CAAC;qBACb;yBAAM,IAAI,QAAQ,KAAK,SAAS,EAAE;wBACjC,OAAO,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;qBACxC;yBAAM;wBACL,MAAM,IAAI,yBAAW,CACjB,wCAAwC,CAAC,CAAC;qBAC/C;gBACH,CAAC,CAAC;QACR,CAAC,CAAoC,CAAC;QACrD,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE;YACzB,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,CAAC,CAAC;IACJ,CAAC;CACF;AAhCD,gDAgCC"}
\ No newline at end of file

build/src/createApiCall.d.ts

@@ -0,0 +1,23 @@
+import { GaxCall, GRPCCall } from './apitypes';
+import { Descriptor } from './descriptor';
+import { CallSettings } from './gax';
+/**
+ * Converts an rpc call into an API call governed by the settings.
+ *
+ * In typical usage, `func` will be a promise to a callable used to make an rpc
+ * request. This will mostly likely be a bound method from a request stub used
+ * to make an rpc call. It is not a direct function but a Promise instance,
+ * because of its asynchronism (typically, obtaining the auth information).
+ *
+ * The result is a function which manages the API call with the given settings
+ * and the options on the invocation.
+ *
+ * @param {Promise<GRPCCall>|GRPCCall} func - is either a promise to be used to make
+ * a bare RPC call, or just a bare RPC call.
+ * @param {CallSettings} settings - provides the settings for this call
+ * @param {Descriptor} descriptor - optionally specify the descriptor for
+ * the method call.
+ * @return {GaxCall} func - a bound method on a request stub used
+ * to make an rpc call.
+ */
+export declare function createApiCall(func: Promise<GRPCCall> | GRPCCall, settings: CallSettings, descriptor?: Descriptor): GaxCall;

build/src/createApiCall.js

@@ -0,0 +1,93 @@
+"use strict";
+/*
+ * Copyright 2019 Google LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+/**
+ * Provides function wrappers that implement page streaming and retrying.
+ */
+const apiCaller_1 = require("./apiCaller");
+const retries_1 = require("./normalCalls/retries");
+const timeout_1 = require("./normalCalls/timeout");
+/**
+ * Converts an rpc call into an API call governed by the settings.
+ *
+ * In typical usage, `func` will be a promise to a callable used to make an rpc
+ * request. This will mostly likely be a bound method from a request stub used
+ * to make an rpc call. It is not a direct function but a Promise instance,
+ * because of its asynchronism (typically, obtaining the auth information).
+ *
+ * The result is a function which manages the API call with the given settings
+ * and the options on the invocation.
+ *
+ * @param {Promise<GRPCCall>|GRPCCall} func - is either a promise to be used to make
+ * a bare RPC call, or just a bare RPC call.
+ * @param {CallSettings} settings - provides the settings for this call
+ * @param {Descriptor} descriptor - optionally specify the descriptor for
+ * the method call.
+ * @return {GaxCall} func - a bound method on a request stub used
+ * to make an rpc call.
+ */
+function createApiCall(func, settings, descriptor) {
+ // we want to be able to accept both promise resolving to a function and a
+ // function. Currently client librares are only calling this method with a
+ // promise, but it will change.
+ const funcPromise = typeof func === 'function' ? Promise.resolve(func) : func;
+ // the following apiCaller will be used for all calls of this function...
+ const apiCaller = apiCaller_1.createAPICaller(settings, descriptor);
+ return (request, callOptions, callback) => {
+ const thisSettings = settings.merge(callOptions);
+ let currentApiCaller = apiCaller;
+ // special case: if bundling is disabled for this one call,
+ // use default API caller instead
+ if (settings.isBundling && !thisSettings.isBundling) {
+ currentApiCaller = apiCaller_1.createAPICaller(settings, undefined);
+ }
+ const status = currentApiCaller.init(thisSettings, callback);
+ funcPromise
+ .then(func => {
+ func = currentApiCaller.wrap(func);
+ const retry = thisSettings.retry;
+ if (retry && retry.retryCodes && retry.retryCodes.length > 0) {
+ return retries_1.retryable(func, thisSettings.retry, thisSettings.otherArgs);
+ }
+ return timeout_1.addTimeoutArg(func, thisSettings.timeout, thisSettings.otherArgs);
+ })
+ .then(apiCall => {
+ currentApiCaller.call(apiCall, request, thisSettings, status);
+ })
+ .catch(err => {
+ currentApiCaller.fail(status, err);
+ });
+ return currentApiCaller.result(status);
+ };
+}
+exports.createApiCall = createApiCall;
+//# sourceMappingURL=createApiCall.js.map
\ No newline at end of file

build/src/createApiCall.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"createApiCall.js","sourceRoot":"","sources":["../../src/createApiCall.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAEH;;GAEG;AAEH,2CAA4C;AAI5C,mDAAgD;AAChD,mDAAoD;AAEpD;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,aAAa,CACzB,IAAgC,EAAE,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AAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;QAChE,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,CAAC,EAAE;YACX,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;QACP,OAAO,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC,CAAC;AACJ,CAAC;AA5CD,sCA4CC"}
\ No newline at end of file

build/src/descriptor.d.ts

@@ -0,0 +1,9 @@
+import { APICaller } from './apiCaller';
+import { CallSettings } from './gax';
+export interface Descriptor {
+ getApiCaller(settings: CallSettings): APICaller;
+}
+export { LongRunningDescriptor as LongrunningDescriptor } from './longRunningCalls/longRunningDescriptor';
+export { PageDescriptor } from './paginationCalls/pageDescriptor';
+export { StreamDescriptor } from './streamingCalls/streamDescriptor';
+export { BundleDescriptor } from './bundlingCalls/bundleDescriptor';

build/src/descriptor.js

@@ -0,0 +1,41 @@
+"use strict";
+/*
+ * Copyright 2019 Google LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+var longRunningDescriptor_1 = require("./longRunningCalls/longRunningDescriptor");
+exports.LongrunningDescriptor = longRunningDescriptor_1.LongRunningDescriptor;
+var pageDescriptor_1 = require("./paginationCalls/pageDescriptor");
+exports.PageDescriptor = pageDescriptor_1.PageDescriptor;
+var streamDescriptor_1 = require("./streamingCalls/streamDescriptor");
+exports.StreamDescriptor = streamDescriptor_1.StreamDescriptor;
+var bundleDescriptor_1 = require("./bundlingCalls/bundleDescriptor");
+exports.BundleDescriptor = bundleDescriptor_1.BundleDescriptor;
+//# sourceMappingURL=descriptor.js.map
\ No newline at end of file

build/src/descriptor.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"descriptor.js","sourceRoot":"","sources":["../../src/descriptor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAeH,kFAAwG;AAAhG,wDAAA,qBAAqB,CAAyB;AACtD,mEAAgE;AAAxD,0CAAA,cAAc,CAAA;AACtB,sEAAmE;AAA3D,8CAAA,gBAAgB,CAAA;AACxB,qEAAkE;AAA1D,8CAAA,gBAAgB,CAAA"}
\ No newline at end of file

build/src/gax.d.ts

@@ -1,5 +1,5 @@
/**
- * Copyright 2016, Google Inc.
+ * Copyright 2019 Google LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,7 @@
/**
* Google API Extensions
*/
-import { BundleOptions } from './bundling';
+import { BundleOptions } from './bundlingCalls/bundleExecutor';
/**
* Encapsulates the overridable settings for a particular API call.
*
@@ -152,7 +152,8 @@
timeout?: number;
retry?: RetryOptions | null;
autoPaginate?: boolean;
- pageToken?: number;
+ pageToken?: string;
+ pageSize?: number;
maxResults?: number;
maxRetries?: number;
otherArgs?: {
@@ -160,21 +161,22 @@
};
bundleOptions?: BundleOptions | null;
isBundling?: boolean;
- longrunning?: boolean | null;
+ longrunning?: BackoffSettings;
promise?: PromiseConstructor;
}
export declare class CallSettings {
timeout: number;
retry?: RetryOptions | null;
autoPaginate?: boolean;
- pageToken?: number;
+ pageToken?: string;
+ pageSize?: number;
maxResults?: number;
otherArgs: {
[index: string]: any;
};
bundleOptions?: BundleOptions | null;
isBundling: boolean;
- longrunning?: boolean | null;
+ longrunning?: BackoffSettings;
promise: PromiseConstructor;
/**
* @param {Object} settings - An object containing parameters of this settings.
@@ -245,6 +247,7 @@
*
*/
export declare function createBackoffSettings(initialRetryDelayMillis: number, retryDelayMultiplier: number, maxRetryDelayMillis: number, initialRpcTimeoutMillis: number | null, rpcTimeoutMultiplier: number | null, maxRpcTimeoutMillis: number | null, totalTimeoutMillis: number | null): BackoffSettings;
+export declare function createDefaultBackoffSettings(): BackoffSettings;
/**
* Parameters to the exponential backoff algorithm for retrying.
* This function is unsupported, and intended for internal use only.

build/src/gax.js

@@ -1,6 +1,6 @@
"use strict";
/**
- * Copyright 2016, Google Inc.
+ * Copyright 2019 Google LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -120,7 +120,8 @@
this.otherArgs = settings.otherArgs || {};
this.bundleOptions = settings.bundleOptions;
this.isBundling = 'isBundling' in settings ? settings.isBundling : true;
- this.longrunning = 'longrunning' in settings ? settings.longrunning : null;
+ this.longrunning =
+ 'longrunning' in settings ? settings.longrunning : undefined;
this.promise = 'promise' in settings ? settings.promise : Promise;
}
/**
@@ -139,6 +140,7 @@
let retry = this.retry;
let autoPaginate = this.autoPaginate;
let pageToken = this.pageToken;
+ let pageSize = this.pageSize;
let maxResults = this.maxResults;
let otherArgs = this.otherArgs;
let isBundling = this.isBundling;
@@ -157,6 +159,9 @@
autoPaginate = false;
pageToken = options.pageToken;
}
+ if ('pageSize' in options) {
+ pageSize = options.pageSize;
+ }
if ('maxResults' in options) {
maxResults = options.maxResults;
}
@@ -191,6 +196,7 @@
longrunning,
autoPaginate,
pageToken,
+ pageSize,
maxResults,
otherArgs,
isBundling,
@@ -253,6 +259,10 @@
};
}
exports.createBackoffSettings = createBackoffSettings;
+function createDefaultBackoffSettings() {
+ return createBackoffSettings(100, 1.3, 60000, null, null, null, null);
+}
+exports.createDefaultBackoffSettings = createDefaultBackoffSettings;
/**
* Parameters to the exponential backoff algorithm for retrying.
* This function is unsupported, and intended for internal use only.

build/src/gax.js.map

@@ -1 +1 @@
-{"version":3,"file":"gax.js","sourceRoot":"","sources":["../../src/gax.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAQH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH;;;;;GAKG;AACH,MAAa,YAAY;IAGvB,YAAY,UAAoB,EAAE,eAAgC;QAChE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;CACF;AAPD,oCAOC;AAgFD,MAAa,YAAY;IAavB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,YAAY,QAAsB;QAChC,QAAQ,GAAG,QAAQ,IAAI,EAAE,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,IAAI,EAAE,GAAG,IAAI,CAAC;QAC7C,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;QAC5B,IAAI,CAAC,YAAY;Y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AAE;oBAClC,cAAc,GAAG,gBAAgB,CAAC,QAAQ,CAAC;iBAC5C;gBACD,IAAI,gBAAgB,IAAI,gBAAgB,EAAE;oBACxC,OAAO,GAAG,gBAAgB,CAAC,cAAc,CAAC;iBAC3C;aACF;YACD,KAAK,GAAG,iBAAiB,CACrB,KAAM,EACN,cAAc,CACV,gBAAgB,EAAE,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC,YAAY,EAC/D,UAAU,CAAE,CAAC,CAAC;SACvB;QAED,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,YAAY,CAAC;YAClC,OAAO;YACP,KAAK;YACL,aAAa,EAAE,cAAc,CAAC,CAAC,CAAC,mBAAmB,CAAC,cAAc,CAAC,CAAC,CAAC;gBACrC,IAAI;YACpC,SAAS;YACT,OAAO,EAAE,OAAO,IAAI,OAAO;SAC5B,CAAC,CAAC;KACJ;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAtDD,8CAsDC"}
\ No newline at end of file

build/src/googleError.d.ts

@@ -0,0 +1,5 @@
+import { status } from 'grpc';
+export declare class GoogleError extends Error {
+ code?: status;
+ note?: string;
+}

build/src/GoogleError.d.ts

@@ -1,5 +0,0 @@
-import { status } from 'grpc';
-export declare class GoogleError extends Error {
- code?: status;
- note?: string;
-}

build/src/googleError.js

@@ -0,0 +1,36 @@
+"use strict";
+/*
+ * Copyright 2019 Google LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+class GoogleError extends Error {
+}
+exports.GoogleError = GoogleError;
+//# sourceMappingURL=googleError.js.map
\ No newline at end of file

build/src/GoogleError.js

@@ -1,36 +0,0 @@
-"use strict";
-/*
- * Copyright 2018, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-Object.defineProperty(exports, "__esModule", { value: true });
-class GoogleError extends Error {
-}
-exports.GoogleError = GoogleError;
-//# sourceMappingURL=GoogleError.js.map
\ No newline at end of file

build/src/googleError.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"googleError.js","sourceRoot":"","sources":["../../src/googleError.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAIH,MAAa,WAAY,SAAQ,KAAK;CAGrC;AAHD,kCAGC"}
\ No newline at end of file

build/src/GoogleError.js.map

@@ -1 +0,0 @@
-{"version":3,"file":"GoogleError.js","sourceRoot":"","sources":["../../src/GoogleError.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAIH,MAAa,WAAY,SAAQ,KAAK;CAGrC;AAHD,kCAGC"}
\ No newline at end of file

build/src/grpc.d.ts

@@ -25,7 +25,6 @@
status: {
[index: string]: number;
};
- isLegacy: boolean;
};
export interface ClientStubOptions {
servicePath: string;
@@ -77,26 +76,7 @@
loadFromProto(filename: string, options: grpcProtoLoaderTypes.Options): grpcTypes.GrpcObject;
/**
* Load grpc proto service from a filename hooking in googleapis common protos
- * when necessary. Uses legacy grpc.loadObject.
- * @param {String} protoPath - The directory to search for the protofile.
- * @param {String} filename - The filename of the proto to be loaded.
- * @return {Object<string, *>} The gRPC loaded result (the toplevel namespace
- * object).
- */
- protected loadProtoLegacy(protoPath: string, filename: string): grpcTypes.GrpcObject;
- /**
- * Load grpc proto service from a filename hooking in googleapis common protos
- * when necessary. Uses the new shiny @grpc/proto-loader.
- * @param {String} protoPath - The directory to search for the protofile.
- * @param {String} filename - The filename of the proto to be loaded.
- * @return {Object<string, *>} The gRPC loaded result (the toplevel namespace
- * object).
- */
- protected loadProtoGrpcJs(protoPath: string, filename: string): grpcTypes.GrpcObject;
- /**
- * Load grpc proto service from a filename hooking in googleapis common protos
- * when necessary. Can use either legacy grpc.loadProto, or new
- * @grpc/proto-loader, depending on which gRPC backend is used.
+ * when necessary.
* @param {String} protoPath - The directory to search for the protofile.
* @param {String} filename - The filename of the proto to be loaded.
* @return {Object<string, *>} The gRPC loaded result (the toplevel namespace

build/src/grpc.js

@@ -1,6 +1,6 @@
"use strict";
/*
- * Copyright 2016, Google Inc.
+ * Copyright 2019 Google LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,6 @@
const grpcProtoLoaderTypes = require("@grpc/proto-loader"); // for types only
const fs = require("fs");
const google_auth_library_1 = require("google-auth-library");
-const google_proto_files_1 = require("google-proto-files");
const grpcTypes = require("grpc"); // for types only
const grpcGcp = require("grpc-gcp");
const path = require("path");
@@ -50,32 +49,15 @@
const semver = require("semver");
const walk = require("walkdir");
const gax = require("./gax");
-const googleProtoFilesDir = path.normalize(google_proto_files_1.getProtoPath('..'));
+const googleProtoFilesDir = path.join(__dirname, '..', '..', 'protos');
// INCLUDE_DIRS is passed to @grpc/proto-loader
const INCLUDE_DIRS = [];
INCLUDE_DIRS.push(googleProtoFilesDir);
// COMMON_PROTO_FILES logic is here for protobufjs loads (see
// GoogleProtoFilesRoot below)
-const COMMON_PROTO_DIRS = [
- // This list of directories is defined here:
- // https://github.com/googleapis/googleapis/blob/master/gapic/packaging/common_protos.yaml
- 'api',
- path.join('iam', 'v1'),
- path.join('logging', 'type'),
- path.join('monitoring', 'v3'),
- 'longrunning',
- 'protobuf',
- 'rpc',
- 'type',
-].map(dir => path.join(googleProtoFilesDir, 'google', dir));
-INCLUDE_DIRS.push(...COMMON_PROTO_DIRS);
-const COMMON_PROTO_FILES = COMMON_PROTO_DIRS
- .map(dir => {
- return walk.sync(dir)
+const COMMON_PROTO_FILES = walk.sync(googleProtoFilesDir)
.filter(f => path.extname(f) === '.proto')
.map(f => path.normalize(f).substring(googleProtoFilesDir.length + 1));
-})
- .reduce((a, c) => a.concat(c), []);
class ClientStub extends grpcTypes.Client {
}
exports.ClientStub = ClientStub;
@@ -110,12 +92,10 @@
if (semver.gte(process.version, '8.13.0') &&
!!process.env.GOOGLE_CLOUD_USE_GRPC_JS) {
this.grpc = require('@grpc/grpc-js');
- this.grpc.isLegacy = false;
this.grpcVersion = require('@grpc/grpc-js/package.json').version;
}
else {
this.grpc = require('grpc');
- this.grpc.isLegacy = true;
this.grpcVersion = require('grpc/package.json').version;
}
}
@@ -153,26 +133,13 @@
}
/**
* Load grpc proto service from a filename hooking in googleapis common protos
- * when necessary. Uses legacy grpc.loadObject.
+ * when necessary.
* @param {String} protoPath - The directory to search for the protofile.
* @param {String} filename - The filename of the proto to be loaded.
* @return {Object<string, *>} The gRPC loaded result (the toplevel namespace
* object).
*/
- loadProtoLegacy(protoPath, filename) {
- const resolvedPath = GrpcClient._resolveFile(protoPath, filename);
- const retval = this.grpc.loadObject(protobuf.loadSync(resolvedPath, new GoogleProtoFilesRoot()));
- return retval;
- }
- /**
- * Load grpc proto service from a filename hooking in googleapis common protos
- * when necessary. Uses the new shiny @grpc/proto-loader.
- * @param {String} protoPath - The directory to search for the protofile.
- * @param {String} filename - The filename of the proto to be loaded.
- * @return {Object<string, *>} The gRPC loaded result (the toplevel namespace
- * object).
- */
- loadProtoGrpcJs(protoPath, filename) {
+ loadProto(protoPath, filename) {
// This set of @grpc/proto-loader options
// 'closely approximates the existing behavior of grpc.load'
const includeDirs = INCLUDE_DIRS.slice();
@@ -187,19 +154,6 @@
};
return this.loadFromProto(filename, options);
}
- /**
- * Load grpc proto service from a filename hooking in googleapis common protos
- * when necessary. Can use either legacy grpc.loadProto, or new
- * @grpc/proto-loader, depending on which gRPC backend is used.
- * @param {String} protoPath - The directory to search for the protofile.
- * @param {String} filename - The filename of the proto to be loaded.
- * @return {Object<string, *>} The gRPC loaded result (the toplevel namespace
- * object).
- */
- loadProto(protoPath, filename) {
- return this.grpc.isLegacy ? this.loadProtoLegacy(protoPath, filename) :
- this.loadProtoGrpcJs(protoPath, filename);
- }
static _resolveFile(protoPath, filename) {
if (fs.existsSync(path.join(protoPath, filename))) {
return path.join(protoPath, filename);
@@ -318,7 +272,7 @@
super(...args);
}
// Causes the loading of an included proto to check if it is a common
- // proto. If it is a common proto, use the google-proto-files proto.
+ // proto. If it is a common proto, use the bundled proto.
resolvePath(originPath, includePath) {
originPath = path.normalize(originPath);
includePath = path.normalize(includePath);

build/src/grpc.js.map

@@ -1 +1 @@
-{"version":3,"file":"grpc.js","sourceRoot":"","sources":["../../src/grpc.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;;;;;;;;;;AAEH,2DAA2D,CAAE,iBAAiB;AAC9E,yBAAyB;AACzB,6DAAkE;AAClE,2DAAgD;AAChD,kCAAkC,CAAE,iBAAiB;AACrD,oCAAoC;AAEpC,6BAA6B;AAC7B,uCAAuC;AACvC,iCAAiC;AACjC,gCAAgC;AAEhC,6BAA6B;AAE7B,MAAM,mBAAmB,GAAG,IAAI,CAAC,SAAS,CAAC,iCAAY,CAAC,IAAI,CAAC,CAAC,CAAC;AAE/D,+CAA+C;AAC/C,MAAM,YAAY,GAAa,EAAE,CAAC;AAClC,YAAY,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;AAEvC,6DAA6D;A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K,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC;QAC3D,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YACnC,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAC9D,KAAK,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC;SACxD;QACD,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,eAAe,GAAG,WAAW,GAAG,kBAAkB,CAAC,CAAC;SACrE;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IACzC,CAAC;CACF;AAzCD,oDAyCC"}
\ No newline at end of file

build/src/index.d.ts

@@ -1,5 +1,5 @@
/**
- * Copyright 2016, Google Inc.
+ * Copyright 2019 Google LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -32,15 +32,15 @@
import * as operationsClient from './operationsClient';
import * as routingHeader from './routingHeader';
export { GoogleAuth, GoogleAuthOptions } from 'google-auth-library';
-export { CancellablePromise, Canceller, createApiCall } from './apiCallable';
-export { BundleDescriptor, BundleExecutor } from './bundling';
+export { CancellablePromise, OngoingCall } from './call';
+export { createApiCall } from './createApiCall';
+export { BundleDescriptor, LongrunningDescriptor, PageDescriptor, StreamDescriptor } from './descriptor';
export { CallOptions, CallSettings, ClientConfig, constructSettings, RetryOptions } from './gax';
-export { GoogleError } from './GoogleError';
+export { GoogleError } from './googleError';
export { ClientStub, ClientStubOptions, GoogleProtoFilesRoot, GrpcClient, GrpcClientOptions, GrpcModule, GrpcObject, Metadata, MetadataValue } from './grpc';
-export { LongrunningDescriptor, Operation, operation } from './longrunning';
-export { PageDescriptor } from './pagedIteration';
+export { Operation, operation } from './longRunningCalls/longrunning';
export { PathTemplate } from './pathTemplate';
-export { StreamDescriptor, StreamType } from './streaming';
+export { StreamType } from './streamingCalls/streaming';
export { routingHeader };
declare function lro(options: GrpcClientOptions): operationsClient.OperationsClientBuilder;
declare namespace lro {

build/src/index.js

@@ -1,6 +1,6 @@
"use strict";
/**
- * Copyright 2016, Google Inc.
+ * Copyright 2019 Google LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -36,32 +36,31 @@
exports.routingHeader = routingHeader;
var google_auth_library_1 = require("google-auth-library");
exports.GoogleAuth = google_auth_library_1.GoogleAuth;
-var apiCallable_1 = require("./apiCallable");
-exports.Canceller = apiCallable_1.Canceller;
-exports.createApiCall = apiCallable_1.createApiCall;
-var bundling_1 = require("./bundling");
-exports.BundleDescriptor = bundling_1.BundleDescriptor;
-exports.BundleExecutor = bundling_1.BundleExecutor;
+var call_1 = require("./call");
+exports.OngoingCall = call_1.OngoingCall;
+var createApiCall_1 = require("./createApiCall");
+exports.createApiCall = createApiCall_1.createApiCall;
+var descriptor_1 = require("./descriptor");
+exports.BundleDescriptor = descriptor_1.BundleDescriptor;
+exports.LongrunningDescriptor = descriptor_1.LongrunningDescriptor;
+exports.PageDescriptor = descriptor_1.PageDescriptor;
+exports.StreamDescriptor = descriptor_1.StreamDescriptor;
var gax_1 = require("./gax");
exports.CallSettings = gax_1.CallSettings;
exports.constructSettings = gax_1.constructSettings;
exports.RetryOptions = gax_1.RetryOptions;
-var GoogleError_1 = require("./GoogleError");
-exports.GoogleError = GoogleError_1.GoogleError;
+var googleError_1 = require("./googleError");
+exports.GoogleError = googleError_1.GoogleError;
var grpc_2 = require("./grpc");
exports.ClientStub = grpc_2.ClientStub;
exports.GoogleProtoFilesRoot = grpc_2.GoogleProtoFilesRoot;
exports.GrpcClient = grpc_2.GrpcClient;
-var longrunning_1 = require("./longrunning");
-exports.LongrunningDescriptor = longrunning_1.LongrunningDescriptor;
+var longrunning_1 = require("./longRunningCalls/longrunning");
exports.Operation = longrunning_1.Operation;
exports.operation = longrunning_1.operation;
-var pagedIteration_1 = require("./pagedIteration");
-exports.PageDescriptor = pagedIteration_1.PageDescriptor;
var pathTemplate_1 = require("./pathTemplate");
exports.PathTemplate = pathTemplate_1.PathTemplate;
-var streaming_1 = require("./streaming");
-exports.StreamDescriptor = streaming_1.StreamDescriptor;
+var streaming_1 = require("./streamingCalls/streaming");
exports.StreamType = streaming_1.StreamType;
function lro(options) {
options = Object.assign({ scopes: lro.ALL_SCOPES }, options);

build/src/index.js.map

@@ -1 +1 @@
-{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAEH,iCAAqD;AACrD,uDAAuD;AACvD,iDAAiD;AAYzC,sCAAa;AAVrB,2DAAkE;AAA1D,2CAAA,UAAU,CAAA;AAClB,6CAA2E;AAA/C,kCAAA,SAAS,CAAA;AAAE,sCAAA,aAAa,CAAA;AACpD,uCAA4D;AAApD,sCAAA,gBAAgB,CAAA;AAAE,oCAAA,cAAc,CAAA;AACxC,6BAA+F;AAA1E,6BAAA,YAAY,CAAA;AAAgB,kCAAA,iBAAiB,CAAA;AAAE,6BAAA,YAAY,CAAA;AAChF,6CAA0C;AAAlC,oCAAA,WAAW,CAAA;AACnB,+BAA2J;AAAnJ,4BAAA,UAAU,CAAA;AAAqB,sCAAA,oBAAoB,CAAA;AAAE,4BAAA,UAAU,CAAA;AACvE,6CAA0E;AAAlE,8CAAA,qBAAqB,CAAA;AAAE,kCAAA,SAAS,CAAA;AAAE,kCAAA,SAAS,CAAA;AACnD,mDAAgD;AAAxC,0CAAA,cAAc,CAAA;AACtB,+CAA4C;AAApC,sCAAA,YAAY,CAAA;AACpB,yCAAyD;AAAjD,uCAAA,gBAAgB,CAAA;AAAE,iCAAA,UAAU,CAAA;AAGpC,SAAS,GAAG,CAAC,OAA0B;IACrC,OAAO,GAA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sCAAA,YAAY,CAAA;AACpB,wDAAsD;AAA9C,iCAAA,UAAU,CAAA;AAGlB,SAAS,GAAG,CAAC,OAA0B;IACrC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAC,EAAE,OAAO,CAAC,CAAC;IAC3D,MAAM,OAAO,GAAG,IAAI,iBAAU,CAAC,OAAO,CAAC,CAAC;IACxC,OAAO,IAAI,gBAAgB,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAC/D,CAAC;AAKO,kBAAG;AAHX,GAAG,CAAC,eAAe,GAAG,gBAAgB,CAAC,eAAe,CAAC;AACvD,GAAG,CAAC,UAAU,GAAG,gBAAgB,CAAC,UAAU,CAAC;AAGhC,QAAA,wBAAwB,GAAG,iBAAU,CAAC,wBAAwB,CAAC;AAC/D,QAAA,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC"}
\ No newline at end of file

build/src/isbrowser.d.ts

@@ -1,16 +1 @@
-/**
- * Copyright 2019 Google LLC. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
export declare function isBrowser(): boolean;

build/src/isbrowser.js

@@ -1,18 +1,33 @@
"use strict";
-/**
- * Copyright 2019 Google LLC. All Rights Reserved.
+/*
+ * Copyright 2019 Google LLC
+ * All rights reserved.
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
Object.defineProperty(exports, "__esModule", { value: true });
function isBrowser() {

build/src/isbrowser.js.map

@@ -1 +1 @@
-{"version":3,"file":"isbrowser.js","sourceRoot":"","sources":["../../src/isbrowser.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAEH,SAAgB,SAAS;IACvB,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,WAAW,CAAC;AACzC,CAAC;AAFD,8BAEC"}
\ No newline at end of file
+{"version":3,"file":"isbrowser.js","sourceRoot":"","sources":["../../src/isbrowser.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAEH,SAAgB,SAAS;IACvB,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,WAAW,CAAC;AACzC,CAAC;AAFD,8BAEC"}
\ No newline at end of file

build/src/longRunningCalls/longRunningApiCaller.d.ts

@@ -0,0 +1,28 @@
+import { APICaller, ApiCallerSettings } from '../apiCaller';
+import { APICallback, GRPCCall, SimpleCallbackFunction } from '../apitypes';
+import { OngoingCall, OngoingCallPromise } from '../call';
+import { CallOptions } from '../gax';
+import { GoogleError } from '../googleError';
+import { Operation } from './longrunning';
+import { LongRunningDescriptor } from './longRunningDescriptor';
+export declare class LongrunningApiCaller implements APICaller {
+ longrunningDescriptor: LongRunningDescriptor;
+ /**
+ * Creates an API caller that performs polling on a long running operation.
+ *
+ * @private
+ * @constructor
+ * @param {LongRunningDescriptor} longrunningDescriptor - Holds the
+ * decoders used for unpacking responses and the operationsClient
+ * used for polling the operation.
+ */
+ constructor(longrunningDescriptor: LongRunningDescriptor);
+ init(settings: ApiCallerSettings, callback?: APICallback): OngoingCallPromise | OngoingCall;
+ wrap(func: GRPCCall): GRPCCall;
+ call(apiCall: SimpleCallbackFunction, argument: {}, settings: CallOptions, canceller: OngoingCallPromise): void;
+ private _wrapOperation;
+ fail(canceller: OngoingCallPromise, err: GoogleError): void;
+ result(canceller: OngoingCallPromise): import("../call").CancellablePromise<[import("../apitypes").ResponseType, {
+ [index: string]: string;
+ } | null | undefined, {} | Operation | undefined]>;
+}

build/src/longRunningCalls/longRunningApiCaller.js

@@ -0,0 +1,86 @@
+"use strict";
+/*
+ * Copyright 2019, Google LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+const call_1 = require("../call");
+const gax_1 = require("../gax");
+const longrunning_1 = require("./longrunning");
+class LongrunningApiCaller {
+ /**
+ * Creates an API caller that performs polling on a long running operation.
+ *
+ * @private
+ * @constructor
+ * @param {LongRunningDescriptor} longrunningDescriptor - Holds the
+ * decoders used for unpacking responses and the operationsClient
+ * used for polling the operation.
+ */
+ constructor(longrunningDescriptor) {
+ this.longrunningDescriptor = longrunningDescriptor;
+ }
+ init(settings, callback) {
+ if (callback) {
+ return new call_1.OngoingCall(callback);
+ }
+ return new call_1.OngoingCallPromise(settings.promise);
+ }
+ wrap(func) {
+ return func;
+ }
+ call(apiCall, argument, settings, canceller) {
+ canceller.call((argument, callback) => {
+ return this._wrapOperation(apiCall, settings, argument, callback);
+ }, argument);
+ }
+ _wrapOperation(apiCall, settings, argument, callback) {
+ let backoffSettings = settings.longrunning;
+ if (!backoffSettings) {
+ backoffSettings = gax_1.createDefaultBackoffSettings();
+ }
+ const longrunningDescriptor = this.longrunningDescriptor;
+ return apiCall(argument, (err, rawResponse) => {
+ if (err) {
+ callback(err, null, null, rawResponse);
+ return;
+ }
+ const operation = new longrunning_1.Operation(rawResponse, longrunningDescriptor, backoffSettings, settings);
+ callback(null, operation, rawResponse);
+ });
+ }
+ fail(canceller, err) {
+ canceller.callback(err);
+ }
+ result(canceller) {
+ return canceller.promise;
+ }
+}
+exports.LongrunningApiCaller = LongrunningApiCaller;
+//# sourceMappingURL=longRunningApiCaller.js.map
\ No newline at end of file

build/src/longRunningCalls/longRunningApiCaller.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"longRunningApiCaller.js","sourceRoot":"","sources":["../../../src/longRunningCalls/longRunningApiCaller.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAIH,kCAAwD;AACxD,gCAAuH;AAGvH,+CAAwC;AAGxC,MAAa,oBAAoB;IAE/B;;;;;;;;OAQG;IACH,YAAY,qBAA4C;QACtD,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;IACrD,CAAC;IAED,IAAI,CAAC,QAA2B,EAAE,QAAsB;QAEtD,IAAI,QAAQ,EAAE;YACZ,OAAO,IAAI,kBAAW,CAAC,QAAQ,CAAC,CAAC;SAClC;QACD,OAAO,IAAI,yBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;IAGD,IAAI,CAAC,IAAc;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CACA,OAA+B,EAAE,QAAY,EAAE,QAAqB,EACpE,SAA6B;QAC/B,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE;YACpC,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACpE,CAAC,EAAE,QAAQ,CAAC,CAAC;IACf,CAAC;IAEO,cAAc,CAClB,OAA+B,EAAE,QAAqB,EAAE,QAAY,EACpE,QAAqB;QACvB,IAAI,eAAe,GAA8B,QAAQ,CAAC,WAAW,CAAC;QACtE,IAAI,CAAC,eAAe,EAAE;YACpB,eAAe,GAAG,kCAA4B,EAAE,CAAC;SAClD;QAED,MAAM,qBAAqB,GAAG,IAAI,CAAC,qBAAqB,CAAC;QACzD,OAAO,OAAO,CACV,QAAQ,EAAE,CAAC,GAAqB,EAAE,WAA8B,EAAE,EAAE;YAClE,IAAI,GAAG,EAAE;gBACP,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,WAAwB,CAAC,CAAC;gBACpD,OAAO;aACR;YAED,MAAM,SAAS,GAAG,IAAI,uBAAS,CAC3B,WAAwB,EAAE,qBAAqB,EAAE,eAAgB,EACjE,QAAQ,CAAC,CAAC;YAEd,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACT,CAAC;IAED,IAAI,CAAC,SAA6B,EAAE,GAAgB;QAClD,SAAS,CAAC,QAAS,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,SAA6B;QAClC,OAAO,SAAS,CAAC,OAAO,CAAC;IAC3B,CAAC;CACF;AAnED,oDAmEC"}
\ No newline at end of file

build/src/longRunningCalls/longRunningDescriptor.d.ts

@@ -0,0 +1,21 @@
+import { Descriptor } from '../descriptor';
+import { CallSettings } from '../gax';
+import { Metadata } from '../grpc';
+import { OperationsClient } from '../operationsClient';
+import { LongrunningApiCaller } from './longRunningApiCaller';
+/**
+ * A callback to upack a google.protobuf.Any message.
+ */
+export interface AnyDecoder {
+ (message: {}): Metadata;
+}
+/**
+ * A descriptor for long-running operations.
+ */
+export declare class LongRunningDescriptor implements Descriptor {
+ operationsClient: OperationsClient;
+ responseDecoder: AnyDecoder;
+ metadataDecoder: AnyDecoder;
+ constructor(operationsClient: OperationsClient, responseDecoder: AnyDecoder, metadataDecoder: AnyDecoder);
+ getApiCaller(settings: CallSettings): LongrunningApiCaller;
+}

build/src/longRunningCalls/longRunningDescriptor.js

@@ -0,0 +1,48 @@
+"use strict";
+/*
+ * Copyright 2019 Google LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+const longRunningApiCaller_1 = require("./longRunningApiCaller");
+/**
+ * A descriptor for long-running operations.
+ */
+class LongRunningDescriptor {
+ constructor(operationsClient, responseDecoder, metadataDecoder) {
+ this.operationsClient = operationsClient;
+ this.responseDecoder = responseDecoder;
+ this.metadataDecoder = metadataDecoder;
+ }
+ getApiCaller(settings) {
+ return new longRunningApiCaller_1.LongrunningApiCaller(this);
+ }
+}
+exports.LongRunningDescriptor = LongRunningDescriptor;
+//# sourceMappingURL=longRunningDescriptor.js.map
\ No newline at end of file

build/src/longRunningCalls/longRunningDescriptor.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"longRunningDescriptor.js","sourceRoot":"","sources":["../../../src/longRunningCalls/longRunningDescriptor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAOH,iEAA4D;AAS5D;;GAEG;AACH,MAAa,qBAAqB;IAKhC,YACI,gBAAkC,EAAE,eAA2B,EAC/D,eAA2B;QAC7B,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAED,YAAY,CAAC,QAAsB;QACjC,OAAO,IAAI,2CAAoB,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;CACF;AAhBD,sDAgBC"}
\ No newline at end of file

build/src/longRunningCalls/longrunning.d.ts

@@ -0,0 +1,119 @@
+/// <reference types="node" />
+import { EventEmitter } from 'events';
+import { ResultTuple } from '../apitypes';
+import { CancellablePromise } from '../call';
+import { BackoffSettings, CallOptions } from '../gax';
+import { GoogleError } from '../googleError';
+import { Metadata } from '../grpc';
+import { LongRunningDescriptor } from './longRunningDescriptor';
+/**
+ * @callback GetOperationCallback
+ * @param {?Error} error
+ * @param {?Object} result
+ * @param {?Object} metadata
+ * @param {?google.longrunning.Operation} rawResponse
+ */
+export interface GetOperationCallback {
+ (err?: Error | null, result?: {}, metadata?: {}, rawResponse?: Operation): void;
+}
+export declare class Operation extends EventEmitter {
+ completeListeners: number;
+ hasActiveListeners: boolean;
+ latestResponse: Operation;
+ longrunningDescriptor: LongRunningDescriptor;
+ result: {} | null;
+ metadata: Metadata | null;
+ backoffSettings: BackoffSettings;
+ _callOptions?: CallOptions;
+ currentCallPromise_?: CancellablePromise<ResultTuple>;
+ name?: string;
+ done?: boolean;
+ error?: GoogleError;
+ response?: {
+ value: {};
+ };
+ /**
+ * Wrapper for a google.longrunnung.Operation.
+ *
+ * @constructor
+ *
+ * @param {google.longrunning.Operation} grpcOp - The operation to be wrapped.
+ * @param {LongRunningDescriptor} longrunningDescriptor - This defines the
+ * operations service client and unpacking mechanisms for the operation.
+ * @param {BackoffSettings} backoffSettings - The backoff settings used in
+ * in polling the operation.
+ * @param {CallOptions} callOptions - CallOptions used in making get operation
+ * requests.
+ */
+ constructor(grpcOp: Operation, longrunningDescriptor: LongRunningDescriptor, backoffSettings: BackoffSettings, callOptions?: CallOptions);
+ /**
+ * Begin listening for events on the operation. This method keeps track of how
+ * many "complete" listeners are registered and removed, making sure polling
+ * is handled automatically.
+ *
+ * As long as there is one active "complete" listener, the connection is open.
+ * When there are no more listeners, the polling stops.
+ *
+ * @private
+ */
+ _listenForEvents(): void;
+ /**
+ * Cancels current polling api call and cancels the operation.
+ *
+ * @return {Promise} the promise of the OperationsClient#cancelOperation api
+ * request.
+ */
+ cancel(): CancellablePromise<[import("../apitypes").ResponseType, {
+ [index: string]: string;
+ } | null | undefined, {} | Operation | undefined]>;
+ /**
+ * Get the updated status of the operation. If the Operation has previously
+ * completed, this will use the status of the cached completed operation.
+ *
+ * - callback(err): Operation failed
+ * - callback(null, result, metadata, rawResponse): Operation complete
+ * - callback(null, null, metadata, rawResponse): Operation incomplete
+ *
+ * @param {getOperationCallback} callback - Callback to handle the polled
+ * operation result and metadata.
+ * @return {Promise|undefined} - This returns a promise if a callback is not specified.
+ * The promise resolves to an array where the first element is the unpacked
+ * result, the second element is the metadata, and the third element is the
+ * raw response of the api call. The promise rejects if the operation returns
+ * an error.
+ */
+ getOperation(): Promise<{}>;
+ getOperation(callback: GetOperationCallback): void;
+ _unpackResponse(op: Operation, callback?: GetOperationCallback): void;
+ /**
+ * Poll `getOperation` to check the operation's status. This runs a loop to
+ * ping using the backoff strategy specified at initialization.
+ *
+ * Note: This method is automatically called once a "complete" event handler
+ * is registered on the operation.
+ *
+ * @private
+ */
+ startPolling_(): void;
+ /**
+ * Wraps the `complete` and `error` events in a Promise.
+ *
+ * @return {promise} - Promise that resolves on operation completion and rejects
+ * on operation error.
+ */
+ promise(): Promise<{}>;
+}
+/**
+ * Method used to create Operation objects.
+ *
+ * @constructor
+ *
+ * @param {google.longrunning.Operation} op - The operation to be wrapped.
+ * @param {LongRunningDescriptor} longrunningDescriptor - This defines the
+ * operations service client and unpacking mechanisms for the operation.
+ * @param {BackoffSettings} backoffSettings - The backoff settings used in
+ * in polling the operation.
+ * @param {CallOptions=} callOptions - CallOptions used in making get operation
+ * requests.
+ */
+export declare function operation(op: Operation, longrunningDescriptor: LongRunningDescriptor, backoffSettings: BackoffSettings, callOptions?: CallOptions): Operation;

build/src/longRunningCalls/longrunning.js

@@ -0,0 +1,269 @@
+"use strict";
+/*
+ * Copyright 2019 Google LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+const events_1 = require("events");
+const grpc_1 = require("grpc");
+const googleError_1 = require("../googleError");
+class Operation extends events_1.EventEmitter {
+ /**
+ * Wrapper for a google.longrunnung.Operation.
+ *
+ * @constructor
+ *
+ * @param {google.longrunning.Operation} grpcOp - The operation to be wrapped.
+ * @param {LongRunningDescriptor} longrunningDescriptor - This defines the
+ * operations service client and unpacking mechanisms for the operation.
+ * @param {BackoffSettings} backoffSettings - The backoff settings used in
+ * in polling the operation.
+ * @param {CallOptions} callOptions - CallOptions used in making get operation
+ * requests.
+ */
+ constructor(grpcOp, longrunningDescriptor, backoffSettings, callOptions) {
+ super();
+ this.completeListeners = 0;
+ this.hasActiveListeners = false;
+ this.latestResponse = grpcOp;
+ this.longrunningDescriptor = longrunningDescriptor;
+ this.result = null;
+ this.metadata = null;
+ this.backoffSettings = backoffSettings;
+ this._unpackResponse(grpcOp);
+ this._listenForEvents();
+ this._callOptions = callOptions;
+ }
+ /**
+ * Begin listening for events on the operation. This method keeps track of how
+ * many "complete" listeners are registered and removed, making sure polling
+ * is handled automatically.
+ *
+ * As long as there is one active "complete" listener, the connection is open.
+ * When there are no more listeners, the polling stops.
+ *
+ * @private
+ */
+ _listenForEvents() {
+ this.on('newListener', event => {
+ if (event === 'complete') {
+ this.completeListeners++;
+ if (!this.hasActiveListeners) {
+ this.hasActiveListeners = true;
+ this.startPolling_();
+ }
+ }
+ });
+ this.on('removeListener', event => {
+ if (event === 'complete' && --this.completeListeners === 0) {
+ this.hasActiveListeners = false;
+ }
+ });
+ }
+ /**
+ * Cancels current polling api call and cancels the operation.
+ *
+ * @return {Promise} the promise of the OperationsClient#cancelOperation api
+ * request.
+ */
+ cancel() {
+ if (this.currentCallPromise_) {
+ this.currentCallPromise_.cancel();
+ }
+ const operationsClient = this.longrunningDescriptor.operationsClient;
+ return operationsClient.cancelOperation({ name: this.latestResponse.name });
+ }
+ getOperation(callback) {
+ const self = this;
+ const operationsClient = this.longrunningDescriptor.operationsClient;
+ function promisifyResponse() {
+ if (!callback) {
+ // tslint:disable-next-line variable-name
+ const PromiseCtor = self._callOptions.promise;
+ return new PromiseCtor((resolve, reject) => {
+ if (self.latestResponse.error) {
+ const error = new googleError_1.GoogleError(self.latestResponse.error.message);
+ error.code = self.latestResponse.error.code;
+ reject(error);
+ }
+ else {
+ resolve([self.result, self.metadata, self.latestResponse]);
+ }
+ });
+ }
+ return;
+ }
+ if (this.latestResponse.done) {
+ this._unpackResponse(this.latestResponse, callback);
+ return promisifyResponse();
+ }
+ this.currentCallPromise_ =
+ operationsClient.getOperation({ name: this.latestResponse.name }, this._callOptions);
+ const noCallbackPromise = this.currentCallPromise_.then(responses => {
+ self.latestResponse = responses[0];
+ self._unpackResponse(responses[0], callback);
+ return promisifyResponse();
+ });
+ if (!callback) {
+ return noCallbackPromise;
+ }
+ }
+ _unpackResponse(op, callback) {
+ const responseDecoder = this.longrunningDescriptor.responseDecoder;
+ const metadataDecoder = this.longrunningDescriptor.metadataDecoder;
+ let response;
+ let metadata;
+ if (op.done) {
+ if (op.result === 'error') {
+ const error = new googleError_1.GoogleError(op.error.message);
+ error.code = op.error.code;
+ if (callback) {
+ callback(error);
+ }
+ return;
+ }
+ if (responseDecoder && op.response) {
+ response = responseDecoder(op.response.value);
+ this.result = response;
+ }
+ }
+ if (metadataDecoder && op.metadata) {
+ metadata = metadataDecoder(op.metadata.value);
+ this.metadata = metadata;
+ }
+ if (callback) {
+ callback(null, response, metadata, op);
+ }
+ }
+ /**
+ * Poll `getOperation` to check the operation's status. This runs a loop to
+ * ping using the backoff strategy specified at initialization.
+ *
+ * Note: This method is automatically called once a "complete" event handler
+ * is registered on the operation.
+ *
+ * @private
+ */
+ startPolling_() {
+ const self = this;
+ let now = new Date();
+ const delayMult = this.backoffSettings.retryDelayMultiplier;
+ const maxDelay = this.backoffSettings.maxRetryDelayMillis;
+ let delay = this.backoffSettings.initialRetryDelayMillis;
+ let deadline = Infinity;
+ if (this.backoffSettings.totalTimeoutMillis) {
+ deadline = now.getTime() + this.backoffSettings.totalTimeoutMillis;
+ }
+ let previousMetadataBytes;
+ if (this.latestResponse.metadata) {
+ previousMetadataBytes = this.latestResponse.metadata.value;
+ }
+ // tslint:disable-next-line no-any
+ function emit(event, ...args) {
+ self.emit(event, ...args);
+ }
+ function retry() {
+ if (!self.hasActiveListeners) {
+ return;
+ }
+ if (now.getTime() >= deadline) {
+ const error = new googleError_1.GoogleError('Total timeout exceeded before any response was received');
+ error.code = grpc_1.status.DEADLINE_EXCEEDED;
+ setImmediate(emit, 'error', error);
+ return;
+ }
+ self.getOperation((err, result, metadata, rawResponse) => {
+ if (err) {
+ setImmediate(emit, 'error', err);
+ return;
+ }
+ if (!result) {
+ if (rawResponse.metadata &&
+ (!previousMetadataBytes ||
+ !rawResponse.metadata.value.equals(previousMetadataBytes))) {
+ setImmediate(emit, 'progress', metadata, rawResponse);
+ previousMetadataBytes = rawResponse.metadata.value;
+ }
+ // special case: some APIs fail to set either result or error
+ // but set done = true (e.g. speech with silent file).
+ // Don't hang forever in this case.
+ if (rawResponse.done) {
+ const error = new googleError_1.GoogleError('Long running operation has finished but there was no result');
+ error.code = grpc_1.status.UNKNOWN;
+ setImmediate(emit, 'error', error);
+ return;
+ }
+ setTimeout(() => {
+ now = new Date();
+ delay = Math.min(delay * delayMult, maxDelay);
+ retry();
+ }, delay);
+ return;
+ }
+ setImmediate(emit, 'complete', result, metadata, rawResponse);
+ });
+ }
+ retry();
+ }
+ /**
+ * Wraps the `complete` and `error` events in a Promise.
+ *
+ * @return {promise} - Promise that resolves on operation completion and rejects
+ * on operation error.
+ */
+ promise() {
+ // tslint:disable-next-line variable-name
+ const PromiseCtor = this._callOptions.promise;
+ return new PromiseCtor((resolve, reject) => {
+ this.on('error', reject)
+ .on('complete', (result, metadata, rawResponse) => {
+ resolve([result, metadata, rawResponse]);
+ });
+ });
+ }
+}
+exports.Operation = Operation;
+/**
+ * Method used to create Operation objects.
+ *
+ * @constructor
+ *
+ * @param {google.longrunning.Operation} op - The operation to be wrapped.
+ * @param {LongRunningDescriptor} longrunningDescriptor - This defines the
+ * operations service client and unpacking mechanisms for the operation.
+ * @param {BackoffSettings} backoffSettings - The backoff settings used in
+ * in polling the operation.
+ * @param {CallOptions=} callOptions - CallOptions used in making get operation
+ * requests.
+ */
+function operation(op, longrunningDescriptor, backoffSettings, callOptions) {
+ return new Operation(op, longrunningDescriptor, backoffSettings, callOptions);
+}
+exports.operation = operation;
+//# sourceMappingURL=longrunning.js.map
\ No newline at end of file

build/src/longRunningCalls/longrunning.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"longrunning.js","sourceRoot":"","sources":["../../../src/longRunningCalls/longrunning.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;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C,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;YAChE,CAAC,CAAC,CAAC;QACL,CAAC;QACD,KAAK,EAAE,CAAC;IACV,CAAC;IAED;;;;;OAKG;IACH,OAAO;QACL,yCAAyC;QACzC,MAAM,WAAW,GAAG,IAAI,CAAC,YAAa,CAAC,OAAQ,CAAC;QAChD,OAAO,IAAI,WAAW,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACzC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC;iBACnB,EAAE,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE;gBAChD,OAAO,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;YAC3C,CAAC,CAAC,CAAC;QACT,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAlRD,8BAkRC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,SAAS,CACrB,EAAa,EAAE,qBAA4C,EAC3D,eAAgC,EAAE,WAAyB;IAC7D,OAAO,IAAI,SAAS,CAAC,EAAE,EAAE,qBAAqB,EAAE,eAAe,EAAE,WAAW,CAAC,CAAC;AAChF,CAAC;AAJD,8BAIC"}
\ No newline at end of file

build/src/longrunning.d.ts

@@ -1,163 +0,0 @@
-/// <reference types="node" />
-import { EventEmitter } from 'events';
-import { APICall, APICallback, CancellablePromise, NormalApiCaller, PromiseCanceller } from './apiCallable';
-import { BackoffSettings, CallOptions } from './gax';
-import { GoogleError } from './GoogleError';
-import { Metadata } from './grpc';
-import { OperationsClient } from './operationsClient';
-/**
- * A callback to upack a google.protobuf.Any message.
- * @callback anyDecoder
- * @param {google.protobuf.Any} message - The message to unpacked.
- * @return {Object} - The unpacked message.
- */
-export interface AnyDecoder {
- (message: {}): Metadata;
-}
-/**
- * @callback GetOperationCallback
- * @param {?Error} error
- * @param {?Object} result
- * @param {?Object} metadata
- * @param {?google.longrunning.Operation} rawResponse
- */
-export interface GetOperationCallback {
- (err?: Error | null, result?: {}, metadata?: {}, rawResponse?: Operation): void;
-}
-export declare class LongrunningDescriptor {
- operationsClient: OperationsClient;
- responseDecoder: AnyDecoder;
- metadataDecoder: AnyDecoder;
- /**
- * Describes the structure of a page-streaming call.
- *
- * @property {OperationsClient} operationsClient
- * @property {anyDecoder} responseDecoder
- * @property {anyDecoder} metadataDecoder
- *
- * @param {OperationsClient} operationsClient - The client used to poll or
- * cancel an operation.
- * @param {anyDecoder=} responseDecoder - The decoder to unpack
- * the response message.
- * @param {anyDecoder=} metadataDecoder - The decoder to unpack
- * the metadata message.
- *
- * @constructor
- */
- constructor(operationsClient: OperationsClient, responseDecoder: AnyDecoder, metadataDecoder: AnyDecoder);
- apiCaller(): LongrunningApiCaller;
-}
-export declare class LongrunningApiCaller extends NormalApiCaller {
- longrunningDescriptor: LongrunningDescriptor;
- /**
- * Creates an API caller that performs polling on a long running operation.
- *
- * @private
- * @constructor
- * @param {LongrunningDescriptor} longrunningDescriptor - Holds the
- * decoders used for unpacking responses and the operationsClient
- * used for polling the operation.
- */
- constructor(longrunningDescriptor: LongrunningDescriptor);
- call(apiCall: APICall, argument: {}, settings: CallOptions, canceller: PromiseCanceller): void;
- _wrapOperation(apiCall: APICall, settings: CallOptions, argument: {}, callback: APICallback): any;
-}
-export declare class Operation extends EventEmitter {
- completeListeners: number;
- hasActiveListeners: boolean;
- latestResponse: Operation;
- longrunningDescriptor: LongrunningDescriptor;
- result: {} | null;
- metadata: Metadata | null;
- backoffSettings: BackoffSettings;
- _callOptions?: CallOptions;
- currentCallPromise_?: CancellablePromise;
- name?: string;
- done?: boolean;
- error?: GoogleError;
- response?: {
- value: {};
- };
- /**
- * Wrapper for a google.longrunnung.Operation.
- *
- * @constructor
- *
- * @param {google.longrunning.Operation} grpcOp - The operation to be wrapped.
- * @param {LongrunningDescriptor} longrunningDescriptor - This defines the
- * operations service client and unpacking mechanisms for the operation.
- * @param {BackoffSettings} backoffSettings - The backoff settings used in
- * in polling the operation.
- * @param {CallOptions=} callOptions - CallOptions used in making get operation
- * requests.
- */
- constructor(grpcOp: Operation, longrunningDescriptor: LongrunningDescriptor, backoffSettings: BackoffSettings, callOptions?: CallOptions);
- /**
- * Begin listening for events on the operation. This method keeps track of how
- * many "complete" listeners are registered and removed, making sure polling
- * is handled automatically.
- *
- * As long as there is one active "complete" listener, the connection is open.
- * When there are no more listeners, the polling stops.
- *
- * @private
- */
- _listenForEvents(): void;
- /**
- * Cancels current polling api call and cancels the operation.
- *
- * @return {Promise} the promise of the OperationsClient#cancelOperation api
- * request.
- */
- cancel(): any;
- /**
- * Get the updated status of the operation. If the Operation has previously
- * completed, this will use the status of the cached completed operation.
- *
- * - callback(err): Operation failed
- * - callback(null, result, metadata, rawResponse): Operation complete
- * - callback(null, null, metadata, rawResponse): Operation incomplete
- *
- * @param {getOperationCallback} callback - Callback to handle the polled
- * operation result and metadata.
- * @return {Promise|undefined} - This returns a promise if a callback is not specified.
- * The promise resolves to an array where the first element is the unpacked
- * result, the second element is the metadata, and the third element is the
- * raw response of the api call. The promise rejects if the operation returns
- * an error.
- */
- getOperation(): Promise<{}>;
- getOperation(callback: GetOperationCallback): void;
- _unpackResponse(op: Operation, callback?: GetOperationCallback): void;
- /**
- * Poll `getOperation` to check the operation's status. This runs a loop to
- * ping using the backoff strategy specified at initialization.
- *
- * Note: This method is automatically called once a "complete" event handler
- * is registered on the operation.
- *
- * @private
- */
- startPolling_(): void;
- /**
- * Wraps the `complete` and `error` events in a Promise.
- *
- * @return {promise} - Promise that resolves on operation completion and rejects
- * on operation error.
- */
- promise(): Promise<{}>;
-}
-/**
- * Method used to create Operation objects.
- *
- * @constructor
- *
- * @param {google.longrunning.Operation} op - The operation to be wrapped.
- * @param {LongrunningDescriptor} longrunningDescriptor - This defines the
- * operations service client and unpacking mechanisms for the operation.
- * @param {BackoffSettings} backoffSettings - The backoff settings used in
- * in polling the operation.
- * @param {CallOptions=} callOptions - CallOptions used in making get operation
- * requests.
- */
-export declare function operation(op: Operation, longrunningDescriptor: LongrunningDescriptor, backoffSettings: BackoffSettings, callOptions?: CallOptions): Operation;

build/src/longrunning.js

@@ -1,336 +0,0 @@
-"use strict";
-/*
- * Copyright 2016, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-Object.defineProperty(exports, "__esModule", { value: true });
-const events_1 = require("events");
-const grpc_1 = require("grpc");
-const apiCallable_1 = require("./apiCallable");
-const gax_1 = require("./gax");
-const GoogleError_1 = require("./GoogleError");
-class LongrunningDescriptor {
- /**
- * Describes the structure of a page-streaming call.
- *
- * @property {OperationsClient} operationsClient
- * @property {anyDecoder} responseDecoder
- * @property {anyDecoder} metadataDecoder
- *
- * @param {OperationsClient} operationsClient - The client used to poll or
- * cancel an operation.
- * @param {anyDecoder=} responseDecoder - The decoder to unpack
- * the response message.
- * @param {anyDecoder=} metadataDecoder - The decoder to unpack
- * the metadata message.
- *
- * @constructor
- */
- constructor(operationsClient, responseDecoder, metadataDecoder) {
- this.operationsClient = operationsClient;
- this.responseDecoder = responseDecoder;
- this.metadataDecoder = metadataDecoder;
- }
- apiCaller() {
- return new LongrunningApiCaller(this);
- }
-}
-exports.LongrunningDescriptor = LongrunningDescriptor;
-class LongrunningApiCaller extends apiCallable_1.NormalApiCaller {
- /**
- * Creates an API caller that performs polling on a long running operation.
- *
- * @private
- * @constructor
- * @param {LongrunningDescriptor} longrunningDescriptor - Holds the
- * decoders used for unpacking responses and the operationsClient
- * used for polling the operation.
- */
- constructor(longrunningDescriptor) {
- super();
- this.longrunningDescriptor = longrunningDescriptor;
- }
- call(apiCall, argument, settings, canceller) {
- canceller.call((argument, callback) => {
- return this._wrapOperation(apiCall, settings, argument, callback);
- }, argument);
- }
- _wrapOperation(apiCall, settings, argument, callback) {
- // TODO: this code defies all logic, and just can't be accurate.
- // tslint:disable-next-line no-any
- let backoffSettings = settings.longrunning;
- if (!backoffSettings) {
- backoffSettings =
- gax_1.createBackoffSettings(100, 1.3, 60000, null, null, null, null);
- }
- const longrunningDescriptor = this.longrunningDescriptor;
- return apiCall(argument, (err, rawResponse) => {
- if (err) {
- callback(err, null, rawResponse);
- return;
- }
- const operation = new Operation(rawResponse, longrunningDescriptor, backoffSettings, settings);
- callback(null, operation, rawResponse);
- });
- }
-}
-exports.LongrunningApiCaller = LongrunningApiCaller;
-class Operation extends events_1.EventEmitter {
- /**
- * Wrapper for a google.longrunnung.Operation.
- *
- * @constructor
- *
- * @param {google.longrunning.Operation} grpcOp - The operation to be wrapped.
- * @param {LongrunningDescriptor} longrunningDescriptor - This defines the
- * operations service client and unpacking mechanisms for the operation.
- * @param {BackoffSettings} backoffSettings - The backoff settings used in
- * in polling the operation.
- * @param {CallOptions=} callOptions - CallOptions used in making get operation
- * requests.
- */
- constructor(grpcOp, longrunningDescriptor, backoffSettings, callOptions) {
- super();
- this.completeListeners = 0;
- this.hasActiveListeners = false;
- this.latestResponse = grpcOp;
- this.longrunningDescriptor = longrunningDescriptor;
- this.result = null;
- this.metadata = null;
- this.backoffSettings = backoffSettings;
- this._unpackResponse(grpcOp);
- this._listenForEvents();
- this._callOptions = callOptions;
- }
- /**
- * Begin listening for events on the operation. This method keeps track of how
- * many "complete" listeners are registered and removed, making sure polling
- * is handled automatically.
- *
- * As long as there is one active "complete" listener, the connection is open.
- * When there are no more listeners, the polling stops.
- *
- * @private
- */
- _listenForEvents() {
- this.on('newListener', event => {
- if (event === 'complete') {
- this.completeListeners++;
- if (!this.hasActiveListeners) {
- this.hasActiveListeners = true;
- this.startPolling_();
- }
- }
- });
- this.on('removeListener', event => {
- if (event === 'complete' && --this.completeListeners === 0) {
- this.hasActiveListeners = false;
- }
- });
- }
- /**
- * Cancels current polling api call and cancels the operation.
- *
- * @return {Promise} the promise of the OperationsClient#cancelOperation api
- * request.
- */
- cancel() {
- if (this.currentCallPromise_) {
- this.currentCallPromise_.cancel();
- }
- const operationsClient = this.longrunningDescriptor.operationsClient;
- return operationsClient.cancelOperation({ name: this.latestResponse.name });
- }
- getOperation(callback) {
- const self = this;
- const operationsClient = this.longrunningDescriptor.operationsClient;
- function promisifyResponse() {
- if (!callback) {
- // tslint:disable-next-line variable-name
- const PromiseCtor = self._callOptions.promise;
- return new PromiseCtor((resolve, reject) => {
- if (self.latestResponse.error) {
- const error = new GoogleError_1.GoogleError(self.latestResponse.error.message);
- error.code = self.latestResponse.error.code;
- reject(error);
- }
- else {
- resolve([self.result, self.metadata, self.latestResponse]);
- }
- });
- }
- return;
- }
- if (this.latestResponse.done) {
- this._unpackResponse(this.latestResponse, callback);
- return promisifyResponse();
- }
- this.currentCallPromise_ = operationsClient.getOperation({ name: this.latestResponse.name }, this._callOptions);
- const noCallbackPromise = this.currentCallPromise_.then(responses => {
- self.latestResponse = responses[0];
- self._unpackResponse(responses[0], callback);
- return promisifyResponse();
- });
- if (!callback) {
- return noCallbackPromise;
- }
- }
- _unpackResponse(op, callback) {
- const responseDecoder = this.longrunningDescriptor.responseDecoder;
- const metadataDecoder = this.longrunningDescriptor.metadataDecoder;
- let response;
- let metadata;
- if (op.done) {
- if (op.result === 'error') {
- const error = new GoogleError_1.GoogleError(op.error.message);
- error.code = op.error.code;
- if (callback) {
- callback(error);
- }
- return;
- }
- if (responseDecoder && op.response) {
- response = responseDecoder(op.response.value);
- this.result = response;
- }
- }
- if (metadataDecoder && op.metadata) {
- metadata = metadataDecoder(op.metadata.value);
- this.metadata = metadata;
- }
- if (callback) {
- callback(null, response, metadata, op);
- }
- }
- /**
- * Poll `getOperation` to check the operation's status. This runs a loop to
- * ping using the backoff strategy specified at initialization.
- *
- * Note: This method is automatically called once a "complete" event handler
- * is registered on the operation.
- *
- * @private
- */
- startPolling_() {
- const self = this;
- let now = new Date();
- const delayMult = this.backoffSettings.retryDelayMultiplier;
- const maxDelay = this.backoffSettings.maxRetryDelayMillis;
- let delay = this.backoffSettings.initialRetryDelayMillis;
- let deadline = Infinity;
- if (this.backoffSettings.totalTimeoutMillis) {
- deadline = now.getTime() + this.backoffSettings.totalTimeoutMillis;
- }
- let previousMetadataBytes;
- if (this.latestResponse.metadata) {
- previousMetadataBytes = this.latestResponse.metadata.value;
- }
- // tslint:disable-next-line no-any
- function emit(event, ...args) {
- self.emit(event, ...args);
- }
- function retry() {
- if (!self.hasActiveListeners) {
- return;
- }
- if (now.getTime() >= deadline) {
- const error = new GoogleError_1.GoogleError('Total timeout exceeded before any response was received');
- error.code = grpc_1.status.DEADLINE_EXCEEDED;
- setImmediate(emit, 'error', error);
- return;
- }
- self.getOperation((err, result, metadata, rawResponse) => {
- if (err) {
- setImmediate(emit, 'error', err);
- return;
- }
- if (!result) {
- if (rawResponse.metadata &&
- (!previousMetadataBytes ||
- !rawResponse.metadata.value.equals(previousMetadataBytes))) {
- setImmediate(emit, 'progress', metadata, rawResponse);
- previousMetadataBytes = rawResponse.metadata.value;
- }
- // special case: some APIs fail to set either result or error
- // but set done = true (e.g. speech with silent file).
- // Don't hang forever in this case.
- if (rawResponse.done) {
- const error = new GoogleError_1.GoogleError('Long running operation has finished but there was no result');
- error.code = grpc_1.status.UNKNOWN;
- setImmediate(emit, 'error', error);
- return;
- }
- setTimeout(() => {
- now = new Date();
- delay = Math.min(delay * delayMult, maxDelay);
- retry();
- }, delay);
- return;
- }
- setImmediate(emit, 'complete', result, metadata, rawResponse);
- });
- }
- retry();
- }
- /**
- * Wraps the `complete` and `error` events in a Promise.
- *
- * @return {promise} - Promise that resolves on operation completion and rejects
- * on operation error.
- */
- promise() {
- // tslint:disable-next-line variable-name
- const PromiseCtor = this._callOptions.promise;
- return new PromiseCtor((resolve, reject) => {
- this.on('error', reject)
- .on('complete', (result, metadata, rawResponse) => {
- resolve([result, metadata, rawResponse]);
- });
- });
- }
-}
-exports.Operation = Operation;
-/**
- * Method used to create Operation objects.
- *
- * @constructor
- *
- * @param {google.longrunning.Operation} op - The operation to be wrapped.
- * @param {LongrunningDescriptor} longrunningDescriptor - This defines the
- * operations service client and unpacking mechanisms for the operation.
- * @param {BackoffSettings} backoffSettings - The backoff settings used in
- * in polling the operation.
- * @param {CallOptions=} callOptions - CallOptions used in making get operation
- * requests.
- */
-function operation(op, longrunningDescriptor, backoffSettings, callOptions) {
- return new Operation(op, longrunningDescriptor, backoffSettings, callOptions);
-}
-exports.operation = operation;
-//# sourceMappingURL=longrunning.js.map
\ No newline at end of file

build/src/longrunning.js.map

@@ -1 +0,0 @@
-{"version":3,"file":"longrunning.js","sourceRoot":"","sources":["../../src/longrunning.ts"],"names":[],"mappings":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iCaller';
+import { APICallback, GRPCCall, SimpleCallbackFunction } from '../apitypes';
+import { OngoingCall, OngoingCallPromise } from '../call';
+import { GoogleError } from '../googleError';
+/**
+ * Creates an API caller for regular unary methods.
+ */
+export declare class NormalApiCaller implements APICaller {
+ init(settings: ApiCallerSettings, callback?: APICallback): OngoingCallPromise | OngoingCall;
+ wrap(func: GRPCCall): GRPCCall;
+ call(apiCall: SimpleCallbackFunction, argument: {}, settings: {}, canceller: OngoingCallPromise): void;
+ fail(canceller: OngoingCallPromise, err: GoogleError): void;
+ result(canceller: OngoingCallPromise): import("../call").CancellablePromise<[import("../apitypes").ResponseType, {
+ [index: string]: string;
+ } | null | undefined, {} | import("..").Operation | undefined]>;
+}

build/src/normalCalls/normalApiCaller.js

@@ -0,0 +1,28 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+const call_1 = require("../call");
+/**
+ * Creates an API caller for regular unary methods.
+ */
+class NormalApiCaller {
+ init(settings, callback) {
+ if (callback) {
+ return new call_1.OngoingCall(callback);
+ }
+ return new call_1.OngoingCallPromise(settings.promise);
+ }
+ wrap(func) {
+ return func;
+ }
+ call(apiCall, argument, settings, canceller) {
+ canceller.call(apiCall, argument);
+ }
+ fail(canceller, err) {
+ canceller.callback(err);
+ }
+ result(canceller) {
+ return canceller.promise;
+ }
+}
+exports.NormalApiCaller = NormalApiCaller;
+//# sourceMappingURL=normalApiCaller.js.map
\ No newline at end of file

build/src/normalCalls/normalApiCaller.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"normalApiCaller.js","sourceRoot":"","sources":["../../../src/normalCalls/normalApiCaller.ts"],"names":[],"mappings":";;AAgCA,kCAAwD;AAGxD;;GAEG;AACH,MAAa,eAAe;IAC1B,IAAI,CAAC,QAA2B,EAAE,QAAsB;QAEtD,IAAI,QAAQ,EAAE;YACZ,OAAO,IAAI,kBAAW,CAAC,QAAQ,CAAC,CAAC;SAClC;QACD,OAAO,IAAI,yBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;IAED,IAAI,CAAC,IAAc;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CACA,OAA+B,EAAE,QAAY,EAAE,QAAY,EAC3D,SAA6B;QAC/B,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED,IAAI,CAAC,SAA6B,EAAE,GAAgB;QAClD,SAAS,CAAC,QAAS,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,SAA6B;QAClC,OAAO,SAAS,CAAC,OAAO,CAAC;IAC3B,CAAC;CACF;AA1BD,0CA0BC"}
\ No newline at end of file

build/src/normalCalls/retries.d.ts

@@ -0,0 +1,16 @@
+import { GRPCCall, GRPCCallOtherArgs, SimpleCallbackFunction } from '../apitypes';
+import { RetryOptions } from '../gax';
+/**
+ * Creates a function equivalent to func, but that retries on certain
+ * exceptions.
+ *
+ * @private
+ *
+ * @param {GRPCCall} func - A function.
+ * @param {RetryOptions} retry - Configures the exceptions upon which the
+ * function eshould retry, and the parameters to the exponential backoff retry
+ * algorithm.
+ * @param {GRPCCallOtherArgs} otherArgs - the additional arguments to be passed to func.
+ * @return {SimpleCallbackFunction} A function that will retry.
+ */
+export declare function retryable(func: GRPCCall, retry: RetryOptions, otherArgs: GRPCCallOtherArgs): SimpleCallbackFunction;

build/src/normalCalls/retries.js

@@ -0,0 +1,143 @@
+"use strict";
+/*
+ * Copyright 2019 Google LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+const grpc_1 = require("grpc");
+const googleError_1 = require("../googleError");
+const timeout_1 = require("./timeout");
+/**
+ * Creates a function equivalent to func, but that retries on certain
+ * exceptions.
+ *
+ * @private
+ *
+ * @param {GRPCCall} func - A function.
+ * @param {RetryOptions} retry - Configures the exceptions upon which the
+ * function eshould retry, and the parameters to the exponential backoff retry
+ * algorithm.
+ * @param {GRPCCallOtherArgs} otherArgs - the additional arguments to be passed to func.
+ * @return {SimpleCallbackFunction} A function that will retry.
+ */
+function retryable(func, retry, otherArgs) {
+ const delayMult = retry.backoffSettings.retryDelayMultiplier;
+ const maxDelay = retry.backoffSettings.maxRetryDelayMillis;
+ const timeoutMult = retry.backoffSettings.rpcTimeoutMultiplier;
+ const maxTimeout = retry.backoffSettings.maxRpcTimeoutMillis;
+ let delay = retry.backoffSettings.initialRetryDelayMillis;
+ let timeout = retry.backoffSettings.initialRpcTimeoutMillis;
+ /**
+ * Equivalent to ``func``, but retries upon transient failure.
+ *
+ * Retrying is done through an exponential backoff algorithm configured
+ * by the options in ``retry``.
+ * @param {RequestType} argument The request object.
+ * @param {APICallback} callback The callback.
+ * @return {GRPCCall}
+ */
+ return (argument, callback) => {
+ let canceller;
+ let timeoutId;
+ let now = new Date();
+ let deadline;
+ if (retry.backoffSettings.totalTimeoutMillis) {
+ deadline = now.getTime() + retry.backoffSettings.totalTimeoutMillis;
+ }
+ let retries = 0;
+ const maxRetries = retry.backoffSettings.maxRetries;
+ // TODO: define A/B testing values for retry behaviors.
+ /** Repeat the API call as long as necessary. */
+ function repeat() {
+ timeoutId = null;
+ if (deadline && now.getTime() >= deadline) {
+ const error = new googleError_1.GoogleError('Retry total timeout exceeded before any response was received');
+ error.code = grpc_1.status.DEADLINE_EXCEEDED;
+ callback(error);
+ return;
+ }
+ if (retries && retries >= maxRetries) {
+ const error = new googleError_1.GoogleError('Exceeded maximum number of retries before any ' +
+ 'response was received');
+ error.code = grpc_1.status.DEADLINE_EXCEEDED;
+ callback(error);
+ return;
+ }
+ retries++;
+ const toCall = timeout_1.addTimeoutArg(func, timeout, otherArgs);
+ canceller = toCall(argument, (err, response, next, rawResponse) => {
+ if (!err) {
+ callback(null, response, next, rawResponse);
+ return;
+ }
+ canceller = null;
+ if (retry.retryCodes.indexOf(err.code) < 0) {
+ err.note = 'Exception occurred in retry method that was ' +
+ 'not classified as transient';
+ callback(err);
+ }
+ else {
+ const toSleep = Math.random() * delay;
+ timeoutId = setTimeout(() => {
+ now = new Date();
+ delay = Math.min(delay * delayMult, maxDelay);
+ timeout = Math.min(timeout * timeoutMult, maxTimeout, deadline - now.getTime());
+ repeat();
+ }, toSleep);
+ }
+ });
+ }
+ if (maxRetries && deadline) {
+ const error = new googleError_1.GoogleError('Cannot set both totalTimeoutMillis and maxRetries ' +
+ 'in backoffSettings.');
+ error.code = grpc_1.status.INVALID_ARGUMENT;
+ callback(error);
+ }
+ else {
+ repeat();
+ }
+ return {
+ cancel() {
+ if (timeoutId) {
+ clearTimeout(timeoutId);
+ }
+ if (canceller) {
+ canceller.cancel();
+ }
+ else {
+ const error = new googleError_1.GoogleError('cancelled');
+ error.code = grpc_1.status.CANCELLED;
+ callback(error);
+ }
+ },
+ };
+ };
+}
+exports.retryable = retryable;
+//# sourceMappingURL=retries.js.map
\ No newline at end of file

build/src/normalCalls/retries.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"retries.js","sourceRoot":"","sources":["../../../src/normalCalls/retries.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAEH,+BAA4B;AAI5B,gDAA2C;AAE3C,uCAAwC;AAExC;;;;;;;;;;;;GAYG;AACH,SAAgB,SAAS,CACrB,IAAc,EAAE,KAAmB,EACnC,SAA4B;IAC9B,MAAM,SAAS,GAAG,KAAK,CAAC,eAAe,CAAC,oBAAoB,CAAC;IAC7D,MAAM,QAAQ,GAAG,KAAK,CAAC,eAAe,CAAC,mBAAmB,CAAC;IAC3D,MAAM,WAAW,GAAG,KAAK,CAAC,eAAe,CAAC,oBAAoB,CAAC;IAC/D,MAAM,UAAU,GAAG,KAAK,CAAC,eAAe,CAAC,mBAAmB,CAAC;IAE7D,IAAI,KAAK,GAAG,KAAK,CAAC,eAAe,CAAC,uBAAuB,CAAC;IAC1D,IAAI,OAAO,GAAG,KAAK,CAAC,eAAe,CAAC,uBAAuB,CAAC;IAE5D;;;;;;;;OAQG;IACH,OAAO,CAAC,QAAqB,EAAE,QAAqB,EAAE,EAAE;QACtD,IAAI,SAA8B,CAAC;QACnC,IAAI,SAA4B,CAAC;QACjC,IAAI,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,QAAgB,CAAC;QACrB,IAAI,KAAK,CAAC,eAAe,CAAC,kBAAkB,EAAE;YAC5C,QAAQ,GAAG,GAAG,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC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Args, SimpleCallbackFunction } from '../apitypes';
+/**
+ * Updates func so that it gets called with the timeout as its final arg.
+ *
+ * This converts a function, func, into another function with updated deadline.
+ *
+ * @private
+ *
+ * @param {GRPCCall} func - a function to be updated.
+ * @param {number} timeout - to be added to the original function as it final
+ * positional arg.
+ * @param {Object} otherArgs - the additional arguments to be passed to func.
+ * @param {Object=} abTests - the A/B testing key/value pairs.
+ * @return {function(Object, APICallback)}
+ * the function with other arguments and the timeout.
+ */
+export declare function addTimeoutArg(func: GRPCCall, timeout: number, otherArgs: GRPCCallOtherArgs, abTests?: {}): SimpleCallbackFunction;

build/src/normalCalls/timeout.js

@@ -0,0 +1,62 @@
+"use strict";
+/*
+ * Copyright 2019 Google LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+/**
+ * Updates func so that it gets called with the timeout as its final arg.
+ *
+ * This converts a function, func, into another function with updated deadline.
+ *
+ * @private
+ *
+ * @param {GRPCCall} func - a function to be updated.
+ * @param {number} timeout - to be added to the original function as it final
+ * positional arg.
+ * @param {Object} otherArgs - the additional arguments to be passed to func.
+ * @param {Object=} abTests - the A/B testing key/value pairs.
+ * @return {function(Object, APICallback)}
+ * the function with other arguments and the timeout.
+ */
+function addTimeoutArg(func, timeout, otherArgs, abTests) {
+ // TODO: this assumes the other arguments consist of metadata and options,
+ // which is specific to gRPC calls. Remove the hidden dependency on gRPC.
+ return (argument, callback) => {
+ const now = new Date();
+ const options = otherArgs.options || {};
+ options.deadline = new Date(now.getTime() + timeout);
+ const metadata = otherArgs.metadataBuilder ?
+ otherArgs.metadataBuilder(abTests, otherArgs.headers || {}) :
+ null;
+ return func(argument, metadata, options, callback);
+ };
+}
+exports.addTimeoutArg = addTimeoutArg;
+//# sourceMappingURL=timeout.js.map
\ No newline at end of file

build/src/normalCalls/timeout.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"timeout.js","sourceRoot":"","sources":["../../../src/normalCalls/timeout.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAIH;;;;;;;;;;;;;;GAcG;AACH,SAAgB,aAAa,CACzB,IAAc,EAAE,OAAe,EAAE,SAA4B,EAC7D,OAAY;IACd,0EAA0E;IAC1E,yEAAyE;IACzE,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE;QAC5B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,IAAI,EAAE,CAAC;QACxC,OAAO,CAAC,QAAQ,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC;QACrD,MAAM,QAAQ,GAAG,SAAS,CAAC,eAAe,CAAC,CAAC;YACxC,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC;YAC7D,IAAI,CAAC;QACT,OAAQ,IAAkB,CAAC,QAAQ,EAAE,QAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACrE,CAAC,CAAC;AACJ,CAAC;AAdD,sCAcC"}
\ No newline at end of file

build/src/operationsClient.d.ts

@@ -1,3 +1,4 @@
+/// <reference types="node" />
import { GoogleAuth } from 'google-auth-library';
import { ProjectIdCallback } from 'google-auth-library/build/src/auth/googleauth';
import * as gax from './gax';
@@ -76,7 +77,9 @@
* const [response] = await client.getOperation({name});
* // doThingsWith(response)
*/
- getOperation(request: {}, options: {}, callback?: any): any;
+ getOperation(request: {}, options: {}, callback?: any): import("./call").CancellablePromise<[import("./apitypes").ResponseType, {
+ [index: string]: string;
+ } | null | undefined, {} | import(".").Operation | undefined]> | import("./apitypes").CancellableStream;
/**
* Lists operations that match the specified filter in the request. If the
* server doesn't support this method, it returns `UNIMPLEMENTED`.
@@ -154,7 +157,9 @@
* }
* };
*/
- listOperations(request: any, options: any, callback: any): any;
+ listOperations(request: any, options: any, callback: any): import("./call").CancellablePromise<[import("./apitypes").ResponseType, {
+ [index: string]: string;
+ } | null | undefined, {} | import(".").Operation | undefined]> | import("./apitypes").CancellableStream;
/**
* Equivalent to {@link listOperations}, but returns a NodeJS Stream object.
*
@@ -199,7 +204,7 @@
* console.error(err);
* });
*/
- listOperationsStream(request: any, options?: {}): any;
+ listOperationsStream(request: {}, options: gax.CallSettings): import("stream").Transform;
/**
* Starts asynchronous cancellation on a long-running operation. The server
* makes a best effort to cancel the operation, but success is not
@@ -230,7 +235,9 @@
* const client = longrunning.operationsClient();
* await client.cancelOperation({name: ''});
*/
- cancelOperation(request: any, options?: any, callback?: any): any;
+ cancelOperation(request: any, options?: any, callback?: any): import("./call").CancellablePromise<[import("./apitypes").ResponseType, {
+ [index: string]: string;
+ } | null | undefined, {} | import(".").Operation | undefined]> | import("./apitypes").CancellableStream;
/**
* Deletes a long-running operation. This method indicates that the client is
* no longer interested in the operation result. It does not cancel the
@@ -255,7 +262,9 @@
* const client = longrunning.operationsClient();
* await client.deleteOperation({name: ''});
*/
- deleteOperation(request: any, options: any, callback: any): any;
+ deleteOperation(request: any, options: any, callback: any): import("./call").CancellablePromise<[import("./apitypes").ResponseType, {
+ [index: string]: string;
+ } | null | undefined, {} | import(".").Operation | undefined]> | import("./apitypes").CancellableStream;
}
export declare class OperationsClientBuilder {
operationsClient: (opts: OperationsClientOptions) => OperationsClient;

build/src/operationsClient.js

@@ -1,34 +1,45 @@
"use strict";
/*
- * Copyright 2018 Google LLC. All rights reserved.
+ * Copyright 2019 Google LLC
+ * All rights reserved.
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
Object.defineProperty(exports, "__esModule", { value: true });
-const google_proto_files_1 = require("google-proto-files");
-const apiCallable = require("./apiCallable");
-const gax = require("./gax");
-const pagedIteration = require("./pagedIteration");
-const pathTemplate = require("./pathTemplate");
+const path = require("path");
+const createApiCall_1 = require("./createApiCall");
+const descriptor_1 = require("./descriptor");
const configData = require('./operations_client_config');
-Object.assign(gax, apiCallable);
-Object.assign(gax, pathTemplate);
-Object.assign(gax, pagedIteration);
exports.SERVICE_ADDRESS = 'longrunning.googleapis.com';
+const version = require('../../package.json').version;
const DEFAULT_SERVICE_PORT = 443;
const CODE_GEN_NAME_VERSION = 'gapic/0.7.1';
const PAGE_DESCRIPTORS = {
- listOperations: new gax['PageDescriptor']('pageToken', 'nextPageToken', 'operations'),
+ listOperations: new descriptor_1.PageDescriptor('pageToken', 'nextPageToken', 'operations'),
};
/**
* The scopes needed to make gRPC calls to all of the methods defined in
@@ -66,7 +77,7 @@
if (opts.libName && opts.libVersion) {
googleApiClient.push(opts.libName + '/' + opts.libVersion);
}
- googleApiClient.push(CODE_GEN_NAME_VERSION, 'gax/' + gax['version'], 'grpc/' + gaxGrpc.grpcVersion);
+ googleApiClient.push(CODE_GEN_NAME_VERSION, 'gax/' + version, 'grpc/' + gaxGrpc.grpcVersion);
const defaults = gaxGrpc.constructSettings('google.longrunning.Operations', configData, opts.clientConfig, { 'x-goog-api-client': googleApiClient.join(' ') });
this.auth = gaxGrpc.auth;
const operationsStub = gaxGrpc.createStub(grpcClients.google.longrunning.Operations, opts);
@@ -77,7 +88,7 @@
'deleteOperation',
];
operationsStubMethods.forEach(methodName => {
- this['_' + methodName] = gax['createApiCall'](operationsStub.then(operationsStub => {
+ this['_' + methodName] = createApiCall_1.createApiCall(operationsStub.then(operationsStub => {
return (...args) => {
return operationsStub[methodName].apply(operationsStub, args);
};
@@ -256,7 +267,7 @@
* console.error(err);
* });
*/
- listOperationsStream(request, options = {}) {
+ listOperationsStream(request, options) {
return PAGE_DESCRIPTORS.listOperations.createStream(this._listOperations, request, options);
}
/**
@@ -337,7 +348,7 @@
* @param gaxGrpc {GrpcClient}
*/
constructor(gaxGrpc) {
- const protoFilesRoot = google_proto_files_1.getProtoPath('..');
+ const protoFilesRoot = path.join(__dirname, '..', '..');
// tslint:disable-next-line no-any
const operationsClient = gaxGrpc.loadProto(protoFilesRoot, 'google/longrunning/operations.proto');
Object.assign(this, operationsClient.google.longrunning);

build/src/operationsClient.js.map

@@ -1 +1 @@
-{"version":3,"file":"operationsClient.js","sourceRoot":"","sources":["../../src/operationsClient.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAIH,2DAAgD;AAEhD,6CAA6C;AAC7C,6BAA6B;AAE7B,mDAAmD;AACnD,+CAA+C;AAE/C,MAAM,UAAU,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAEzD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC,CAA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,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAEzD;;;;;;;;WAQG;QACH,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,EAAE;YAC7B,OAAO,IAAI,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAC;QAC/D,CAAC,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;IACzD,CAAC;CACF;AA5BD,0DA4BC"}
\ No newline at end of file

build/src/pagedIteration.d.ts

@@ -1,92 +0,0 @@
-/**
- * Copyright 2016, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/// <reference types="node" />
-import { Transform } from 'stream';
-import { APICall, APICallback, NormalApiCaller, NormalApiCallerSettings } from './apiCallable';
-export declare class PagedIteration extends NormalApiCaller {
- pageDescriptor: PageDescriptor;
- /**
- * Creates an API caller that returns a stream to performs page-streaming.
- *
- * @private
- * @constructor
- * @param {PageDescriptor} pageDescriptor - indicates the structure
- * of page streaming to be performed.
- */
- constructor(pageDescriptor: PageDescriptor);
- createActualCallback(request: {
- [index: string]: {};
- }, callback: APICallback): (err: Error | null, response: {
- [index: string]: {};
- }) => void;
- wrap(func: Function): (argument: any, metadata: any, options: any, callback: any) => any;
- init(settings: NormalApiCallerSettings, callback: APICallback): import("./apiCallable").PromiseCanceller<any> | import("./apiCallable").Canceller;
- call(apiCall: APICall, argument: {
- [index: string]: {};
- }, settings: any, canceller: any): void;
-}
-export declare class PageDescriptor {
- requestPageTokenField: string;
- responsePageTokenField: string;
- requestPageSizeField?: string;
- resourceField: string;
- /**
- * Describes the structure of a page-streaming call.
- *
- * @property {String} requestPageTokenField
- * @property {String} responsePageTokenField
- * @property {String} resourceField
- *
- * @param {String} requestPageTokenField - The field name of the page token in
- * the request.
- * @param {String} responsePageTokenField - The field name of the page token in
- * the response.
- * @param {String} resourceField - The resource field name.
- *
- * @constructor
- */
- constructor(requestPageTokenField: string, responsePageTokenField: string, resourceField: string);
- /**
- * Creates a new object Stream which emits the resource on 'data' event.
- * @private
- * @param {ApiCall} apiCall - the callable object.
- * @param {Object} request - the request object.
- * @param {CallOptions=} options - the call options to customize the api call.
- * @return {Stream} - a new object Stream.
- */
- createStream(apiCall: APICall, request: any, options: any): Transform;
- /**
- * Returns a new API caller.
- * @private
- * @return {PageStreamable} - the page streaming caller.
- */
- apiCaller(): PagedIteration;
-}

build/src/pagedIteration.js

@@ -1,203 +0,0 @@
-"use strict";
-/**
- * Copyright 2016, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-Object.defineProperty(exports, "__esModule", { value: true });
-const ended = require("is-stream-ended");
-const stream_1 = require("stream");
-const apiCallable_1 = require("./apiCallable");
-class PagedIteration extends apiCallable_1.NormalApiCaller {
- /**
- * Creates an API caller that returns a stream to performs page-streaming.
- *
- * @private
- * @constructor
- * @param {PageDescriptor} pageDescriptor - indicates the structure
- * of page streaming to be performed.
- */
- constructor(pageDescriptor) {
- super();
- this.pageDescriptor = pageDescriptor;
- }
- createActualCallback(request, callback) {
- const self = this;
- return function fetchNextPageToken(err, response) {
- if (err) {
- callback(err);
- return;
- }
- const resources = response[self.pageDescriptor.resourceField];
- const pageToken = response[self.pageDescriptor.responsePageTokenField];
- if (pageToken) {
- request[self.pageDescriptor.requestPageTokenField] = pageToken;
- callback(err, resources, request, response);
- }
- else {
- callback(err, resources, null, response);
- }
- };
- }
- wrap(func) {
- const self = this;
- return function wrappedCall(argument, metadata, options, callback) {
- return func(argument, metadata, options, self.createActualCallback(argument, callback));
- };
- }
- init(settings, callback) {
- return super.init(settings, callback);
- }
- call(apiCall, argument, settings, canceller) {
- argument = Object.assign({}, argument);
- if (settings.pageToken) {
- argument[this.pageDescriptor.requestPageTokenField] = settings.pageToken;
- }
- if (settings.pageSize) {
- argument[this.pageDescriptor.requestPageSizeField] = settings.pageSize;
- }
- if (!settings.autoPaginate) {
- apiCallable_1.NormalApiCaller.prototype.call.call(this, apiCall, argument, settings, canceller);
- return;
- }
- const maxResults = settings.maxResults || -1;
- const allResources = [];
- function pushResources(err, resources, next) {
- if (err) {
- canceller.callback(err);
- return;
- }
- for (let i = 0; i < resources.length; ++i) {
- allResources.push(resources[i]);
- if (allResources.length === maxResults) {
- next = null;
- break;
- }
- }
- if (!next) {
- canceller.callback(null, allResources);
- return;
- }
- setImmediate(apiCall, next, pushResources);
- }
- setImmediate(apiCall, argument, pushResources);
- }
-}
-exports.PagedIteration = PagedIteration;
-class PageDescriptor {
- /**
- * Describes the structure of a page-streaming call.
- *
- * @property {String} requestPageTokenField
- * @property {String} responsePageTokenField
- * @property {String} resourceField
- *
- * @param {String} requestPageTokenField - The field name of the page token in
- * the request.
- * @param {String} responsePageTokenField - The field name of the page token in
- * the response.
- * @param {String} resourceField - The resource field name.
- *
- * @constructor
- */
- constructor(requestPageTokenField, responsePageTokenField, resourceField) {
- this.requestPageTokenField = requestPageTokenField;
- this.responsePageTokenField = responsePageTokenField;
- this.resourceField = resourceField;
- }
- /**
- * Creates a new object Stream which emits the resource on 'data' event.
- * @private
- * @param {ApiCall} apiCall - the callable object.
- * @param {Object} request - the request object.
- * @param {CallOptions=} options - the call options to customize the api call.
- * @return {Stream} - a new object Stream.
- */
- createStream(apiCall, request, options) {
- const stream = new stream_1.PassThrough({ objectMode: true });
- options = Object.assign({}, options, { autoPaginate: false });
- const maxResults = 'maxResults' in options ? options.maxResults : -1;
- let pushCount = 0;
- let started = false;
- function callback(err, resources, next) {
- if (err) {
- stream.emit('error', err);
- return;
- }
- for (let i = 0; i < resources.length; ++i) {
- if (ended(stream)) {
- return;
- }
- if (resources[i] === null) {
- continue;
- }
- stream.push(resources[i]);
- pushCount++;
- if (pushCount === maxResults) {
- stream.end();
- }
- }
- if (ended(stream)) {
- return;
- }
- if (!next) {
- stream.end();
- return;
- }
- // When pageToken is specified in the original options, it will overwrite
- // the page token field in the next request. Therefore it must be cleared.
- if ('pageToken' in options) {
- delete options.pageToken;
- }
- if (stream.isPaused()) {
- request = next;
- started = false;
- }
- else {
- setImmediate(apiCall, next, options, callback);
- }
- }
- stream.on('resume', () => {
- if (!started) {
- started = true;
- apiCall(request, options, callback);
- }
- });
- return stream;
- }
- /**
- * Returns a new API caller.
- * @private
- * @return {PageStreamable} - the page streaming caller.
- */
- apiCaller() {
- return new PagedIteration(this);
- }
-}
-exports.PageDescriptor = PageDescriptor;
-//# sourceMappingURL=pagedIteration.js.map
\ No newline at end of file

build/src/pagedIteration.js.map

@@ -1 +0,0 @@
-{"version":3,"file":"pagedIteration.js","sourceRoot":"","sources":["../../src/pagedIteration.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAEH,yCAAyC;AACzC,mCAA8C;AAE9C,+CAA6F;AAE7F,MAAa,cAAe,SAAQ,6BAAe;IAEjD;;;;;;;OAOG;IACH,YAAY,cAA8B;QACxC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAED,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CAAC;iBACd;aACF;YACD,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE;gBACjB,OAAO;aACR;YACD,IAAI,CAAC,IAAI,EAAE;gBACT,MAAM,CAAC,GAAG,EAAE,CAAC;gBACb,OAAO;aACR;YACD,yEAAyE;YACzE,0EAA0E;YAC1E,IAAI,WAAW,IAAI,OAAO,EAAE;gBAC1B,OAAO,OAAO,CAAC,SAAS,CAAC;aAC1B;YACD,IAAI,MAAM,CAAC,QAAQ,EAAE,EAAE;gBACrB,OAAO,GAAG,IAAI,CAAC;gBACf,OAAO,GAAG,KAAK,CAAC;aACjB;iBAAM;gBACL,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;aAChD;QACH,CAAC;QACD,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YACvB,IAAI,CAAC,OAAO,EAAE;gBACZ,OAAO,GAAG,IAAI,CAAC;gBACf,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;aACrC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACH,SAAS;QACP,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACF;AAhGD,wCAgGC"}
\ No newline at end of file

build/src/paginationCalls/pagedApiCaller.d.ts

@@ -0,0 +1,29 @@
+import { APICaller, ApiCallerSettings } from '../apiCaller';
+import { GRPCCall, SimpleCallbackFunction } from '../apitypes';
+import { APICallback } from '../apitypes';
+import { OngoingCall, OngoingCallPromise } from '../call';
+import { CallOptions } from '../gax';
+import { GoogleError } from '../googleError';
+import { PageDescriptor } from './pageDescriptor';
+export declare class PagedApiCaller implements APICaller {
+ pageDescriptor: PageDescriptor;
+ /**
+ * Creates an API caller that returns a stream to performs page-streaming.
+ *
+ * @private
+ * @constructor
+ * @param {PageDescriptor} pageDescriptor - indicates the structure
+ * of page streaming to be performed.
+ */
+ constructor(pageDescriptor: PageDescriptor);
+ private createActualCallback;
+ wrap(func: GRPCCall): GRPCCall;
+ init(settings: ApiCallerSettings, callback?: APICallback): OngoingCall;
+ call(apiCall: SimpleCallbackFunction, argument: {
+ [index: string]: {};
+ }, settings: CallOptions, canceller: OngoingCall): void;
+ fail(canceller: OngoingCallPromise, err: GoogleError): void;
+ result(canceller: OngoingCallPromise): import("../call").CancellablePromise<[import("../apitypes").ResponseType, {
+ [index: string]: string;
+ } | null | undefined, {} | import("..").Operation | undefined]>;
+}

build/src/paginationCalls/pagedApiCaller.js

@@ -0,0 +1,124 @@
+"use strict";
+/*
+ * Copyright 2019, Google LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+const call_1 = require("../call");
+const googleError_1 = require("../googleError");
+class PagedApiCaller {
+ /**
+ * Creates an API caller that returns a stream to performs page-streaming.
+ *
+ * @private
+ * @constructor
+ * @param {PageDescriptor} pageDescriptor - indicates the structure
+ * of page streaming to be performed.
+ */
+ constructor(pageDescriptor) {
+ this.pageDescriptor = pageDescriptor;
+ }
+ createActualCallback(request, callback) {
+ const self = this;
+ return function fetchNextPageToken(err, response) {
+ if (err) {
+ callback(err);
+ return;
+ }
+ if (!response) {
+ callback(new googleError_1.GoogleError('Undefined response in pagination method callback.'));
+ return;
+ }
+ const resources = response[self.pageDescriptor.resourceField];
+ const pageToken = response[self.pageDescriptor.responsePageTokenField];
+ if (pageToken) {
+ request[self.pageDescriptor.requestPageTokenField] = pageToken;
+ callback(err, resources, request, response);
+ }
+ else {
+ callback(err, resources, null, response);
+ }
+ };
+ }
+ wrap(func) {
+ const self = this;
+ return function wrappedCall(argument, metadata, options, callback) {
+ return func(argument, metadata, options, self.createActualCallback(argument, callback));
+ };
+ }
+ init(settings, callback) {
+ if (callback) {
+ return new call_1.OngoingCall(callback);
+ }
+ return new call_1.OngoingCallPromise(settings.promise);
+ }
+ call(apiCall, argument, settings, canceller) {
+ argument = Object.assign({}, argument);
+ if (settings.pageToken) {
+ argument[this.pageDescriptor.requestPageTokenField] = settings.pageToken;
+ }
+ if (settings.pageSize) {
+ argument[this.pageDescriptor.requestPageSizeField] = settings.pageSize;
+ }
+ if (!settings.autoPaginate) {
+ // they don't want auto-pagination this time - okay, just call once
+ canceller.call(apiCall, argument);
+ return;
+ }
+ const maxResults = settings.maxResults || -1;
+ const allResources = [];
+ function pushResources(err, resources, next) {
+ if (err) {
+ canceller.callback(err);
+ return;
+ }
+ for (let i = 0; i < resources.length; ++i) {
+ allResources.push(resources[i]);
+ if (allResources.length === maxResults) {
+ next = null;
+ break;
+ }
+ }
+ if (!next) {
+ canceller.callback(null, allResources);
+ return;
+ }
+ setImmediate(apiCall, next, pushResources);
+ }
+ setImmediate(apiCall, argument, pushResources);
+ }
+ fail(canceller, err) {
+ canceller.callback(err);
+ }
+ result(canceller) {
+ return canceller.promise;
+ }
+}
+exports.PagedApiCaller = PagedApiCaller;
+//# sourceMappingURL=pagedApiCaller.js.map
\ No newline at end of file

build/src/paginationCalls/pagedApiCaller.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"pagedApiCaller.js","sourceRoot":"","sources":["../../../src/paginationCalls/pagedApiCaller.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAKH,kCAAwD;AAExD,gDAA2C;AAI3C,MAAa,cAAc;IAEzB;;;;;;;OAOG;IACH,YAAY,cAA8B;QACxC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAEO,oBAAoB,CACxB,OAA4B,EAAE,QAAqB;QACrD,MAAM,IAAI,GAAG,IAAI,CAAC;QAClB,OAAO,SAAS,kBAAkB,CAC9B,GAAe,EAAE,QAAuC;YAC1D,IAAI,GAAG,EAAE;gBACP,QAAQ,CAAC,GAAG,CAAC,CAAC;gBACd,OAAO;aACR;YACD,IAAI,CAAC,QAAQ,EAAE;gBACb,QAAQ,CAAC,IAAI,yBAAW,CACpB,mDAAmD,CAAC,CAAC,CAAC;gBAC1D,OAAO;aACR;YACD,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;YAC9D,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,sBAAsB,CAAC,CAAC;YACvE,IAAI,SAAS,EAAE;gBACb,OAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,qBAA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CAAC,CAAC;YAClC,OAAO;SACR;QAED,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC;QAC7C,MAAM,YAAY,GAAc,EAAE,CAAC;QACnC,SAAS,aAAa,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI;YACzC,IAAI,GAAG,EAAE;gBACP,SAAS,CAAC,QAAS,CAAC,GAAG,CAAC,CAAC;gBACzB,OAAO;aACR;YAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;gBACzC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;gBAChC,IAAI,YAAY,CAAC,MAAM,KAAK,UAAU,EAAE;oBACtC,IAAI,GAAG,IAAI,CAAC;oBACZ,MAAM;iBACP;aACF;YACD,IAAI,CAAC,IAAI,EAAE;gBACT,SAAS,CAAC,QAAS,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;gBACxC,OAAO;aACR;YACD,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;QAC7C,CAAC;QAED,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,CAAC,SAA6B,EAAE,GAAgB;QAClD,SAAS,CAAC,QAAS,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,SAA6B;QAClC,OAAO,SAAS,CAAC,OAAO,CAAC;IAC3B,CAAC;CACF;AAvGD,wCAuGC"}
\ No newline at end of file

build/src/paginationCalls/pageDescriptor.d.ts

@@ -0,0 +1,21 @@
+/// <reference types="node" />
+import { Transform } from 'stream';
+import { APICaller } from '../apiCaller';
+import { GaxCall } from '../apitypes';
+import { Descriptor } from '../descriptor';
+import { CallSettings } from '../gax';
+/**
+ * A descriptor for methods that support pagination.
+ */
+export declare class PageDescriptor implements Descriptor {
+ requestPageTokenField: string;
+ responsePageTokenField: string;
+ requestPageSizeField?: string;
+ resourceField: string;
+ constructor(requestPageTokenField: string, responsePageTokenField: string, resourceField: string);
+ /**
+ * Creates a new object Stream which emits the resource on 'data' event.
+ */
+ createStream(apiCall: GaxCall, request: {}, options: CallSettings): Transform;
+ getApiCaller(settings: CallSettings): APICaller;
+}

build/src/paginationCalls/pageDescriptor.js

@@ -0,0 +1,109 @@
+"use strict";
+/*
+ * Copyright 2019 Google LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+const ended = require("is-stream-ended");
+const stream_1 = require("stream");
+const normalApiCaller_1 = require("../normalCalls/normalApiCaller");
+const pagedApiCaller_1 = require("./pagedApiCaller");
+/**
+ * A descriptor for methods that support pagination.
+ */
+class PageDescriptor {
+ constructor(requestPageTokenField, responsePageTokenField, resourceField) {
+ this.requestPageTokenField = requestPageTokenField;
+ this.responsePageTokenField = responsePageTokenField;
+ this.resourceField = resourceField;
+ }
+ /**
+ * Creates a new object Stream which emits the resource on 'data' event.
+ */
+ createStream(apiCall, request, options) {
+ const stream = new stream_1.PassThrough({ objectMode: true });
+ options = Object.assign({}, options, { autoPaginate: false });
+ const maxResults = 'maxResults' in options ? options.maxResults : -1;
+ let pushCount = 0;
+ let started = false;
+ function callback(err, resources, next) {
+ if (err) {
+ stream.emit('error', err);
+ return;
+ }
+ for (let i = 0; i < resources.length; ++i) {
+ if (ended(stream)) {
+ return;
+ }
+ if (resources[i] === null) {
+ continue;
+ }
+ stream.push(resources[i]);
+ pushCount++;
+ if (pushCount === maxResults) {
+ stream.end();
+ }
+ }
+ if (ended(stream)) {
+ return;
+ }
+ if (!next) {
+ stream.end();
+ return;
+ }
+ // When pageToken is specified in the original options, it will overwrite
+ // the page token field in the next request. Therefore it must be cleared.
+ if ('pageToken' in options) {
+ delete options.pageToken;
+ }
+ if (stream.isPaused()) {
+ request = next;
+ started = false;
+ }
+ else {
+ setImmediate(apiCall, next, options, callback);
+ }
+ }
+ stream.on('resume', () => {
+ if (!started) {
+ started = true;
+ apiCall(request, options, callback);
+ }
+ });
+ return stream;
+ }
+ getApiCaller(settings) {
+ if (!settings.autoPaginate) {
+ return new normalApiCaller_1.NormalApiCaller();
+ }
+ return new pagedApiCaller_1.PagedApiCaller(this);
+ }
+}
+exports.PageDescriptor = PageDescriptor;
+//# sourceMappingURL=pageDescriptor.js.map
\ No newline at end of file

build/src/paginationCalls/pageDescript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C,CAAC,KAAK,IAAI,EAAE;oBACzB,SAAS;iBACV;gBACD,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC1B,SAAS,EAAE,CAAC;gBACZ,IAAI,SAAS,KAAK,UAAU,EAAE;oBAC5B,MAAM,CAAC,GAAG,EAAE,CAAC;iBACd;aACF;YACD,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE;gBACjB,OAAO;aACR;YACD,IAAI,CAAC,IAAI,EAAE;gBACT,MAAM,CAAC,GAAG,EAAE,CAAC;gBACb,OAAO;aACR;YACD,yEAAyE;YACzE,0EAA0E;YAC1E,IAAI,WAAW,IAAI,OAAO,EAAE;gBAC1B,OAAO,OAAO,CAAC,SAAS,CAAC;aAC1B;YACD,IAAI,MAAM,CAAC,QAAQ,EAAE,EAAE;gBACrB,OAAO,GAAG,IAAI,CAAC;gBACf,OAAO,GAAG,KAAK,CAAC;aACjB;iBAAM;gBACL,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;aAChD;QACH,CAAC;QACD,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YACvB,IAAI,CAAC,OAAO,EAAE;gBACZ,OAAO,GAAG,IAAI,CAAC;gBACf,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;aACrC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,YAAY,CAAC,QAAsB;QACjC,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE;YAC1B,OAAO,IAAI,iCAAe,EAAE,CAAC;SAC9B;QACD,OAAO,IAAI,+BAAc,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACF;AA5ED,wCA4EC"}
\ No newline at end of file

build/src/parserExtras.js

@@ -1,7 +1,6 @@
"use strict";
/*
- *
- * Copyright 2016, Google Inc.
+ * Copyright 2019 Google LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +28,6 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
*/
Object.defineProperty(exports, "__esModule", { value: true });
const util = require("util");

build/src/parserExtras.js.map

@@ -1 +1 @@
-{"version":3,"file":"parserExtras.js","sourceRoot":"","sources":["../../src/parserExtras.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;AAEH,6BAA6B;AAG7B,wCAAwC;AAC3B,QAAA,OAAO,GAAG,CAAC,CAAC;AACZ,QAAA,WAAW,GAAG,CAAC,CAAC;AAChB,QAAA,QAAQ,GAAG,CAAC,CAAC;AAE1B;;;;;;;GAOG;AACH,SAAS,oBAAoB,CAAC,QAAmB;IAC/C,IAAI,eAAe,GAAG,KAAK,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACxC,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,CAAC,CAAC,IAAI,KAAK,gBAAQ,IAAI,CAAC,CAAC,OAAO,KAAK,IAAI,EAAE;YAC7C,SAAS;SACV;QACD,IAAI,eAAe,EAAE;YACnB,MAAM,gBAAgB,GAAG,4CAA4C,CAAC;YACtE,MAAM,IAAI,SAAS,CAAC,gBAAgB,CAAC,CAAC;SACvC;QACD,eAAe,GAAG,IAAI,CAAC;KACxB;AACH,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,cAAc,CAAC,QAAmB;IACzC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,gBAAQ,CAAC,CAAC,MAAM,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YAC7C,SAAS;SACV;QACD,IAAI,eAAe,EAAE;YACnB,MAAM,gBAAgB,GAAG,4CAA4C,CAAC;YACtE,MAAM,IAAI,SAAS,CAAC,gBAAgB,CAAC,CAAC;SACvC;QACD,eAAe,GAAG,IAAI,CAAC;KACxB;AACH,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,cAAc,CAAC,QAAmB;IACzC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,gBAAQ,CAAC,CAAC,MAAM,CAAC;AAC1D,CAAC;AAED;;;;;;GAMG;AACH,SAAS,qBAAqB,CAAC,QAAmB;IAChD,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;QACnB,IAAI,CAAC,CAAC,IAAI,KAAK,eAAO,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE;YACpC,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;YAC7C,YAAY,IAAI,CAAC,CAAC;SACnB;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,WAAW,CAAC,QAAmB;IAC7C,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAC/B,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAChC,OAAO;QACL,QAAQ;QACR,IAAI,EAAE,cAAc,CAAC,QAAQ,CAAC;KAC/B,CAAC;AACJ,CAAC;AAPD,kCAOC"}
\ No newline at end of file

build/src/pathTemplate.js

@@ -1,7 +1,6 @@
"use strict";
/*
- *
- * Copyright 2016, Google Inc.
+ * Copyright 2019 Google LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +28,6 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
*/
Object.defineProperty(exports, "__esModule", { value: true });
/*

build/src/pathTemplate.js.map

@@ -1 +1 @@
-{"version":3,"file":"pathTemplate.js","sourceRoot":"","sources":["../../src/pathTemplate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;AAEH;;GAEG;AAEH,kCAAmC;AACnC,6BAA6B;AAC7B,yCAAyC;AACzC,MAAM,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAgB/C,MAAa,YAAY;IAGvB,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,YAAY,IAAY;QACtB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5D,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,IAAY;QAChB,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACrC,MAAM,QAAQ,GAAa,EAAE,CAAC;QAC9B,IAAI,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC;QAC7B,IAAI,OAAe,CAAC;QACpB,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAC9B,IAAI,KAAK,GAAG,YAAY,CAAC,MAAM,EAAE;gBAC/B,OAAO;aACR;YACD,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,OAAO,EAAE;gBACnC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;aAC3B;iBAAM,IAAI,OAAO,CAAC,IAAI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AC,CAAC;QACnC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACnB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACH,OAAO;QACL,OAAO,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;CACF;AA9GD,oCA8GC;AAED;;;;;GAKG;AACH,SAAS,cAAc,CAAC,QAAmB;IACzC,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,KAAK,GAAG,IAAI,CAAC;IACjB,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QACzB,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,QAAQ,EAAE;YACpC,IAAI,KAAK,EAAE;gBACT,GAAG,IAAI,GAAG,CAAC;aACZ;YACD,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;YACvB,OAAO;SACR;QACD,KAAK,GAAG,IAAI,CAAC;QACb,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,OAAO,EAAE;YACnC,GAAG,IAAI,IAAI,GAAG,OAAO,CAAC,OAAO,GAAG,GAAG,CAAC;YACpC,KAAK,GAAG,KAAK,CAAC;SACf;aAAM;YACL,GAAG,IAAI,OAAO,CAAC,OAAO,GAAG,GAAG,CAAC;SAC9B;IACH,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAC1B,CAAC"}
\ No newline at end of file

build/src/routingHeader.js

@@ -1,6 +1,6 @@
"use strict";
/*
- * Copyright 2017, Google Inc.
+ * Copyright 2019 Google LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without

build/src/streamingCalls/streamDescriptor.d.ts

@@ -0,0 +1,12 @@
+import { APICaller } from '../apiCaller';
+import { Descriptor } from '../descriptor';
+import { CallSettings } from '../gax';
+import { StreamType } from './streaming';
+/**
+ * A descriptor for streaming calls.
+ */
+export declare class StreamDescriptor implements Descriptor {
+ type: StreamType;
+ constructor(streamType: StreamType);
+ getApiCaller(settings: CallSettings): APICaller;
+}

build/src/streamingCalls/streamDescriptor.js

@@ -0,0 +1,51 @@
+"use strict";
+/*
+ * Copyright 2019 Google LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+const streamingApiCaller_1 = require("./streamingApiCaller");
+/**
+ * A descriptor for streaming calls.
+ */
+class StreamDescriptor {
+ constructor(streamType) {
+ this.type = streamType;
+ }
+ getApiCaller(settings) {
+ // Right now retrying does not work with gRPC-streaming, because retryable
+ // assumes an API call returns an event emitter while gRPC-streaming methods
+ // return Stream.
+ // TODO: support retrying.
+ settings.retry = null;
+ return new streamingApiCaller_1.StreamingApiCaller(this);
+ }
+}
+exports.StreamDescriptor = StreamDescriptor;
+//# sourceMappingURL=streamDescriptor.js.map
\ No newline at end of file

build/src/streamingCalls/streamDescriptor.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"streamDescriptor.js","sourceRoot":"","sources":["../../../src/streamingCalls/streamDescriptor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAOH,6DAAwD;AAExD;;GAEG;AACH,MAAa,gBAAgB;IAG3B,YAAY,UAAsB;QAChC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;IAED,YAAY,CAAC,QAAsB;QACjC,0EAA0E;QAC1E,4EAA4E;QAC5E,iBAAiB;QACjB,0BAA0B;QAC1B,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC;QACtB,OAAO,IAAI,uCAAkB,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;CACF;AAfD,4CAeC"}
\ No newline at end of file

build/src/streamingCalls/streamingApiCaller.d.ts

@@ -0,0 +1,19 @@
+import { APICaller, ApiCallerSettings } from '../apiCaller';
+import { APICallback, CancellableStream, GRPCCall, SimpleCallbackFunction } from '../apitypes';
+import { StreamDescriptor } from './streamDescriptor';
+import { StreamProxy } from './streaming';
+export declare class StreamingApiCaller implements APICaller {
+ descriptor: StreamDescriptor;
+ /**
+ * An API caller for methods of gRPC streaming.
+ * @private
+ * @constructor
+ * @param {StreamDescriptor} descriptor - the descriptor of the method structure.
+ */
+ constructor(descriptor: StreamDescriptor);
+ init(settings: ApiCallerSettings, callback: APICallback): StreamProxy;
+ wrap(func: GRPCCall): GRPCCall;
+ call(apiCall: SimpleCallbackFunction, argument: {}, settings: {}, stream: StreamProxy): void;
+ fail(stream: CancellableStream, err: Error): void;
+ result(stream: CancellableStream): CancellableStream;
+}

build/src/streamingCalls/streamingApiCaller.js

@@ -0,0 +1,78 @@
+"use strict";
+/*
+ * Copyright 2019, Google LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+const warnings_1 = require("../warnings");
+const streaming_1 = require("./streaming");
+class StreamingApiCaller {
+ /**
+ * An API caller for methods of gRPC streaming.
+ * @private
+ * @constructor
+ * @param {StreamDescriptor} descriptor - the descriptor of the method structure.
+ */
+ constructor(descriptor) {
+ this.descriptor = descriptor;
+ }
+ init(settings, callback) {
+ return new streaming_1.StreamProxy(this.descriptor.type, callback);
+ }
+ wrap(func) {
+ switch (this.descriptor.type) {
+ case streaming_1.StreamType.SERVER_STREAMING:
+ return (argument, metadata, options) => {
+ return func(argument, metadata, options);
+ };
+ case streaming_1.StreamType.CLIENT_STREAMING:
+ return (argument, metadata, options, callback) => {
+ return func(metadata, options, callback);
+ };
+ case streaming_1.StreamType.BIDI_STREAMING:
+ return (argument, metadata, options) => {
+ return func(metadata, options);
+ };
+ default:
+ warnings_1.warn('streaming_wrap_unknown_stream_type', `Unknown stream type: ${this.descriptor.type}`);
+ }
+ return func;
+ }
+ call(apiCall, argument, settings, stream) {
+ stream.setStream(apiCall, argument);
+ }
+ fail(stream, err) {
+ stream.emit('error', err);
+ }
+ result(stream) {
+ return stream;
+ }
+}
+exports.StreamingApiCaller = StreamingApiCaller;
+//# sourceMappingURL=streamingApiCaller.js.map
\ No newline at end of file

build/src/streamingCalls/streamingApiCaller.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"streamingApiCaller.js","sourceRoot":"","sources":["../../../src/streamingCalls/streamingApiCaller.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAKH,0CAAiC;AAGjC,2CAAoD;AAEpD,MAAa,kBAAkB;IAG7B;;;;;OAKG;IACH,YAAY,UAA4B;QACtC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,IAAI,CAAC,QAA2B,EAAE,QAAqB;QACrD,OAAO,IAAI,uBAAW,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC;IAED,IAAI,CAAC,IAAc;QACjB,QAAQ,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE;YAC5B,KAAK,sBAAU,CAAC,gBAAgB;gBAC9B,OAAO,CAAC,QAAY,EAAE,QAAY,EAAE,OAAW,EAAE,EAAE;oBACjD,OAAQ,IAA4B,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;gBACpE,CAAC,CAAC;YACJ,KAAK,sBAAU,CAAC,gBAAgB;gBAC9B,OAAO,CAAC,QAAY,EAAE,QAAY,EAAE,OAAW,EACvC,QAAsB,EAAE,EAAE;oBAChC,OAAQ,IAA4B,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;gBACpE,CAAC,CAAC;YACJ,KAAK,sBAAU,CAAC,cAAc;gBAC5B,OAAO,CAAC,QAAY,EAAE,QAAY,EAAE,OAAW,EAAE,EAAE;oBACjD,OAAQ,IAA0B,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;gBACxD,CAAC,CAAC;YACJ;gBACE,eAAI,CACA,oCAAoC,EACpC,wBAAwB,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;SACvD;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CACA,OAA+B,EAAE,QAAY,EAAE,QAAY,EAC3D,MAAmB;QACrB,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,CAAC,MAAyB,EAAE,GAAU;QACxC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED,MAAM,CAAC,MAAyB;QAC9B,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AArDD,gDAqDC"}
\ No newline at end of file

build/src/streamingCalls/streaming.d.ts

@@ -0,0 +1,88 @@
+/**
+ * Copyright 2019 Google LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/// <reference types="node" />
+import { Duplex, DuplexOptions, Readable, Stream, Writable } from 'stream';
+import { APICallback, CancellableStream, GRPCCallResult, SimpleCallbackFunction } from '../apitypes';
+declare const duplexify: DuplexifyConstructor;
+export interface DuplexifyOptions extends DuplexOptions {
+ autoDestroy?: boolean;
+ end?: boolean;
+}
+export interface Duplexify extends Duplex {
+ readonly destroyed: boolean;
+ setWritable(writable: Writable | false | null): void;
+ setReadable(readable: Readable | false | null): void;
+}
+export interface DuplexifyConstructor {
+ obj(writable?: Writable | false | null, readable?: Readable | false | null, options?: DuplexifyOptions): Duplexify;
+ new (writable?: Writable | false | null, readable?: Readable | false | null, options?: DuplexifyOptions): Duplexify;
+ (writable?: Writable | false | null, readable?: Readable | false | null, options?: DuplexifyOptions): Duplexify;
+}
+/**
+ * The type of gRPC streaming.
+ * @enum {number}
+ */
+export declare enum StreamType {
+ /** Client sends a single request, server streams responses. */
+ SERVER_STREAMING = 1,
+ /** Client streams requests, server returns a single response. */
+ CLIENT_STREAMING = 2,
+ /** Both client and server stream objects. */
+ BIDI_STREAMING = 3
+}
+export declare class StreamProxy extends duplexify implements GRPCCallResult {
+ type: StreamType;
+ private _callback;
+ private _isCancelCalled;
+ stream?: CancellableStream;
+ /**
+ * StreamProxy is a proxy to gRPC-streaming method.
+ *
+ * @private
+ * @constructor
+ * @param {StreamType} type - the type of gRPC stream.
+ * @param {ApiCallback} callback - the callback for further API call.
+ */
+ constructor(type: StreamType, callback: APICallback);
+ cancel(): void;
+ /**
+ * Forward events from an API request stream to the user's stream.
+ * @param {Stream} stream - The API request stream.
+ */
+ forwardEvents(stream: Stream): void;
+ /**
+ * Specifies the target stream.
+ * @param {ApiCall} apiCall - the API function to be called.
+ * @param {Object} argument - the argument to be passed to the apiCall.
+ */
+ setStream(apiCall: SimpleCallbackFunction, argument: {}): void;
+}
+export {};

build/src/streamingCalls/streaming.js

@@ -0,0 +1,142 @@
+"use strict";
+/**
+ * Copyright 2019 Google LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+const duplexify = require('duplexify');
+const retryRequest = require('retry-request');
+/**
+ * The type of gRPC streaming.
+ * @enum {number}
+ */
+var StreamType;
+(function (StreamType) {
+ /** Client sends a single request, server streams responses. */
+ StreamType[StreamType["SERVER_STREAMING"] = 1] = "SERVER_STREAMING";
+ /** Client streams requests, server returns a single response. */
+ StreamType[StreamType["CLIENT_STREAMING"] = 2] = "CLIENT_STREAMING";
+ /** Both client and server stream objects. */
+ StreamType[StreamType["BIDI_STREAMING"] = 3] = "BIDI_STREAMING";
+})(StreamType = exports.StreamType || (exports.StreamType = {}));
+class StreamProxy extends duplexify {
+ /**
+ * StreamProxy is a proxy to gRPC-streaming method.
+ *
+ * @private
+ * @constructor
+ * @param {StreamType} type - the type of gRPC stream.
+ * @param {ApiCallback} callback - the callback for further API call.
+ */
+ constructor(type, callback) {
+ super(undefined, undefined, {
+ objectMode: true,
+ readable: type !== StreamType.CLIENT_STREAMING,
+ writable: type !== StreamType.SERVER_STREAMING,
+ });
+ this.type = type;
+ this._callback = callback;
+ this._isCancelCalled = false;
+ }
+ cancel() {
+ if (this.stream) {
+ this.stream.cancel();
+ }
+ else {
+ this._isCancelCalled = true;
+ }
+ }
+ /**
+ * Forward events from an API request stream to the user's stream.
+ * @param {Stream} stream - The API request stream.
+ */
+ forwardEvents(stream) {
+ const eventsToForward = ['metadata', 'response', 'status'];
+ eventsToForward.forEach(event => {
+ stream.on(event, this.emit.bind(this, event));
+ });
+ // We also want to supply the status data as 'response' event to support
+ // the behavior of google-cloud-node expects.
+ // see:
+ // https://github.com/GoogleCloudPlatform/google-cloud-node/pull/1775#issuecomment-259141029
+ // https://github.com/GoogleCloudPlatform/google-cloud-node/blob/116436fa789d8b0f7fc5100b19b424e3ec63e6bf/packages/common/src/grpc-service.js#L355
+ stream.on('metadata', metadata => {
+ // Create a response object with succeeds.
+ // TODO: unify this logic with the decoration of gRPC response when it's
+ // added. see: https://github.com/googleapis/gax-nodejs/issues/65
+ stream.emit('response', {
+ code: 200,
+ details: '',
+ message: 'OK',
+ metadata,
+ });
+ });
+ }
+ /**
+ * Specifies the target stream.
+ * @param {ApiCall} apiCall - the API function to be called.
+ * @param {Object} argument - the argument to be passed to the apiCall.
+ */
+ setStream(apiCall, argument) {
+ if (this.type === StreamType.SERVER_STREAMING) {
+ const retryStream = retryRequest(null, {
+ objectMode: true,
+ request: () => {
+ if (this._isCancelCalled) {
+ if (this.stream) {
+ this.stream.cancel();
+ }
+ return;
+ }
+ const stream = apiCall(argument, this._callback);
+ this.stream = stream;
+ this.forwardEvents(stream);
+ return stream;
+ },
+ });
+ this.setReadable(retryStream);
+ return;
+ }
+ const stream = apiCall(argument, this._callback);
+ this.stream = stream;
+ this.forwardEvents(stream);
+ if (this.type === StreamType.CLIENT_STREAMING) {
+ this.setWritable(stream);
+ }
+ if (this.type === StreamType.BIDI_STREAMING) {
+ this.setReadable(stream);
+ this.setWritable(stream);
+ }
+ if (this._isCancelCalled && this.stream) {
+ this.stream.cancel();
+ }
+ }
+}
+exports.StreamProxy = StreamProxy;
+//# sourceMappingURL=streaming.js.map
\ No newline at end of file

build/src/streamingCalls/streaming.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"streaming.js","sourceRoot":"","sources":["../../../src/streamingCalls/streaming.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAQH,MAAM,SAAS,GAAyB,OAAO,CAAC,WAAW,CAAC,CAAC;AAC7D,MAAM,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAuB9C;;;GAGG;AACH,IAAY,UASX;AATD,WAAY,UAAU;IACpB,+DAA+D;IAC/D,mEAAoB,CAAA;IAEpB,iEAAiE;IACjE,mEAAoB,CAAA;IAEpB,6CAA6C;IAC7C,+DAAkB,CAAA;AACpB,CAAC,EATW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QASrB;AAED,MAAa,WAAY,SAAQ,SAAS;IAKxC;;;;;;;OAOG;IACH,YAAY,IAAgB,EAAE,QAAqB;QACjD,KAAK,CAAC,SAAS,EAAE,SAAS,EAAE;YAC1B,UAAU,EAAE,IAAI;YAChB,QAAQ,EAAE,IAAI,KAAK,UAAU,CAAC,gBAAgB;YAC9C,QAAQ,EAAE,IAAI,KAAK,UAAU,CAAC,gBAAgB;SAC9B,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;IAC/B,CAAC;IAED,MAAM;QACJ,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;SACtB;aAAM;YACL,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;SAC7B;IACH,CAAC;IAED;;;OAGG;IACH,aAAa,CAAC,MAAc;QAC1B,MAAM,eAAe,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;QAE3D,eAAe,CAAC,OAA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AE,IAAI,CAAC,SAAS,CAAsB,CAAC;QACtE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAE3B,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,CAAC,gBAAgB,EAAE;YAC7C,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;SAC1B;QAED,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,CAAC,cAAc,EAAE;YAC3C,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YACzB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;SAC1B;QAED,IAAI,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,MAAM,EAAE;YACvC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;SACtB;IACH,CAAC;CACF;AAxGD,kCAwGC"}
\ No newline at end of file

build/src/streaming.d.ts

@@ -1,117 +0,0 @@
-/**
- * Copyright 2016, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/// <reference types="node" />
-import { Duplex, DuplexOptions, Readable, Stream, Writable } from 'stream';
-import { APICall, APICallback } from './apiCallable';
-declare const duplexify: DuplexifyConstructor;
-export interface DuplexifyOptions extends DuplexOptions {
- autoDestroy?: boolean;
- end?: boolean;
-}
-export interface Duplexify extends Duplex {
- readonly destroyed: boolean;
- setWritable(writable: Writable | false | null): void;
- setReadable(readable: Readable | false | null): void;
-}
-export interface DuplexifyConstructor {
- obj(writable?: Writable | false | null, readable?: Readable | false | null, options?: DuplexifyOptions): Duplexify;
- new (writable?: Writable | false | null, readable?: Readable | false | null, options?: DuplexifyOptions): Duplexify;
- (writable?: Writable | false | null, readable?: Readable | false | null, options?: DuplexifyOptions): Duplexify;
-}
-/**
- * The type of gRPC streaming.
- * @enum {number}
- */
-export declare enum StreamType {
- /** Client sends a single request, server streams responses. */
- SERVER_STREAMING = 1,
- /** Client streams requests, server returns a single response. */
- CLIENT_STREAMING = 2,
- /** Both client and server stream objects. */
- BIDI_STREAMING = 3
-}
-export declare class StreamProxy extends duplexify {
- type: StreamType;
- private _callback?;
- private _isCancelCalled;
- stream?: Duplex & {
- cancel: () => void;
- };
- /**
- * StreamProxy is a proxy to gRPC-streaming method.
- *
- * @private
- * @constructor
- * @param {StreamType} type - the type of gRPC stream.
- * @param {ApiCallback} callback - the callback for further API call.
- */
- constructor(type: StreamType, callback: APICallback);
- cancel(): void;
- /**
- * Forward events from an API request stream to the user's stream.
- * @param {Stream} stream - The API request stream.
- */
- forwardEvents(stream: Stream): void;
- /**
- * Specifies the target stream.
- * @param {ApiCall} apiCall - the API function to be called.
- * @param {Object} argument - the argument to be passed to the apiCall.
- */
- setStream(apiCall: APICall, argument: {}): void;
-}
-export declare class GrpcStreamable {
- descriptor: StreamDescriptor;
- /**
- * An API caller for methods of gRPC streaming.
- * @private
- * @constructor
- * @param {StreamDescriptor} descriptor - the descriptor of the method structure.
- */
- constructor(descriptor: StreamDescriptor);
- init(settings: {}, callback: APICallback): StreamProxy;
- wrap(func: Function): Function;
- call(apiCall: APICall, argument: {}, settings: {}, stream: StreamProxy): void;
- fail(stream: Stream, err: Error): void;
- result(stream: Stream): Stream;
-}
-export declare class StreamDescriptor {
- type: StreamType;
- /**
- * Describes the structure of gRPC streaming call.
- * @constructor
- * @param {StreamType} streamType - the type of streaming.
- */
- constructor(streamType: StreamType);
- apiCaller(settings: {
- retry: null;
- }): GrpcStreamable;
-}
-export {};

build/src/streaming.js

@@ -1,205 +0,0 @@
-"use strict";
-/**
- * Copyright 2016, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-Object.defineProperty(exports, "__esModule", { value: true });
-const warnings_1 = require("./warnings");
-const duplexify = require('duplexify');
-const retryRequest = require('retry-request');
-/**
- * The type of gRPC streaming.
- * @enum {number}
- */
-var StreamType;
-(function (StreamType) {
- /** Client sends a single request, server streams responses. */
- StreamType[StreamType["SERVER_STREAMING"] = 1] = "SERVER_STREAMING";
- /** Client streams requests, server returns a single response. */
- StreamType[StreamType["CLIENT_STREAMING"] = 2] = "CLIENT_STREAMING";
- /** Both client and server stream objects. */
- StreamType[StreamType["BIDI_STREAMING"] = 3] = "BIDI_STREAMING";
-})(StreamType = exports.StreamType || (exports.StreamType = {}));
-class StreamProxy extends duplexify {
- /**
- * StreamProxy is a proxy to gRPC-streaming method.
- *
- * @private
- * @constructor
- * @param {StreamType} type - the type of gRPC stream.
- * @param {ApiCallback} callback - the callback for further API call.
- */
- constructor(type, callback) {
- super(undefined, undefined, {
- objectMode: true,
- readable: type !== StreamType.CLIENT_STREAMING,
- writable: type !== StreamType.SERVER_STREAMING,
- });
- this.type = type;
- this._callback = callback;
- this._isCancelCalled = false;
- }
- cancel() {
- if (this.stream) {
- this.stream.cancel();
- }
- else {
- this._isCancelCalled = true;
- }
- }
- /**
- * Forward events from an API request stream to the user's stream.
- * @param {Stream} stream - The API request stream.
- */
- forwardEvents(stream) {
- const eventsToForward = ['metadata', 'response', 'status'];
- eventsToForward.forEach(event => {
- stream.on(event, this.emit.bind(this, event));
- });
- // We also want to supply the status data as 'response' event to support
- // the behavior of google-cloud-node expects.
- // see:
- // https://github.com/GoogleCloudPlatform/google-cloud-node/pull/1775#issuecomment-259141029
- // https://github.com/GoogleCloudPlatform/google-cloud-node/blob/116436fa789d8b0f7fc5100b19b424e3ec63e6bf/packages/common/src/grpc-service.js#L355
- stream.on('metadata', metadata => {
- // Create a response object with succeeds.
- // TODO: unify this logic with the decoration of gRPC response when it's
- // added. see: https://github.com/googleapis/gax-nodejs/issues/65
- stream.emit('response', {
- code: 200,
- details: '',
- message: 'OK',
- metadata,
- });
- });
- }
- /**
- * Specifies the target stream.
- * @param {ApiCall} apiCall - the API function to be called.
- * @param {Object} argument - the argument to be passed to the apiCall.
- */
- setStream(apiCall, argument) {
- if (this.type === StreamType.SERVER_STREAMING) {
- const retryStream = retryRequest(null, {
- objectMode: true,
- request: () => {
- if (this._isCancelCalled) {
- if (this.stream) {
- this.stream.cancel();
- }
- return;
- }
- const stream = apiCall(argument, this._callback);
- this.stream = stream;
- this.forwardEvents(stream);
- return stream;
- },
- });
- this.setReadable(retryStream);
- return;
- }
- const stream = apiCall(argument, this._callback);
- this.stream = stream;
- this.forwardEvents(stream);
- if (this.type === StreamType.CLIENT_STREAMING) {
- this.setWritable(stream);
- }
- if (this.type === StreamType.BIDI_STREAMING) {
- this.setReadable(stream);
- this.setWritable(stream);
- }
- if (this._isCancelCalled && this.stream) {
- this.stream.cancel();
- }
- }
-}
-exports.StreamProxy = StreamProxy;
-class GrpcStreamable {
- /**
- * An API caller for methods of gRPC streaming.
- * @private
- * @constructor
- * @param {StreamDescriptor} descriptor - the descriptor of the method structure.
- */
- constructor(descriptor) {
- this.descriptor = descriptor;
- }
- init(settings, callback) {
- return new StreamProxy(this.descriptor.type, callback);
- }
- wrap(func) {
- switch (this.descriptor.type) {
- case StreamType.SERVER_STREAMING:
- return (argument, metadata, options) => {
- return func(argument, metadata, options);
- };
- case StreamType.CLIENT_STREAMING:
- return (argument, metadata, options, callback) => {
- return func(metadata, options, callback);
- };
- case StreamType.BIDI_STREAMING:
- return (argument, metadata, options) => {
- return func(metadata, options);
- };
- default:
- warnings_1.warn('streaming_wrap_unknown_stream_type', `Unknown stream type: ${this.descriptor.type}`);
- }
- return func;
- }
- call(apiCall, argument, settings, stream) {
- stream.setStream(apiCall, argument);
- }
- fail(stream, err) {
- stream.emit('error', err);
- }
- result(stream) {
- return stream;
- }
-}
-exports.GrpcStreamable = GrpcStreamable;
-class StreamDescriptor {
- /**
- * Describes the structure of gRPC streaming call.
- * @constructor
- * @param {StreamType} streamType - the type of streaming.
- */
- constructor(streamType) {
- this.type = streamType;
- }
- apiCaller(settings) {
- // Right now retrying does not work with gRPC-streaming, because retryable
- // assumes an API call returns an event emitter while gRPC-streaming methods
- // return Stream.
- // TODO: support retrying.
- settings.retry = null;
- return new GrpcStreamable(this);
- }
-}
-exports.StreamDescriptor = StreamDescriptor;
-//# sourceMappingURL=streaming.js.map
\ No newline at end of file

build/src/streaming.js.map

@@ -1 +0,0 @@
-{"version":3,"file":"streaming.js","sourceRoot":"","sources":["../../src/streaming.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAOH,yCAAgC;AAEhC,MAAM,SAAS,GAAyB,OAAO,CAAC,WAAW,CAAC,CAAC;AAC7D,MAAM,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAuB9C;;;GAGG;AACH,IAAY,UASX;AATD,WAAY,UAAU;IACpB,+DAA+D;IAC/D,mEAAoB,CAAA;IAEpB,iEAAiE;IACjE,mEAAoB,CAAA;IAEpB,6CAA6C;IAC7C,+DAAkB,CAAA;AACpB,CAAC,EATW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QASrB;AAED,MAAa,WAAY,SAAQ,SAAS;IAKxC;;;;;;;OAOG;IACH,YAAY,IAAgB,EAAE,QAAqB;QACjD,KAAK,CAAC,SAAS,EAAE,SAAS,E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AkDC;AAED,MAAa,gBAAgB;IAE3B;;;;OAIG;IACH,YAAY,UAAsB;QAChC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;IAED,SAAS,CAAC,QAAuB;QAC/B,0EAA0E;QAC1E,4EAA4E;QAC5E,iBAAiB;QACjB,0BAA0B;QAC1B,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC;QACtB,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACF;AAnBD,4CAmBC"}
\ No newline at end of file

build/src/warnings.d.ts

@@ -1,16 +1 @@
-/**
- * Copyright 2019 Google LLC. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
export declare function warn(code: string, message: string): void;

build/src/warnings.js

@@ -1,18 +1,33 @@
"use strict";
-/**
- * Copyright 2019 Google LLC. All Rights Reserved.
+/*
+ * Copyright 2019 Google LLC
+ * All rights reserved.
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
Object.defineProperty(exports, "__esModule", { value: true });
const isbrowser_1 = require("./isbrowser");

build/src/warnings.js.map

@@ -1 +1 @@
-{"version":3,"file":"warnings.js","sourceRoot":"","sources":["../../src/warnings.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAGH,2CAAsC;AAEtC,MAAM,eAAe,GAAG,IAAI,GAAG,EAAU,CAAC;AAE1C,SAAgB,IAAI,CAAC,IAAY,EAAE,OAAe;IAChD,iCAAiC;IACjC,IAAI,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QAC7B,OAAO;KACR;IACD,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAE1B,IAAI,qBAAS,EAAE,EAAE;QACf,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KACvB;SAAM;QACL,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;KAC9B;AACH,CAAC;AAZD,oBAYC"}
\ No newline at end of file
+{"version":3,"file":"warnings.js","sourceRoot":"","sources":["../../src/warnings.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAGH,2CAAsC;AAEtC,MAAM,eAAe,GAAG,IAAI,GAAG,EAAU,CAAC;AAE1C,SAAgB,IAAI,CAAC,IAAY,EAAE,OAAe;IAChD,iCAAiC;IACjC,IAAI,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QAC7B,OAAO;KACR;IACD,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAE1B,IAAI,qBAAS,EAAE,EAAE;QACf,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KACvB;SAAM;QACL,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;KAC9B;AACH,CAAC;AAZD,oBAYC"}
\ No newline at end of file

CHANGELOG.md

@@ -4,6 +4,35 @@
[1]: https://www.npmjs.com/package/gax-nodejs?activeTab=versions
+## v0.26.0
+
+04-30-2019 20:45 PDT
+
+### Implementation Changes
+
+- refactor: a huge refactor of call handling ([#467](https://github.com/googleapis/gax-nodejs/pull/467))
+- feat: do not use legacy grpc loadObject ([#477](https://github.com/googleapis/gax-nodejs/pull/477))
+
+### New Features
+
+- feat: turned google-proto-files into a dev dependency ([#470](https://github.com/googleapis/gax-nodejs/pull/470))
+
+### Dependencies
+
+- chore(deps): unpin grpc ([#475](https://github.com/googleapis/gax-nodejs/pull/475))
+- fix: pin grpc 1.20.0 ([#474](https://github.com/googleapis/gax-nodejs/pull/474))
+- chore(deps): update dependency nyc to v14 ([#468](https://github.com/googleapis/gax-nodejs/pull/468))
+- fix(deps): update dependency @grpc/proto-loader to ^0.5.0 ([#466](https://github.com/googleapis/gax-nodejs/pull/466))
+- chore(deps): update dependency mocha to ~6.1.0 ([#464](https://github.com/googleapis/gax-nodejs/pull/464))
+- chore(deps): update dependency typescript to ~3.4.0
+- chore(deps): update dependency @types/semver to v6
+
+### Internal / Testing Changes
+
+- test: end-to-end system test ([#471](https://github.com/googleapis/gax-nodejs/pull/471))
+- update to .nycrc with --all enabled ([#476](https://github.com/googleapis/gax-nodejs/pull/476))
+- test: better return type for typescript 3.4.0 ([#463](https://github.com/googleapis/gax-nodejs/pull/463))
+
## v0.25.6
03-28-2019 21:27 PDT

package.json

@@ -1,19 +1,19 @@
{
"name": "google-gax",
- "version": "0.25.6",
+ "version": "0.26.0",
"description": "Google API Extensions",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
"files": [
- "build/src"
+ "build/src",
+ "protos"
],
"dependencies": {
"@grpc/grpc-js": "^0.3.0",
- "@grpc/proto-loader": "^0.4.0",
+ "@grpc/proto-loader": "^0.5.0",
"duplexify": "^3.6.0",
"google-auth-library": "^3.0.0",
- "google-proto-files": "^0.20.0",
- "grpc": "^1.16.0",
+ "grpc": "^1.20.2",
"grpc-gcp": "^0.1.1",
"is-stream-ended": "^0.1.4",
"lodash.at": "^4.6.0",
@@ -26,14 +26,16 @@
"devDependencies": {
"@compodoc/compodoc": "^1.1.7",
"@types/chai": "^4.1.3",
+ "@types/execa": "^0.9.0",
"@types/lodash.at": "^4.6.4",
"@types/lodash.has": "^4.5.4",
"@types/mocha": "^5.2.1",
+ "@types/ncp": "^2.0.1",
"@types/node": "^10.3.2",
"@types/proxyquire": "^1.3.28",
"@types/pumpify": "^1.4.1",
"@types/rimraf": "^2.0.2",
- "@types/semver": "^5.5.0",
+ "@types/semver": "^6.0.0",
"@types/sinon": "^7.0.0",
"@types/source-map-support": "^0.5.0",
"@types/through2": "^2.0.33",
@@ -44,11 +46,15 @@
"eslint-config-prettier": "^4.0.0",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-prettier": "^3.0.0",
+ "execa": "^1.0.0",
+ "fs-extra": "^7.0.1",
+ "google-proto-files": "^0.20.0",
"gts": "^0.9.0",
"intelli-espower-loader": "^1.0.1",
"linkinator": "^1.1.2",
- "mocha": "~6.0.0",
- "nyc": "^13.1.0",
+ "mocha": "^6.1.0",
+ "ncp": "^2.0.0",
+ "nyc": "^14.0.0",
"pegjs": "~0.10.0",
"prettier": "^1.15.2",
"proxyquire": "^2.0.1",
@@ -58,21 +64,21 @@
"source-map-support": "^0.5.6",
"stream-events": "^1.0.4",
"through2": "^3.0.0",
- "typescript": "~3.3.0"
+ "typescript": "~3.4.0"
},
"scripts": {
"codecov": "nyc mocha build/test --reporter spec --slow 500 && codecov",
"docs": "compodoc src/",
"gen-parser": "pegjs src/pathTemplateParser.pegjs",
- "pretest": "npm run compile",
+ "pretest": "npm run prepare",
"test": "cross-env GOOGLE_CLOUD_USE_GRPC_JS=1 nyc mocha build/test && mocha build/test",
"lint": "gts check && eslint samples/*.js samples/**/*.js",
"clean": "gts clean",
"compile": "tsc -p . && cp src/*.json build/src && cp src/*.js build/src",
"fix": "gts fix && eslint --fix samples/*.js samples/**/*.js",
- "prepare": "npm run compile",
+ "prepare": "npm run compile && node ./build/tools/prepublish.js",
"posttest": "npm run lint",
- "system-test": "nyc mocha build/system-test --timeout 120000",
+ "system-test": "nyc mocha build/system-test/test.*.js --timeout 120000",
"samples-test": "echo no sample tests 😱",
"docs-test": "linkinator docs -r --skip www.googleapis.com",
"predocs-test": "npm run docs"

protos/google/api/annotations.proto

@@ -0,0 +1,31 @@
+// Copyright (c) 2015, Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.api;
+
+import "google/api/http.proto";
+import "google/protobuf/descriptor.proto";
+
+option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
+option java_multiple_files = true;
+option java_outer_classname = "AnnotationsProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+extend google.protobuf.MethodOptions {
+ // See `HttpRule`.
+ HttpRule http = 72295728;
+}

protos/google/api/auth.proto

@@ -0,0 +1,187 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+import "google/api/annotations.proto";
+
+option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig";
+option java_multiple_files = true;
+option java_outer_classname = "AuthProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// `Authentication` defines the authentication configuration for an API.
+//
+// Example for an API targeted for external use:
+//
+// name: calendar.googleapis.com
+// authentication:
+// providers:
+// - id: google_calendar_auth
+// jwks_uri: https://www.googleapis.com/oauth2/v1/certs
+// issuer: https://securetoken.google.com
+// rules:
+// - selector: "*"
+// requirements:
+// provider_id: google_calendar_auth
+message Authentication {
+ // A list of authentication rules that apply to individual API methods.
+ //
+ // **NOTE:** All service configuration rules follow "last one wins" order.
+ repeated AuthenticationRule rules = 3;
+
+ // Defines a set of authentication providers that a service supports.
+ repeated AuthProvider providers = 4;
+}
+
+// Authentication rules for the service.
+//
+// By default, if a method has any authentication requirements, every request
+// must include a valid credential matching one of the requirements.
+// It's an error to include more than one kind of credential in a single
+// request.
+//
+// If a method doesn't have any auth requirements, request credentials will be
+// ignored.
+message AuthenticationRule {
+ // Selects the methods to which this rule applies.
+ //
+ // Refer to [selector][google.api.DocumentationRule.selector] for syntax
+ // details.
+ string selector = 1;
+
+ // The requirements for OAuth credentials.
+ OAuthRequirements oauth = 2;
+
+ // If true, the service accepts API keys without any other credential.
+ bool allow_without_credential = 5;
+
+ // Requirements for additional authentication providers.
+ repeated AuthRequirement requirements = 7;
+}
+
+// Configuration for an anthentication provider, including support for
+// [JSON Web Token
+// (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32).
+message AuthProvider {
+ // The unique identifier of the auth provider. It will be referred to by
+ // `AuthRequirement.provider_id`.
+ //
+ // Example: "bookstore_auth".
+ string id = 1;
+
+ // Identifies the principal that issued the JWT. See
+ // https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.1
+ // Usually a URL or an email address.
+ //
+ // Example: https://securetoken.google.com
+ // Example: 1234567-compute@developer.gserviceaccount.com
+ string issuer = 2;
+
+ // URL of the provider's public key set to validate signature of the JWT. See
+ // [OpenID
+ // Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata).
+ // Optional if the key set document:
+ // - can be retrieved from
+ // [OpenID
+ // Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html of
+ // the issuer.
+ // - can be inferred from the email domain of the issuer (e.g. a Google
+ // service account).
+ //
+ // Example: https://www.googleapis.com/oauth2/v1/certs
+ string jwks_uri = 3;
+
+ // The list of JWT
+ // [audiences](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.3).
+ // that are allowed to access. A JWT containing any of these audiences will
+ // be accepted. When this setting is absent, only JWTs with audience
+ // "https://[Service_name][google.api.Service.name]/[API_name][google.protobuf.Api.name]"
+ // will be accepted. For example, if no audiences are in the setting,
+ // LibraryService API will only accept JWTs with the following audience
+ // "https://library-example.googleapis.com/google.example.library.v1.LibraryService".
+ //
+ // Example:
+ //
+ // audiences: bookstore_android.apps.googleusercontent.com,
+ // bookstore_web.apps.googleusercontent.com
+ string audiences = 4;
+
+ // Redirect URL if JWT token is required but not present or is expired.
+ // Implement authorizationUrl of securityDefinitions in OpenAPI spec.
+ string authorization_url = 5;
+}
+
+// OAuth scopes are a way to define data and permissions on data. For example,
+// there are scopes defined for "Read-only access to Google Calendar" and
+// "Access to Cloud Platform". Users can consent to a scope for an application,
+// giving it permission to access that data on their behalf.
+//
+// OAuth scope specifications should be fairly coarse grained; a user will need
+// to see and understand the text description of what your scope means.
+//
+// In most cases: use one or at most two OAuth scopes for an entire family of
+// products. If your product has multiple APIs, you should probably be sharing
+// the OAuth scope across all of those APIs.
+//
+// When you need finer grained OAuth consent screens: talk with your product
+// management about how developers will use them in practice.
+//
+// Please note that even though each of the canonical scopes is enough for a
+// request to be accepted and passed to the backend, a request can still fail
+// due to the backend requiring additional scopes or permissions.
+message OAuthRequirements {
+ // The list of publicly documented OAuth scopes that are allowed access. An
+ // OAuth token containing any of these scopes will be accepted.
+ //
+ // Example:
+ //
+ // canonical_scopes: https://www.googleapis.com/auth/calendar,
+ // https://www.googleapis.com/auth/calendar.read
+ string canonical_scopes = 1;
+}
+
+// User-defined authentication requirements, including support for
+// [JSON Web Token
+// (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32).
+message AuthRequirement {
+ // [id][google.api.AuthProvider.id] from authentication provider.
+ //
+ // Example:
+ //
+ // provider_id: bookstore_auth
+ string provider_id = 1;
+
+ // NOTE: This will be deprecated soon, once AuthProvider.audiences is
+ // implemented and accepted in all the runtime components.
+ //
+ // The list of JWT
+ // [audiences](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.3).
+ // that are allowed to access. A JWT containing any of these audiences will
+ // be accepted. When this setting is absent, only JWTs with audience
+ // "https://[Service_name][google.api.Service.name]/[API_name][google.protobuf.Api.name]"
+ // will be accepted. For example, if no audiences are in the setting,
+ // LibraryService API will only accept JWTs with the following audience
+ // "https://library-example.googleapis.com/google.example.library.v1.LibraryService".
+ //
+ // Example:
+ //
+ // audiences: bookstore_android.apps.googleusercontent.com,
+ // bookstore_web.apps.googleusercontent.com
+ string audiences = 2;
+}

protos/google/api/backend.proto

@@ -0,0 +1,128 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig";
+option java_multiple_files = true;
+option java_outer_classname = "BackendProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// `Backend` defines the backend configuration for a service.
+message Backend {
+ // A list of API backend rules that apply to individual API methods.
+ //
+ // **NOTE:** All service configuration rules follow "last one wins" order.
+ repeated BackendRule rules = 1;
+}
+
+// A backend rule provides configuration for an individual API element.
+message BackendRule {
+ // Path Translation specifies how to combine the backend address with the
+ // request path in order to produce the appropriate forwarding URL for the
+ // request.
+ //
+ // Path Translation is applicable only to HTTP-based backends. Backends which
+ // do not accept requests over HTTP/HTTPS should leave `path_translation`
+ // unspecified.
+ enum PathTranslation {
+ PATH_TRANSLATION_UNSPECIFIED = 0;
+
+ // Use the backend address as-is, with no modification to the path. If the
+ // URL pattern contains variables, the variable names and values will be
+ // appended to the query string. If a query string parameter and a URL
+ // pattern variable have the same name, this may result in duplicate keys in
+ // the query string.
+ //
+ // # Examples
+ //
+ // Given the following operation config:
+ //
+ // Method path: /api/company/{cid}/user/{uid}
+ // Backend address: https://example.cloudfunctions.net/getUser
+ //
+ // Requests to the following request paths will call the backend at the
+ // translated path:
+ //
+ // Request path: /api/company/widgetworks/user/johndoe
+ // Translated:
+ // https://example.cloudfunctions.net/getUser?cid=widgetworks&uid=johndoe
+ //
+ // Request path: /api/company/widgetworks/user/johndoe?timezone=EST
+ // Translated:
+ // https://example.cloudfunctions.net/getUser?timezone=EST&cid=widgetworks&uid=johndoe
+ CONSTANT_ADDRESS = 1;
+
+ // The request path will be appended to the backend address.
+ //
+ // # Examples
+ //
+ // Given the following operation config:
+ //
+ // Method path: /api/company/{cid}/user/{uid}
+ // Backend address: https://example.appspot.com
+ //
+ // Requests to the following request paths will call the backend at the
+ // translated path:
+ //
+ // Request path: /api/company/widgetworks/user/johndoe
+ // Translated:
+ // https://example.appspot.com/api/company/widgetworks/user/johndoe
+ //
+ // Request path: /api/company/widgetworks/user/johndoe?timezone=EST
+ // Translated:
+ // https://example.appspot.com/api/company/widgetworks/user/johndoe?timezone=EST
+ APPEND_PATH_TO_ADDRESS = 2;
+ }
+
+ // Selects the methods to which this rule applies.
+ //
+ // Refer to [selector][google.api.DocumentationRule.selector] for syntax
+ // details.
+ string selector = 1;
+
+ // The address of the API backend.
+ string address = 2;
+
+ // The number of seconds to wait for a response from a request. The default
+ // deadline for gRPC is infinite (no deadline) and HTTP requests is 5 seconds.
+ double deadline = 3;
+
+ // Minimum deadline in seconds needed for this method. Calls having deadline
+ // value lower than this will be rejected.
+ double min_deadline = 4;
+
+ // The number of seconds to wait for the completion of a long running
+ // operation. The default is no deadline.
+ double operation_deadline = 5;
+
+ PathTranslation path_translation = 6;
+
+ // Authentication settings used by the backend.
+ //
+ // These are typically used to provide service management functionality to
+ // a backend served on a publicly-routable URL. The `authentication`
+ // details should match the authentication behavior used by the backend.
+ //
+ // For example, specifying `jwt_audience` implies that the backend expects
+ // authentication via a JWT.
+ oneof authentication {
+ // The JWT audience is used when generating a JWT id token for the backend.
+ string jwt_audience = 7;
+ }
+}

protos/google/api/billing.proto

@@ -0,0 +1,70 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+import "google/api/annotations.proto";
+import "google/api/metric.proto";
+
+option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig";
+option java_multiple_files = true;
+option java_outer_classname = "BillingProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// Billing related configuration of the service.
+//
+// The following example shows how to configure monitored resources and metrics
+// for billing:
+//
+// monitored_resources:
+// - type: library.googleapis.com/branch
+// labels:
+// - key: /city
+// description: The city where the library branch is located in.
+// - key: /name
+// description: The name of the branch.
+// metrics:
+// - name: library.googleapis.com/book/borrowed_count
+// metric_kind: DELTA
+// value_type: INT64
+// billing:
+// consumer_destinations:
+// - monitored_resource: library.googleapis.com/branch
+// metrics:
+// - library.googleapis.com/book/borrowed_count
+message Billing {
+ // Configuration of a specific billing destination (Currently only support
+ // bill against consumer project).
+ message BillingDestination {
+ // The monitored resource type. The type must be defined in
+ // [Service.monitored_resources][google.api.Service.monitored_resources]
+ // section.
+ string monitored_resource = 1;
+
+ // Names of the metrics to report to this billing destination.
+ // Each name must be defined in
+ // [Service.metrics][google.api.Service.metrics] section.
+ repeated string metrics = 2;
+ }
+
+ // Billing configurations for sending metrics to the consumer project.
+ // There can be multiple consumer destinations per service, each one must have
+ // a different monitored resource type. A metric can be used in at most
+ // one consumer destination.
+ repeated BillingDestination consumer_destinations = 8;
+}

protos/google/api/client.proto

@@ -0,0 +1,100 @@
+// Copyright 2019 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+import "google/protobuf/descriptor.proto";
+
+option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
+option java_multiple_files = true;
+option java_outer_classname = "ClientProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+extend google.protobuf.MethodOptions {
+ // A definition of a client library method signature.
+ //
+ // In client libraries, each proto RPC corresponds to one or more methods
+ // which the end user is able to call, and calls the underlying RPC.
+ // Normally, this method receives a single argument (a struct or instance
+ // corresponding to the RPC request object). Defining this field will
+ // add one or more overloads providing flattened or simpler method signatures
+ // in some languages.
+ //
+ // The fields on the method signature are provided as a comma-separated
+ // string.
+ //
+ // For example, the proto RPC and annotation:
+ //
+ // rpc CreateSubscription(CreateSubscriptionRequest)
+ // returns (Subscription) {
+ // option (google.api.method_signature) = "name,topic";
+ // }
+ //
+ // Would add the following Java overload (in addition to the method accepting
+ // the request object):
+ //
+ // public final Subscription createSubscription(String name, String topic)
+ //
+ // The following backwards-compatibility guidelines apply:
+ //
+ // * Adding this annotation to an unannotated method is backwards
+ // compatible.
+ // * Adding this annotation to a method which already has existing
+ // method signature annotations is backwards compatible if and only if
+ // the new method signature annotation is last in the sequence.
+ // * Modifying or removing an existing method signature annotation is
+ // a breaking change.
+ // * Re-ordering existing method signature annotations is a breaking
+ // change.
+ repeated string method_signature = 1051;
+}
+
+extend google.protobuf.ServiceOptions {
+ // The hostname for this service.
+ // This should be specified with no prefix or protocol.
+ //
+ // Example:
+ //
+ // service Foo {
+ // option (google.api.default_host) = "foo.googleapi.com";
+ // ...
+ // }
+ string default_host = 1049;
+
+ // OAuth scopes needed for the client.
+ //
+ // Example:
+ //
+ // service Foo {
+ // option (google.api.oauth_scopes) = \
+ // "https://www.googleapis.com/auth/cloud-platform";
+ // ...
+ // }
+ //
+ // If there is more than one scope, use a comma-separated string:
+ //
+ // Example:
+ //
+ // service Foo {
+ // option (google.api.oauth_scopes) = \
+ // "https://www.googleapis.com/auth/cloud-platform,"
+ // "https://www.googleapis.com/auth/monitoring";
+ // ...
+ // }
+ string oauth_scopes = 1050;
+}

protos/google/api/config_change.proto

@@ -0,0 +1,86 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+option go_package = "google.golang.org/genproto/googleapis/api/configchange;configchange";
+option java_multiple_files = true;
+option java_outer_classname = "ConfigChangeProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// Output generated from semantically comparing two versions of a service
+// configuration.
+//
+// Includes detailed information about a field that have changed with
+// applicable advice about potential consequences for the change, such as
+// backwards-incompatibility.
+message ConfigChange {
+ // Object hierarchy path to the change, with levels separated by a '.'
+ // character. For repeated fields, an applicable unique identifier field is
+ // used for the index (usually selector, name, or id). For maps, the term
+ // 'key' is used. If the field has no unique identifier, the numeric index
+ // is used.
+ // Examples:
+ // -
+ // visibility.rules[selector=="google.LibraryService.CreateBook"].restriction
+ // - quota.metric_rules[selector=="google"].metric_costs[key=="reads"].value
+ // - logging.producer_destinations[0]
+ string element = 1;
+
+ // Value of the changed object in the old Service configuration,
+ // in JSON format. This field will not be populated if ChangeType == ADDED.
+ string old_value = 2;
+
+ // Value of the changed object in the new Service configuration,
+ // in JSON format. This field will not be populated if ChangeType == REMOVED.
+ string new_value = 3;
+
+ // The type for this change, either ADDED, REMOVED, or MODIFIED.
+ ChangeType change_type = 4;
+
+ // Collection of advice provided for this change, useful for determining the
+ // possible impact of this change.
+ repeated Advice advices = 5;
+}
+
+// Generated advice about this change, used for providing more
+// information about how a change will affect the existing service.
+message Advice {
+ // Useful description for why this advice was applied and what actions should
+ // be taken to mitigate any implied risks.
+ string description = 2;
+}
+
+// Classifies set of possible modifications to an object in the service
+// configuration.
+enum ChangeType {
+ // No value was provided.
+ CHANGE_TYPE_UNSPECIFIED = 0;
+
+ // The changed object exists in the 'new' service configuration, but not
+ // in the 'old' service configuration.
+ ADDED = 1;
+
+ // The changed object exists in the 'old' service configuration, but not
+ // in the 'new' service configuration.
+ REMOVED = 2;
+
+ // The changed object exists in both service configurations, but its value
+ // is different.
+ MODIFIED = 3;
+}

protos/google/api/consumer.proto

@@ -0,0 +1,82 @@
+// Copyright 2016 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.api;
+
+option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig";
+option java_multiple_files = true;
+option java_outer_classname = "ConsumerProto";
+option java_package = "com.google.api";
+
+// A descriptor for defining project properties for a service. One service may
+// have many consumer projects, and the service may want to behave differently
+// depending on some properties on the project. For example, a project may be
+// associated with a school, or a business, or a government agency, a business
+// type property on the project may affect how a service responds to the client.
+// This descriptor defines which properties are allowed to be set on a project.
+//
+// Example:
+//
+// project_properties:
+// properties:
+// - name: NO_WATERMARK
+// type: BOOL
+// description: Allows usage of the API without watermarks.
+// - name: EXTENDED_TILE_CACHE_PERIOD
+// type: INT64
+message ProjectProperties {
+ // List of per consumer project-specific properties.
+ repeated Property properties = 1;
+}
+
+// Defines project properties.
+//
+// API services can define properties that can be assigned to consumer projects
+// so that backends can perform response customization without having to make
+// additional calls or maintain additional storage. For example, Maps API
+// defines properties that controls map tile cache period, or whether to embed a
+// watermark in a result.
+//
+// These values can be set via API producer console. Only API providers can
+// define and set these properties.
+message Property {
+ // Supported data type of the property values
+ enum PropertyType {
+ // The type is unspecified, and will result in an error.
+ UNSPECIFIED = 0;
+
+ // The type is `int64`.
+ INT64 = 1;
+
+ // The type is `bool`.
+ BOOL = 2;
+
+ // The type is `string`.
+ STRING = 3;
+
+ // The type is 'double'.
+ DOUBLE = 4;
+ }
+
+ // The name of the property (a.k.a key).
+ string name = 1;
+
+ // The type of this property.
+ PropertyType type = 2;
+
+ // The description of the property
+ string description = 3;
+}

protos/google/api/context.proto

@@ -0,0 +1,91 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig";
+option java_multiple_files = true;
+option java_outer_classname = "ContextProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// `Context` defines which contexts an API requests.
+//
+// Example:
+//
+// context:
+// rules:
+// - selector: "*"
+// requested:
+// - google.rpc.context.ProjectContext
+// - google.rpc.context.OriginContext
+//
+// The above specifies that all methods in the API request
+// `google.rpc.context.ProjectContext` and
+// `google.rpc.context.OriginContext`.
+//
+// Available context types are defined in package
+// `google.rpc.context`.
+//
+// This also provides mechanism to whitelist any protobuf message extension that
+// can be sent in grpc metadata using “x-goog-ext-<extension_id>-bin” and
+// “x-goog-ext-<extension_id>-jspb” format. For example, list any service
+// specific protobuf types that can appear in grpc metadata as follows in your
+// yaml file:
+//
+// Example:
+//
+// context:
+// rules:
+// - selector: "google.example.library.v1.LibraryService.CreateBook"
+// allowed_request_extensions:
+// - google.foo.v1.NewExtension
+// allowed_response_extensions:
+// - google.foo.v1.NewExtension
+//
+// You can also specify extension ID instead of fully qualified extension name
+// here.
+message Context {
+ // A list of RPC context rules that apply to individual API methods.
+ //
+ // **NOTE:** All service configuration rules follow "last one wins" order.
+ repeated ContextRule rules = 1;
+}
+
+// A context rule provides information about the context for an individual API
+// element.
+message ContextRule {
+ // Selects the methods to which this rule applies.
+ //
+ // Refer to [selector][google.api.DocumentationRule.selector] for syntax
+ // details.
+ string selector = 1;
+
+ // A list of full type names of requested contexts.
+ repeated string requested = 2;
+
+ // A list of full type names of provided contexts.
+ repeated string provided = 3;
+
+ // A list of full type names or extension IDs of extensions allowed in grpc
+ // side channel from client to backend.
+ repeated string allowed_request_extensions = 4;
+
+ // A list of full type names or extension IDs of extensions allowed in grpc
+ // side channel from backend to client.
+ repeated string allowed_response_extensions = 5;
+}

protos/google/api/control.proto

@@ -0,0 +1,33 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig";
+option java_multiple_files = true;
+option java_outer_classname = "ControlProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// Selects and configures the service controller used by the service. The
+// service controller handles features like abuse, quota, billing, logging,
+// monitoring, etc.
+message Control {
+ // The service control environment to use. If empty, no control plane
+ // feature (like quota and billing) will be enabled.
+ string environment = 1;
+}

protos/google/api/distribution.proto

@@ -0,0 +1,212 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+import "google/protobuf/any.proto";
+import "google/protobuf/timestamp.proto";
+
+option go_package = "google.golang.org/genproto/googleapis/api/distribution;distribution";
+option java_multiple_files = true;
+option java_outer_classname = "DistributionProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// `Distribution` contains summary statistics for a population of values. It
+// optionally contains a histogram representing the distribution of those values
+// across a set of buckets.
+//
+// The summary statistics are the count, mean, sum of the squared deviation from
+// the mean, the minimum, and the maximum of the set of population of values.
+// The histogram is based on a sequence of buckets and gives a count of values
+// that fall into each bucket. The boundaries of the buckets are given either
+// explicitly or by formulas for buckets of fixed or exponentially increasing
+// widths.
+//
+// Although it is not forbidden, it is generally a bad idea to include
+// non-finite values (infinities or NaNs) in the population of values, as this
+// will render the `mean` and `sum_of_squared_deviation` fields meaningless.
+message Distribution {
+ // The range of the population values.
+ message Range {
+ // The minimum of the population values.
+ double min = 1;
+
+ // The maximum of the population values.
+ double max = 2;
+ }
+
+ // `BucketOptions` describes the bucket boundaries used to create a histogram
+ // for the distribution. The buckets can be in a linear sequence, an
+ // exponential sequence, or each bucket can be specified explicitly.
+ // `BucketOptions` does not include the number of values in each bucket.
+ //
+ // A bucket has an inclusive lower bound and exclusive upper bound for the
+ // values that are counted for that bucket. The upper bound of a bucket must
+ // be strictly greater than the lower bound. The sequence of N buckets for a
+ // distribution consists of an underflow bucket (number 0), zero or more
+ // finite buckets (number 1 through N - 2) and an overflow bucket (number N -
+ // 1). The buckets are contiguous: the lower bound of bucket i (i > 0) is the
+ // same as the upper bound of bucket i - 1. The buckets span the whole range
+ // of finite values: lower bound of the underflow bucket is -infinity and the
+ // upper bound of the overflow bucket is +infinity. The finite buckets are
+ // so-called because both bounds are finite.
+ message BucketOptions {
+ // Specifies a linear sequence of buckets that all have the same width
+ // (except overflow and underflow). Each bucket represents a constant
+ // absolute uncertainty on the specific value in the bucket.
+ //
+ // There are `num_finite_buckets + 2` (= N) buckets. Bucket `i` has the
+ // following boundaries:
+ //
+ // Upper bound (0 <= i < N-1): offset + (width * i).
+ // Lower bound (1 <= i < N): offset + (width * (i - 1)).
+ message Linear {
+ // Must be greater than 0.
+ int32 num_finite_buckets = 1;
+
+ // Must be greater than 0.
+ double width = 2;
+
+ // Lower bound of the first bucket.
+ double offset = 3;
+ }
+
+ // Specifies an exponential sequence of buckets that have a width that is
+ // proportional to the value of the lower bound. Each bucket represents a
+ // constant relative uncertainty on a specific value in the bucket.
+ //
+ // There are `num_finite_buckets + 2` (= N) buckets. Bucket `i` has the
+ // following boundaries:
+ //
+ // Upper bound (0 <= i < N-1): scale * (growth_factor ^ i).
+ // Lower bound (1 <= i < N): scale * (growth_factor ^ (i - 1)).
+ message Exponential {
+ // Must be greater than 0.
+ int32 num_finite_buckets = 1;
+
+ // Must be greater than 1.
+ double growth_factor = 2;
+
+ // Must be greater than 0.
+ double scale = 3;
+ }
+
+ // Specifies a set of buckets with arbitrary widths.
+ //
+ // There are `size(bounds) + 1` (= N) buckets. Bucket `i` has the following
+ // boundaries:
+ //
+ // Upper bound (0 <= i < N-1): bounds[i]
+ // Lower bound (1 <= i < N); bounds[i - 1]
+ //
+ // The `bounds` field must contain at least one element. If `bounds` has
+ // only one element, then there are no finite buckets, and that single
+ // element is the common boundary of the overflow and underflow buckets.
+ message Explicit {
+ // The values must be monotonically increasing.
+ repeated double bounds = 1;
+ }
+
+ // Exactly one of these three fields must be set.
+ oneof options {
+ // The linear bucket.
+ Linear linear_buckets = 1;
+
+ // The exponential buckets.
+ Exponential exponential_buckets = 2;
+
+ // The explicit buckets.
+ Explicit explicit_buckets = 3;
+ }
+ }
+
+ // Exemplars are example points that may be used to annotate aggregated
+ // distribution values. They are metadata that gives information about a
+ // particular value added to a Distribution bucket, such as a trace ID that
+ // was active when a value was added. They may contain further information,
+ // such as a example values and timestamps, origin, etc.
+ message Exemplar {
+ // Value of the exemplar point. This value determines to which bucket the
+ // exemplar belongs.
+ double value = 1;
+
+ // The observation (sampling) time of the above value.
+ google.protobuf.Timestamp timestamp = 2;
+
+ // Contextual information about the example value. Examples are:
+ //
+ // Trace ID: type.googleapis.com/google.devtools.cloudtrace.v1.Trace
+ //
+ // Literal string: type.googleapis.com/google.protobuf.StringValue
+ //
+ // Labels dropped during aggregation:
+ // type.googleapis.com/google.monitoring.v3.DroppedLabels
+ //
+ // There may be only a single attachment of any given message type in a
+ // single exemplar, and this is enforced by the system.
+ repeated google.protobuf.Any attachments = 3;
+ }
+
+ // The number of values in the population. Must be non-negative. This value
+ // must equal the sum of the values in `bucket_counts` if a histogram is
+ // provided.
+ int64 count = 1;
+
+ // The arithmetic mean of the values in the population. If `count` is zero
+ // then this field must be zero.
+ double mean = 2;
+
+ // The sum of squared deviations from the mean of the values in the
+ // population. For values x_i this is:
+ //
+ // Sum[i=1..n]((x_i - mean)^2)
+ //
+ // Knuth, "The Art of Computer Programming", Vol. 2, page 323, 3rd edition
+ // describes Welford's method for accumulating this sum in one pass.
+ //
+ // If `count` is zero then this field must be zero.
+ double sum_of_squared_deviation = 3;
+
+ // If specified, contains the range of the population values. The field
+ // must not be present if the `count` is zero.
+ Range range = 4;
+
+ // Defines the histogram bucket boundaries. If the distribution does not
+ // contain a histogram, then omit this field.
+ BucketOptions bucket_options = 6;
+
+ // The number of values in each bucket of the histogram, as described in
+ // `bucket_options`. If the distribution does not have a histogram, then omit
+ // this field. If there is a histogram, then the sum of the values in
+ // `bucket_counts` must equal the value in the `count` field of the
+ // distribution.
+ //
+ // If present, `bucket_counts` should contain N values, where N is the number
+ // of buckets specified in `bucket_options`. If you supply fewer than N
+ // values, the remaining values are assumed to be 0.
+ //
+ // The order of the values in `bucket_counts` follows the bucket numbering
+ // schemes described for the three bucket types. The first value must be the
+ // count for the underflow bucket (number 0). The next N-2 values are the
+ // counts for the finite buckets (number 1 through N-2). The N'th value in
+ // `bucket_counts` is the count for the overflow bucket (number N-1).
+ repeated int64 bucket_counts = 7;
+
+ // Must be in increasing order of `value` field.
+ repeated Exemplar exemplars = 10;
+}

protos/google/api/documentation.proto

@@ -0,0 +1,157 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig";
+option java_multiple_files = true;
+option java_outer_classname = "DocumentationProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// `Documentation` provides the information for describing a service.
+//
+// Example:
+// <pre><code>documentation:
+// summary: >
+// The Google Calendar API gives access
+// to most calendar features.
+// pages:
+// - name: Overview
+// content: &#40;== include google/foo/overview.md ==&#41;
+// - name: Tutorial
+// content: &#40;== include google/foo/tutorial.md ==&#41;
+// subpages;
+// - name: Java
+// content: &#40;== include google/foo/tutorial_java.md ==&#41;
+// rules:
+// - selector: google.calendar.Calendar.Get
+// description: >
+// ...
+// - selector: google.calendar.Calendar.Put
+// description: >
+// ...
+// </code></pre>
+// Documentation is provided in markdown syntax. In addition to
+// standard markdown features, definition lists, tables and fenced
+// code blocks are supported. Section headers can be provided and are
+// interpreted relative to the section nesting of the context where
+// a documentation fragment is embedded.
+//
+// Documentation from the IDL is merged with documentation defined
+// via the config at normalization time, where documentation provided
+// by config rules overrides IDL provided.
+//
+// A number of constructs specific to the API platform are supported
+// in documentation text.
+//
+// In order to reference a proto element, the following
+// notation can be used:
+// <pre><code>&#91;fully.qualified.proto.name]&#91;]</code></pre>
+// To override the display text used for the link, this can be used:
+// <pre><code>&#91;display text]&#91;fully.qualified.proto.name]</code></pre>
+// Text can be excluded from doc using the following notation:
+// <pre><code>&#40;-- internal comment --&#41;</code></pre>
+//
+// A few directives are available in documentation. Note that
+// directives must appear on a single line to be properly
+// identified. The `include` directive includes a markdown file from
+// an external source:
+// <pre><code>&#40;== include path/to/file ==&#41;</code></pre>
+// The `resource_for` directive marks a message to be the resource of
+// a collection in REST view. If it is not specified, tools attempt
+// to infer the resource from the operations in a collection:
+// <pre><code>&#40;== resource_for v1.shelves.books ==&#41;</code></pre>
+// The directive `suppress_warning` does not directly affect documentation
+// and is documented together with service config validation.
+message Documentation {
+ // A short summary of what the service does. Can only be provided by
+ // plain text.
+ string summary = 1;
+
+ // The top level pages for the documentation set.
+ repeated Page pages = 5;
+
+ // A list of documentation rules that apply to individual API elements.
+ //
+ // **NOTE:** All service configuration rules follow "last one wins" order.
+ repeated DocumentationRule rules = 3;
+
+ // The URL to the root of documentation.
+ string documentation_root_url = 4;
+
+ // Declares a single overview page. For example:
+ // <pre><code>documentation:
+ // summary: ...
+ // overview: &#40;== include overview.md ==&#41;
+ // </code></pre>
+ // This is a shortcut for the following declaration (using pages style):
+ // <pre><code>documentation:
+ // summary: ...
+ // pages:
+ // - name: Overview
+ // content: &#40;== include overview.md ==&#41;
+ // </code></pre>
+ // Note: you cannot specify both `overview` field and `pages` field.
+ string overview = 2;
+}
+
+// A documentation rule provides information about individual API elements.
+message DocumentationRule {
+ // The selector is a comma-separated list of patterns. Each pattern is a
+ // qualified name of the element which may end in "*", indicating a wildcard.
+ // Wildcards are only allowed at the end and for a whole component of the
+ // qualified name, i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". To
+ // specify a default for all applicable elements, the whole pattern "*"
+ // is used.
+ string selector = 1;
+
+ // Description of the selected API(s).
+ string description = 2;
+
+ // Deprecation description of the selected element(s). It can be provided if
+ // an element is marked as `deprecated`.
+ string deprecation_description = 3;
+}
+
+// Represents a documentation page. A page can contain subpages to represent
+// nested documentation set structure.
+message Page {
+ // The name of the page. It will be used as an identity of the page to
+ // generate URI of the page, text of the link to this page in navigation,
+ // etc. The full page name (start from the root page name to this page
+ // concatenated with `.`) can be used as reference to the page in your
+ // documentation. For example:
+ // <pre><code>pages:
+ // - name: Tutorial
+ // content: &#40;== include tutorial.md ==&#41;
+ // subpages:
+ // - name: Java
+ // content: &#40;== include tutorial_java.md ==&#41;
+ // </code></pre>
+ // You can reference `Java` page using Markdown reference link syntax:
+ // `[Java][Tutorial.Java]`.
+ string name = 1;
+
+ // The Markdown content of the page. You can use <code>&#40;== include {path}
+ // ==&#41;</code> to include content from a Markdown file.
+ string content = 2;
+
+ // Subpages of this page. The order of subpages specified here will be
+ // honored in the generated docset.
+ repeated Page subpages = 3;
+}

protos/google/api/endpoint.proto

@@ -0,0 +1,72 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+import "google/api/annotations.proto";
+
+option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig";
+option java_multiple_files = true;
+option java_outer_classname = "EndpointProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// `Endpoint` describes a network endpoint that serves a set of APIs.
+// A service may expose any number of endpoints, and all endpoints share the
+// same service configuration, such as quota configuration and monitoring
+// configuration.
+//
+// Example service configuration:
+//
+// name: library-example.googleapis.com
+// endpoints:
+// # Below entry makes 'google.example.library.v1.Library'
+// # API be served from endpoint address library-example.googleapis.com.
+// # It also allows HTTP OPTIONS calls to be passed to the backend, for
+// # it to decide whether the subsequent cross-origin request is
+// # allowed to proceed.
+// - name: library-example.googleapis.com
+// allow_cors: true
+message Endpoint {
+ // The canonical name of this endpoint.
+ string name = 1;
+
+ // DEPRECATED: This field is no longer supported. Instead of using aliases,
+ // please specify multiple [google.api.Endpoint][google.api.Endpoint] for each
+ // of the intended aliases.
+ //
+ // Additional names that this endpoint will be hosted on.
+ repeated string aliases = 2 [deprecated = true];
+
+ // The list of features enabled on this endpoint.
+ repeated string features = 4;
+
+ // The specification of an Internet routable address of API frontend that will
+ // handle requests to this [API
+ // Endpoint](https://cloud.google.com/apis/design/glossary). It should be
+ // either a valid IPv4 address or a fully-qualified domain name. For example,
+ // "8.8.8.8" or "myservice.appspot.com".
+ string target = 101;
+
+ // Allowing
+ // [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing), aka
+ // cross-domain traffic, would allow the backends served from this endpoint to
+ // receive and respond to HTTP OPTIONS requests. The response will be used by
+ // the browser to determine whether the subsequent cross-origin request is
+ // allowed to proceed.
+ bool allow_cors = 5;
+}

protos/google/api/experimental/authorization_config.proto

@@ -0,0 +1,40 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+option go_package = "google.golang.org/genproto/googleapis/api;api";
+option java_multiple_files = true;
+option java_outer_classname = "AuthorizationConfigProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// Configuration of authorization.
+//
+// This section determines the authorization provider, if unspecified, then no
+// authorization check will be done.
+//
+// Example:
+//
+// experimental:
+// authorization:
+// provider: firebaserules.googleapis.com
+message AuthorizationConfig {
+ // The name of the authorization provider, such as
+ // firebaserules.googleapis.com.
+ string provider = 1;
+}

protos/google/api/experimental/experimental.proto

@@ -0,0 +1,34 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+import "google/api/annotations.proto";
+import "google/api/experimental/authorization_config.proto";
+
+option go_package = "google.golang.org/genproto/googleapis/api;api";
+option java_multiple_files = true;
+option java_outer_classname = "ExperimentalProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// Experimental service configuration. These configuration options can
+// only be used by whitelisted users.
+message Experimental {
+ // Authorization configuration.
+ AuthorizationConfig authorization = 8;
+}

protos/google/api/expr/v1alpha1/cel_service.proto

@@ -0,0 +1,44 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api.expr.v1alpha1;
+
+import "google/api/expr/v1alpha1/conformance_service.proto";
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/api/expr/v1alpha1;expr";
+option java_multiple_files = true;
+option java_outer_classname = "CelServiceProto";
+option java_package = "com.google.api.expr.v1alpha1";
+
+// Access a CEL implementation from another process or machine.
+// A CEL implementation is decomposed as a parser, a static checker,
+// and an evaluator. Every CEL implementation is expected to provide
+// a server for this API. The API will be used for conformance testing,
+// utilities, and execution as a service.
+service CelService {
+ // Transforms CEL source text into a parsed representation.
+ rpc Parse(ParseRequest) returns (ParseResponse) {}
+
+ // Runs static checks on a parsed CEL representation and return
+ // an annotated representation, or a set of issues.
+ rpc Check(CheckRequest) returns (CheckResponse) {}
+
+ // Evaluates a parsed or annotation CEL representation given
+ // values of external bindings.
+ rpc Eval(EvalRequest) returns (EvalResponse) {}
+}

protos/google/api/expr/v1alpha1/checked.proto

@@ -0,0 +1,336 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api.expr.v1alpha1;
+
+import "google/api/expr/v1alpha1/syntax.proto";
+import "google/protobuf/empty.proto";
+import "google/protobuf/struct.proto";
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/api/expr/v1alpha1;expr";
+option java_multiple_files = true;
+option java_outer_classname = "DeclProto";
+option java_package = "com.google.api.expr.v1alpha1";
+
+// Protos for representing CEL declarations and typed checked expressions.
+
+// A CEL expression which has been successfully type checked.
+message CheckedExpr {
+ // A map from expression ids to resolved references.
+ //
+ // The following entries are in this table:
+ //
+ // - An Ident or Select expression is represented here if it resolves to a
+ // declaration. For instance, if `a.b.c` is represented by
+ // `select(select(id(a), b), c)`, and `a.b` resolves to a declaration,
+ // while `c` is a field selection, then the reference is attached to the
+ // nested select expression (but not to the id or or the outer select).
+ // In turn, if `a` resolves to a declaration and `b.c` are field selections,
+ // the reference is attached to the ident expression.
+ // - Every Call expression has an entry here, identifying the function being
+ // called.
+ // - Every CreateStruct expression for a message has an entry, identifying
+ // the message.
+ map<int64, Reference> reference_map = 2;
+
+ // A map from expression ids to types.
+ //
+ // Every expression node which has a type different than DYN has a mapping
+ // here. If an expression has type DYN, it is omitted from this map to save
+ // space.
+ map<int64, Type> type_map = 3;
+
+ // The source info derived from input that generated the parsed `expr` and
+ // any optimizations made during the type-checking pass.
+ SourceInfo source_info = 5;
+
+ // The checked expression. Semantically equivalent to the parsed `expr`, but
+ // may have structural differences.
+ Expr expr = 4;
+}
+
+// Represents a CEL type.
+message Type {
+ // List type with typed elements, e.g. `list<example.proto.MyMessage>`.
+ message ListType {
+ // The element type.
+ Type elem_type = 1;
+ }
+
+ // Map type with parameterized key and value types, e.g. `map<string, int>`.
+ message MapType {
+ // The type of the key.
+ Type key_type = 1;
+
+ // The type of the value.
+ Type value_type = 2;
+ }
+
+ // Function type with result and arg types.
+ message FunctionType {
+ // Result type of the function.
+ Type result_type = 1;
+
+ // Argument types of the function.
+ repeated Type arg_types = 2;
+ }
+
+ // Application defined abstract type.
+ message AbstractType {
+ // The fully qualified name of this abstract type.
+ string name = 1;
+
+ // Parameter types for this abstract type.
+ repeated Type parameter_types = 2;
+ }
+
+ // CEL primitive types.
+ enum PrimitiveType {
+ // Unspecified type.
+ PRIMITIVE_TYPE_UNSPECIFIED = 0;
+
+ // Boolean type.
+ BOOL = 1;
+
+ // Int64 type.
+ //
+ // Proto-based integer values are widened to int64.
+ INT64 = 2;
+
+ // Uint64 type.
+ //
+ // Proto-based unsigned integer values are widened to uint64.
+ UINT64 = 3;
+
+ // Double type.
+ //
+ // Proto-based float values are widened to double values.
+ DOUBLE = 4;
+
+ // String type.
+ STRING = 5;
+
+ // Bytes type.
+ BYTES = 6;
+ }
+
+ // Well-known protobuf types treated with first-class support in CEL.
+ enum WellKnownType {
+ // Unspecified type.
+ WELL_KNOWN_TYPE_UNSPECIFIED = 0;
+
+ // Well-known protobuf.Any type.
+ //
+ // Any types are a polymorphic message type. During type-checking they are
+ // treated like `DYN` types, but at runtime they are resolved to a specific
+ // message type specified at evaluation time.
+ ANY = 1;
+
+ // Well-known protobuf.Timestamp type, internally referenced as `timestamp`.
+ TIMESTAMP = 2;
+
+ // Well-known protobuf.Duration type, internally referenced as `duration`.
+ DURATION = 3;
+ }
+
+ // The kind of type.
+ oneof type_kind {
+ // Dynamic type.
+ google.protobuf.Empty dyn = 1;
+
+ // Null value.
+ google.protobuf.NullValue null = 2;
+
+ // Primitive types: `true`, `1u`, `-2.0`, `'string'`, `b'bytes'`.
+ PrimitiveType primitive = 3;
+
+ // Wrapper of a primitive type, e.g. `google.protobuf.Int64Value`.
+ PrimitiveType wrapper = 4;
+
+ // Well-known protobuf type such as `google.protobuf.Timestamp`.
+ WellKnownType well_known = 5;
+
+ // Parameterized list with elements of `list_type`, e.g. `list<timestamp>`.
+ ListType list_type = 6;
+
+ // Parameterized map with typed keys and values.
+ MapType map_type = 7;
+
+ // Function type.
+ FunctionType function = 8;
+
+ // Protocol buffer message type.
+ //
+ // The `message_type` string specifies the qualified message type name. For
+ // example, `google.plus.Profile`.
+ string message_type = 9;
+
+ // Type param type.
+ //
+ // The `type_param` string specifies the type parameter name, e.g. `list<E>`
+ // would be a `list_type` whose element type was a `type_param` type
+ // named `E`.
+ string type_param = 10;
+
+ // Type type.
+ //
+ // The `type` value specifies the target type. e.g. int is type with a
+ // target type of `Primitive.INT`.
+ Type type = 11;
+
+ // Error type.
+ //
+ // During type-checking if an expression is an error, its type is propagated
+ // as the `ERROR` type. This permits the type-checker to discover other
+ // errors present in the expression.
+ google.protobuf.Empty error = 12;
+
+ // Abstract, application defined type.
+ AbstractType abstract_type = 14;
+ }
+}
+
+// Represents a declaration of a named value or function.
+//
+// A declaration is part of the contract between the expression, the agent
+// evaluating that expression, and the caller requesting evaluation.
+message Decl {
+ // Identifier declaration which specifies its type and optional `Expr` value.
+ //
+ // An identifier without a value is a declaration that must be provided at
+ // evaluation time. An identifier with a value should resolve to a constant,
+ // but may be used in conjunction with other identifiers bound at evaluation
+ // time.
+ message IdentDecl {
+ // Required. The type of the identifier.
+ Type type = 1;
+
+ // The constant value of the identifier. If not specified, the identifier
+ // must be supplied at evaluation time.
+ Constant value = 2;
+
+ // Documentation string for the identifier.
+ string doc = 3;
+ }
+
+ // Function declaration specifies one or more overloads which indicate the
+ // function's parameter types and return type, and may optionally specify a
+ // function definition in terms of CEL expressions.
+ //
+ // Functions have no observable side-effects (there may be side-effects like
+ // logging which are not observable from CEL).
+ message FunctionDecl {
+ // An overload indicates a function's parameter types and return type, and
+ // may optionally include a function body described in terms of
+ // [Expr][google.api.expr.v1alpha1.Expr] values.
+ //
+ // Functions overloads are declared in either a function or method
+ // call-style. For methods, the `params[0]` is the expected type of the
+ // target receiver.
+ //
+ // Overloads must have non-overlapping argument types after erasure of all
+ // parameterized type variables (similar as type erasure in Java).
+ message Overload {
+ // Required. Globally unique overload name of the function which reflects
+ // the function name and argument types.
+ //
+ // This will be used by a [Reference][google.api.expr.v1alpha1.Reference]
+ // to indicate the `overload_id` that was resolved for the function
+ // `name`.
+ string overload_id = 1;
+
+ // List of function parameter [Type][google.api.expr.v1alpha1.Type]
+ // values.
+ //
+ // Param types are disjoint after generic type parameters have been
+ // replaced with the type `DYN`. Since the `DYN` type is compatible with
+ // any other type, this means that if `A` is a type parameter, the
+ // function types `int<A>` and `int<int>` are not disjoint. Likewise,
+ // `map<string, string>` is not disjoint from `map<K, V>`.
+ //
+ // When the `result_type` of a function is a generic type param, the
+ // type param name also appears as the `type` of on at least one params.
+ repeated Type params = 2;
+
+ // The type param names associated with the function declaration.
+ //
+ // For example, `function ex<K,V>(K key, map<K, V> map) : V` would yield
+ // the type params of `K, V`.
+ repeated string type_params = 3;
+
+ // Required. The result type of the function. For example, the operator
+ // `string.isEmpty()` would have `result_type` of `kind: BOOL`.
+ Type result_type = 4;
+
+ // Whether the function is to be used in a method call-style `x.f(...)`
+ // of a function call-style `f(x, ...)`.
+ //
+ // For methods, the first parameter declaration, `params[0]` is the
+ // expected type of the target receiver.
+ bool is_instance_function = 5;
+
+ // Documentation string for the overload.
+ string doc = 6;
+ }
+
+ // Required. List of function overloads, must contain at least one overload.
+ repeated Overload overloads = 1;
+ }
+
+ // The fully qualified name of the declaration.
+ //
+ // Declarations are organized in containers and this represents the full path
+ // to the declaration in its container, as in `google.api.expr.Decl`.
+ //
+ // Declarations used as
+ // [FunctionDecl.Overload][google.api.expr.v1alpha1.Decl.FunctionDecl.Overload]
+ // parameters may or may not have a name depending on whether the overload is
+ // function declaration or a function definition containing a result
+ // [Expr][google.api.expr.v1alpha1.Expr].
+ string name = 1;
+
+ // Required. The declaration kind.
+ oneof decl_kind {
+ // Identifier declaration.
+ IdentDecl ident = 2;
+
+ // Function declaration.
+ FunctionDecl function = 3;
+ }
+}
+
+// Describes a resolved reference to a declaration.
+message Reference {
+ // The fully qualified name of the declaration.
+ string name = 1;
+
+ // For references to functions, this is a list of `Overload.overload_id`
+ // values which match according to typing rules.
+ //
+ // If the list has more than one element, overload resolution among the
+ // presented candidates must happen at runtime because of dynamic types. The
+ // type checker attempts to narrow down this list as much as possible.
+ //
+ // Empty if this is not a reference to a
+ // [Decl.FunctionDecl][google.api.expr.v1alpha1.Decl.FunctionDecl].
+ repeated string overload_id = 3;
+
+ // For references to constants, this may contain the value of the
+ // constant if known at compile time.
+ Constant value = 4;
+}

protos/google/api/expr/v1alpha1/conformance_service.proto

@@ -0,0 +1,165 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api.expr.v1alpha1;
+
+import "google/api/expr/v1alpha1/checked.proto";
+import "google/api/expr/v1alpha1/eval.proto";
+import "google/api/expr/v1alpha1/syntax.proto";
+import "google/rpc/status.proto";
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/api/expr/v1alpha1;expr";
+option java_multiple_files = true;
+option java_outer_classname = "ConformanceServiceProto";
+option java_package = "com.google.api.expr.v1alpha1";
+
+// Access a CEL implementation from another process or machine.
+// A CEL implementation is decomposed as a parser, a static checker,
+// and an evaluator. Every CEL implementation is expected to provide
+// a server for this API. The API will be used for conformance testing
+// and other utilities.
+service ConformanceService {
+ // Transforms CEL source text into a parsed representation.
+ rpc Parse(ParseRequest) returns (ParseResponse) {}
+
+ // Runs static checks on a parsed CEL representation and return
+ // an annotated representation, or a set of issues.
+ rpc Check(CheckRequest) returns (CheckResponse) {}
+
+ // Evaluates a parsed or annotation CEL representation given
+ // values of external bindings.
+ rpc Eval(EvalRequest) returns (EvalResponse) {}
+}
+
+// Request message for the Parse method.
+message ParseRequest {
+ // Required. Source text in CEL syntax.
+ string cel_source = 1;
+
+ // Tag for version of CEL syntax, for future use.
+ string syntax_version = 2;
+
+ // File or resource for source text, used in
+ // [SourceInfo][google.api.expr.v1alpha1.SourceInfo].
+ string source_location = 3;
+
+ // Prevent macro expansion. See "Macros" in Language Defiinition.
+ bool disable_macros = 4;
+}
+
+// Response message for the Parse method.
+message ParseResponse {
+ // The parsed representation, or unset if parsing failed.
+ ParsedExpr parsed_expr = 1;
+
+ // Any number of issues with [StatusDetails][] as the details.
+ repeated google.rpc.Status issues = 2;
+}
+
+// Request message for the Check method.
+message CheckRequest {
+ // Required. The parsed representation of the CEL program.
+ ParsedExpr parsed_expr = 1;
+
+ // Declarations of types for external variables and functions.
+ // Required if program uses external variables or functions
+ // not in the default environment.
+ repeated Decl type_env = 2;
+
+ // The protocol buffer context. See "Name Resolution" in the
+ // Language Definition.
+ string container = 3;
+
+ // If true, use only the declarations in
+ // [type_env][google.api.expr.v1alpha1.CheckRequest.type_env]. If false
+ // (default), add declarations for the standard definitions to the type
+ // environment. See "Standard Definitions" in the Language Definition.
+ bool no_std_env = 4;
+}
+
+// Response message for the Check method.
+message CheckResponse {
+ // The annotated representation, or unset if checking failed.
+ CheckedExpr checked_expr = 1;
+
+ // Any number of issues with [StatusDetails][] as the details.
+ repeated google.rpc.Status issues = 2;
+}
+
+// Request message for the Eval method.
+message EvalRequest {
+ // Required. Either the parsed or annotated representation of the CEL program.
+ oneof expr_kind {
+ // Evaluate based on the parsed representation.
+ ParsedExpr parsed_expr = 1;
+
+ // Evaluate based on the checked representation.
+ CheckedExpr checked_expr = 2;
+ }
+
+ // Bindings for the external variables. The types SHOULD be compatible
+ // with the type environment in
+ // [CheckRequest][google.api.expr.v1alpha1.CheckRequest], if checked.
+ map<string, ExprValue> bindings = 3;
+
+ // SHOULD be the same container as used in
+ // [CheckRequest][google.api.expr.v1alpha1.CheckRequest], if checked.
+ string container = 4;
+}
+
+// Response message for the Eval method.
+message EvalResponse {
+ // The execution result, or unset if execution couldn't start.
+ ExprValue result = 1;
+
+ // Any number of issues with [StatusDetails][] as the details.
+ // Note that CEL execution errors are reified into
+ // [ExprValue][google.api.expr.v1alpha1.ExprValue]. Nevertheless, we'll allow
+ // out-of-band issues to be raised, which also makes the replies more regular.
+ repeated google.rpc.Status issues = 2;
+}
+
+// Warnings or errors in service execution are represented by
+// [google.rpc.Status][google.rpc.Status] messages, with the following message
+// in the details field.
+message IssueDetails {
+ // Severities of issues.
+ enum Severity {
+ // An unspecified severity.
+ SEVERITY_UNSPECIFIED = 0;
+
+ // Deprecation issue for statements and method that may no longer be
+ // supported or maintained.
+ DEPRECATION = 1;
+
+ // Warnings such as: unused variables.
+ WARNING = 2;
+
+ // Errors such as: unmatched curly braces or variable redefinition.
+ ERROR = 3;
+ }
+
+ // The severity of the issue.
+ Severity severity = 1;
+
+ // Position in the source, if known.
+ SourcePosition position = 2;
+
+ // Expression ID from [Expr][google.api.expr.v1alpha1.Expr], 0 if unknown.
+ int64 id = 3;
+}

protos/google/api/expr/v1alpha1/eval.proto

@@ -0,0 +1,119 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api.expr.v1alpha1;
+
+import "google/api/expr/v1alpha1/value.proto";
+import "google/rpc/status.proto";
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/api/expr/v1alpha1;expr";
+option java_multiple_files = true;
+option java_outer_classname = "EvalProto";
+option java_package = "com.google.api.expr.v1alpha1";
+
+// The state of an evaluation.
+//
+// Can represent an inital, partial, or completed state of evaluation.
+message EvalState {
+ // A single evalution result.
+ message Result {
+ // The id of the expression this result if for.
+ int64 expr = 1;
+
+ // The index in `values` of the resulting value.
+ int64 value = 2;
+ }
+
+ // The unique values referenced in this message.
+ repeated ExprValue values = 1;
+
+ // An ordered list of results.
+ //
+ // Tracks the flow of evaluation through the expression.
+ // May be sparse.
+ repeated Result results = 3;
+}
+
+// The value of an evaluated expression.
+message ExprValue {
+ // An expression can resolve to a value, error or unknown.
+ oneof kind {
+ // A concrete value.
+ Value value = 1;
+
+ // The set of errors in the critical path of evalution.
+ //
+ // Only errors in the critical path are included. For example,
+ // `(<error1> || true) && <error2>` will only result in `<error2>`,
+ // while `<error1> || <error2>` will result in both `<error1>` and
+ // `<error2>`.
+ //
+ // Errors cause by the presence of other errors are not included in the
+ // set. For example `<error1>.foo`, `foo(<error1>)`, and `<error1> + 1` will
+ // only result in `<error1>`.
+ //
+ // Multiple errors *might* be included when evaluation could result
+ // in different errors. For example `<error1> + <error2>` and
+ // `foo(<error1>, <error2>)` may result in `<error1>`, `<error2>` or both.
+ // The exact subset of errors included for this case is unspecified and
+ // depends on the implementation details of the evaluator.
+ ErrorSet error = 2;
+
+ // The set of unknowns in the critical path of evaluation.
+ //
+ // Unknown behaves identically to Error with regards to propagation.
+ // Specifically, only unknowns in the critical path are included, unknowns
+ // caused by the presence of other unknowns are not included, and multiple
+ // unknowns *might* be included included when evaluation could result in
+ // different unknowns. For example:
+ //
+ // (<unknown[1]> || true) && <unknown[2]> -> <unknown[2]>
+ // <unknown[1]> || <unknown[2]> -> <unknown[1,2]>
+ // <unknown[1]>.foo -> <unknown[1]>
+ // foo(<unknown[1]>) -> <unknown[1]>
+ // <unknown[1]> + <unknown[2]> -> <unknown[1]> or <unknown[2[>
+ //
+ // Unknown takes precidence over Error in cases where a `Value` can short
+ // circuit the result:
+ //
+ // <error> || <unknown> -> <unknown>
+ // <error> && <unknown> -> <unknown>
+ //
+ // Errors take precidence in all other cases:
+ //
+ // <unknown> + <error> -> <error>
+ // foo(<unknown>, <error>) -> <error>
+ UnknownSet unknown = 3;
+ }
+}
+
+// A set of errors.
+//
+// The errors included depend on the context. See `ExprValue.error`.
+message ErrorSet {
+ // The errors in the set.
+ repeated google.rpc.Status errors = 1;
+}
+
+// A set of expressions for which the value is unknown.
+//
+// The unknowns included depend on the context. See `ExprValue.unknown`.
+message UnknownSet {
+ // The ids of the expressions with unknown values.
+ repeated int64 exprs = 1;
+}

protos/google/api/expr/v1alpha1/explain.proto

@@ -0,0 +1,54 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api.expr.v1alpha1;
+
+import "google/api/expr/v1alpha1/value.proto";
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/api/expr/v1alpha1;expr";
+option java_multiple_files = true;
+option java_outer_classname = "ExplainProto";
+option java_package = "com.google.api.expr.v1alpha1";
+
+// Values of intermediate expressions produced when evaluating expression.
+// Deprecated, use `EvalState` instead.
+message Explain {
+ option deprecated = true;
+
+ // ID and value index of one step.
+ message ExprStep {
+ // ID of corresponding Expr node.
+ int64 id = 1;
+
+ // Index of the value in the values list.
+ int32 value_index = 2;
+ }
+
+ // All of the observed values.
+ //
+ // The field value_index is an index in the values list.
+ // Separating values from steps is needed to remove redundant values.
+ repeated Value values = 1;
+
+ // List of steps.
+ //
+ // Repeated evaluations of the same expression generate new ExprStep
+ // instances. The order of such ExprStep instances matches the order of
+ // elements returned by Comprehension.iter_range.
+ repeated ExprStep expr_steps = 2;
+}

protos/google/api/expr/v1alpha1/syntax.proto

@@ -0,0 +1,322 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api.expr.v1alpha1;
+
+import "google/protobuf/duration.proto";
+import "google/protobuf/struct.proto";
+import "google/protobuf/timestamp.proto";
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/api/expr/v1alpha1;expr";
+option java_multiple_files = true;
+option java_outer_classname = "SyntaxProto";
+option java_package = "com.google.api.expr.v1alpha1";
+
+// A representation of the abstract syntax of the Common Expression Language.
+
+// An expression together with source information as returned by the parser.
+message ParsedExpr {
+ // The parsed expression.
+ Expr expr = 2;
+
+ // The source info derived from input that generated the parsed `expr`.
+ SourceInfo source_info = 3;
+}
+
+// An abstract representation of a common expression.
+//
+// Expressions are abstractly represented as a collection of identifiers,
+// select statements, function calls, literals, and comprehensions. All
+// operators with the exception of the '.' operator are modelled as function
+// calls. This makes it easy to represent new operators into the existing AST.
+//
+// All references within expressions must resolve to a
+// [Decl][google.api.expr.v1alpha1.Decl] provided at type-check for an
+// expression to be valid. A reference may either be a bare identifier `name` or
+// a qualified identifier `google.api.name`. References may either refer to a
+// value or a function declaration.
+//
+// For example, the expression `google.api.name.startsWith('expr')` references
+// the declaration `google.api.name` within a
+// [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression, and the
+// function declaration `startsWith`.
+message Expr {
+ // An identifier expression. e.g. `request`.
+ message Ident {
+ // Required. Holds a single, unqualified identifier, possibly preceded by a
+ // '.'.
+ //
+ // Qualified names are represented by the
+ // [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression.
+ string name = 1;
+ }
+
+ // A field selection expression. e.g. `request.auth`.
+ message Select {
+ // Required. The target of the selection expression.
+ //
+ // For example, in the select expression `request.auth`, the `request`
+ // portion of the expression is the `operand`.
+ Expr operand = 1;
+
+ // Required. The name of the field to select.
+ //
+ // For example, in the select expression `request.auth`, the `auth` portion
+ // of the expression would be the `field`.
+ string field = 2;
+
+ // Whether the select is to be interpreted as a field presence test.
+ //
+ // This results from the macro `has(request.auth)`.
+ bool test_only = 3;
+ }
+
+ // A call expression, including calls to predefined functions and operators.
+ //
+ // For example, `value == 10`, `size(map_value)`.
+ message Call {
+ // The target of an method call-style expression. For example, `x` in
+ // `x.f()`.
+ Expr target = 1;
+
+ // Required. The name of the function or method being called.
+ string function = 2;
+
+ // The arguments.
+ repeated Expr args = 3;
+ }
+
+ // A list creation expression.
+ //
+ // Lists may either be homogenous, e.g. `[1, 2, 3]`, or heterogenous, e.g.
+ // `dyn([1, 'hello', 2.0])`
+ message CreateList {
+ // The elements part of the list.
+ repeated Expr elements = 1;
+ }
+
+ // A map or message creation expression.
+ //
+ // Maps are constructed as `{'key_name': 'value'}`. Message construction is
+ // similar, but prefixed with a type name and composed of field ids:
+ // `types.MyType{field_id: 'value'}`.
+ message CreateStruct {
+ // Represents an entry.
+ message Entry {
+ // Required. An id assigned to this node by the parser which is unique
+ // in a given expression tree. This is used to associate type
+ // information and other attributes to the node.
+ int64 id = 1;
+
+ // The `Entry` key kinds.
+ oneof key_kind {
+ // The field key for a message creator statement.
+ string field_key = 2;
+
+ // The key expression for a map creation statement.
+ Expr map_key = 3;
+ }
+
+ // Required. The value assigned to the key.
+ Expr value = 4;
+ }
+
+ // The type name of the message to be created, empty when creating map
+ // literals.
+ string message_name = 1;
+
+ // The entries in the creation expression.
+ repeated Entry entries = 2;
+ }
+
+ // A comprehension expression applied to a list or map.
+ //
+ // Comprehensions are not part of the core syntax, but enabled with macros.
+ // A macro matches a specific call signature within a parsed AST and replaces
+ // the call with an alternate AST block. Macro expansion happens at parse
+ // time.
+ //
+ // The following macros are supported within CEL:
+ //
+ // Aggregate type macros may be applied to all elements in a list or all keys
+ // in a map:
+ //
+ // * `all`, `exists`, `exists_one` - test a predicate expression against
+ // the inputs and return `true` if the predicate is satisfied for all,
+ // any, or only one value `list.all(x, x < 10)`.
+ // * `filter` - test a predicate expression against the inputs and return
+ // the subset of elements which satisfy the predicate:
+ // `payments.filter(p, p > 1000)`.
+ // * `map` - apply an expression to all elements in the input and return the
+ // output aggregate type: `[1, 2, 3].map(i, i * i)`.
+ //
+ // The `has(m.x)` macro tests whether the property `x` is present in struct
+ // `m`. The semantics of this macro depend on the type of `m`. For proto2
+ // messages `has(m.x)` is defined as 'defined, but not set`. For proto3, the
+ // macro tests whether the property is set to its default. For map and struct
+ // types, the macro tests whether the property `x` is defined on `m`.
+ message Comprehension {
+ // The name of the iteration variable.
+ string iter_var = 1;
+
+ // The range over which var iterates.
+ Expr iter_range = 2;
+
+ // The name of the variable used for accumulation of the result.
+ string accu_var = 3;
+
+ // The initial value of the accumulator.
+ Expr accu_init = 4;
+
+ // An expression which can contain iter_var and accu_var.
+ //
+ // Returns false when the result has been computed and may be used as
+ // a hint to short-circuit the remainder of the comprehension.
+ Expr loop_condition = 5;
+
+ // An expression which can contain iter_var and accu_var.
+ //
+ // Computes the next value of accu_var.
+ Expr loop_step = 6;
+
+ // An expression which can contain accu_var.
+ //
+ // Computes the result.
+ Expr result = 7;
+ }
+
+ // Required. An id assigned to this node by the parser which is unique in a
+ // given expression tree. This is used to associate type information and other
+ // attributes to a node in the parse tree.
+ int64 id = 2;
+
+ // Required. Variants of expressions.
+ oneof expr_kind {
+ // A literal expression.
+ Constant const_expr = 3;
+
+ // An identifier expression.
+ Ident ident_expr = 4;
+
+ // A field selection expression, e.g. `request.auth`.
+ Select select_expr = 5;
+
+ // A call expression, including calls to predefined functions and operators.
+ Call call_expr = 6;
+
+ // A list creation expression.
+ CreateList list_expr = 7;
+
+ // A map or message creation expression.
+ CreateStruct struct_expr = 8;
+
+ // A comprehension expression.
+ Comprehension comprehension_expr = 9;
+ }
+}
+
+// Represents a primitive literal.
+//
+// Named 'Constant' here for backwards compatibility.
+//
+// This is similar as the primitives supported in the well-known type
+// `google.protobuf.Value`, but richer so it can represent CEL's full range of
+// primitives.
+//
+// Lists and structs are not included as constants as these aggregate types may
+// contain [Expr][google.api.expr.v1alpha1.Expr] elements which require
+// evaluation and are thus not constant.
+//
+// Examples of literals include: `"hello"`, `b'bytes'`, `1u`, `4.2`, `-2`,
+// `true`, `null`.
+message Constant {
+ // Required. The valid constant kinds.
+ oneof constant_kind {
+ // null value.
+ google.protobuf.NullValue null_value = 1;
+
+ // boolean value.
+ bool bool_value = 2;
+
+ // int64 value.
+ int64 int64_value = 3;
+
+ // uint64 value.
+ uint64 uint64_value = 4;
+
+ // double value.
+ double double_value = 5;
+
+ // string value.
+ string string_value = 6;
+
+ // bytes value.
+ bytes bytes_value = 7;
+
+ // protobuf.Duration value.
+ //
+ // Deprecated: duration is no longer considered a builtin cel type.
+ google.protobuf.Duration duration_value = 8 [deprecated = true];
+
+ // protobuf.Timestamp value.
+ //
+ // Deprecated: timestamp is no longer considered a builtin cel type.
+ google.protobuf.Timestamp timestamp_value = 9 [deprecated = true];
+ }
+}
+
+// Source information collected at parse time.
+message SourceInfo {
+ // The syntax version of the source, e.g. `cel1`.
+ string syntax_version = 1;
+
+ // The location name. All position information attached to an expression is
+ // relative to this location.
+ //
+ // The location could be a file, UI element, or similar. For example,
+ // `acme/app/AnvilPolicy.cel`.
+ string location = 2;
+
+ // Monotonically increasing list of character offsets where newlines appear.
+ //
+ // The line number of a given position is the index `i` where for a given
+ // `id` the `line_offsets[i] < id_positions[id] < line_offsets[i+1]`. The
+ // column may be derivd from `id_positions[id] - line_offsets[i]`.
+ repeated int32 line_offsets = 3;
+
+ // A map from the parse node id (e.g. `Expr.id`) to the character offset
+ // within source.
+ map<int64, int32> positions = 4;
+}
+
+// A specific position in source.
+message SourcePosition {
+ // The soucre location name (e.g. file name).
+ string location = 1;
+
+ // The character offset.
+ int32 offset = 2;
+
+ // The 1-based index of the starting line in the source text
+ // where the issue occurs, or 0 if unknown.
+ int32 line = 3;
+
+ // The 0-based index of the starting position within the line of source text
+ // where the issue occurs. Only meaningful if line is nonzero.
+ int32 column = 4;
+}

protos/google/api/expr/v1alpha1/value.proto

@@ -0,0 +1,116 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api.expr.v1alpha1;
+
+import "google/protobuf/any.proto";
+import "google/protobuf/struct.proto";
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/api/expr/v1alpha1;expr";
+option java_multiple_files = true;
+option java_outer_classname = "ValueProto";
+option java_package = "com.google.api.expr.v1alpha1";
+
+// Contains representations for CEL runtime values.
+
+// Represents a CEL value.
+//
+// This is similar to `google.protobuf.Value`, but can represent CEL's full
+// range of values.
+message Value {
+ // Required. The valid kinds of values.
+ oneof kind {
+ // Null value.
+ google.protobuf.NullValue null_value = 1;
+
+ // Boolean value.
+ bool bool_value = 2;
+
+ // Signed integer value.
+ int64 int64_value = 3;
+
+ // Unsigned integer value.
+ uint64 uint64_value = 4;
+
+ // Floating point value.
+ double double_value = 5;
+
+ // UTF-8 string value.
+ string string_value = 6;
+
+ // Byte string value.
+ bytes bytes_value = 7;
+
+ // An enum value.
+ EnumValue enum_value = 9;
+
+ // The proto message backing an object value.
+ google.protobuf.Any object_value = 10;
+
+ // Map value.
+ MapValue map_value = 11;
+
+ // List value.
+ ListValue list_value = 12;
+
+ // Type value.
+ string type_value = 15;
+ }
+}
+
+// An enum value.
+message EnumValue {
+ // The fully qualified name of the enum type.
+ string type = 1;
+
+ // The value of the enum.
+ int32 value = 2;
+}
+
+// A list.
+//
+// Wrapped in a message so 'not set' and empty can be differentiated, which is
+// required for use in a 'oneof'.
+message ListValue {
+ // The ordered values in the list.
+ repeated Value values = 1;
+}
+
+// A map.
+//
+// Wrapped in a message so 'not set' and empty can be differentiated, which is
+// required for use in a 'oneof'.
+message MapValue {
+ // An entry in the map.
+ message Entry {
+ // The key.
+ //
+ // Must be unique with in the map.
+ // Currently only boolean, int, uint, and string values can be keys.
+ Value key = 1;
+
+ // The value.
+ Value value = 2;
+ }
+
+ // The set of map entries.
+ //
+ // CEL has fewer restrictions on keys, so a protobuf map represenation
+ // cannot be used.
+ repeated Entry entries = 1;
+}

protos/google/api/expr/v1beta1/decl.proto

@@ -0,0 +1,84 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api.expr.v1beta1;
+
+import "google/api/expr/v1beta1/expr.proto";
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/api/expr/v1beta1;expr";
+option java_multiple_files = true;
+option java_outer_classname = "DeclProto";
+option java_package = "com.google.api.expr.v1beta1";
+
+// A declaration.
+message Decl {
+ // The id of the declaration.
+ int32 id = 1;
+
+ // The name of the declaration.
+ string name = 2;
+
+ // The documentation string for the declaration.
+ string doc = 3;
+
+ // The kind of declaration.
+ oneof kind {
+ // An identifier declaration.
+ IdentDecl ident = 4;
+
+ // A function declaration.
+ FunctionDecl function = 5;
+ }
+}
+
+// The declared type of a variable.
+//
+// Extends runtime type values with extra information used for type checking
+// and dispatching.
+message DeclType {
+ // The expression id of the declared type, if applicable.
+ int32 id = 1;
+
+ // The type name, e.g. 'int', 'my.type.Type' or 'T'
+ string type = 2;
+
+ // An ordered list of type parameters, e.g. `<string, int>`.
+ // Only applies to a subset of types, e.g. `map`, `list`.
+ repeated DeclType type_params = 4;
+}
+
+// An identifier declaration.
+message IdentDecl {
+ // Optional type of the identifier.
+ DeclType type = 3;
+
+ // Optional value of the identifier.
+ Expr value = 4;
+}
+
+// A function declaration.
+message FunctionDecl {
+ // The function arguments.
+ repeated IdentDecl args = 1;
+
+ // Optional declared return type.
+ DeclType return_type = 2;
+
+ // If the first argument of the function is the receiver.
+ bool receiver_function = 3;
+}

protos/google/api/expr/v1beta1/eval.proto

@@ -0,0 +1,125 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api.expr.v1beta1;
+
+import "google/api/expr/v1beta1/value.proto";
+import "google/rpc/status.proto";
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/api/expr/v1beta1;expr";
+option java_multiple_files = true;
+option java_outer_classname = "EvalProto";
+option java_package = "com.google.api.expr.v1beta1";
+
+// The state of an evaluation.
+//
+// Can represent an initial, partial, or completed state of evaluation.
+message EvalState {
+ // A single evaluation result.
+ message Result {
+ // The expression this result is for.
+ IdRef expr = 1;
+
+ // The index in `values` of the resulting value.
+ int32 value = 2;
+ }
+
+ // The unique values referenced in this message.
+ repeated ExprValue values = 1;
+
+ // An ordered list of results.
+ //
+ // Tracks the flow of evaluation through the expression.
+ // May be sparse.
+ repeated Result results = 3;
+}
+
+// The value of an evaluated expression.
+message ExprValue {
+ // An expression can resolve to a value, error or unknown.
+ oneof kind {
+ // A concrete value.
+ Value value = 1;
+
+ // The set of errors in the critical path of evalution.
+ //
+ // Only errors in the critical path are included. For example,
+ // `(<error1> || true) && <error2>` will only result in `<error2>`,
+ // while `<error1> || <error2>` will result in both `<error1>` and
+ // `<error2>`.
+ //
+ // Errors cause by the presence of other errors are not included in the
+ // set. For example `<error1>.foo`, `foo(<error1>)`, and `<error1> + 1` will
+ // only result in `<error1>`.
+ //
+ // Multiple errors *might* be included when evaluation could result
+ // in different errors. For example `<error1> + <error2>` and
+ // `foo(<error1>, <error2>)` may result in `<error1>`, `<error2>` or both.
+ // The exact subset of errors included for this case is unspecified and
+ // depends on the implementation details of the evaluator.
+ ErrorSet error = 2;
+
+ // The set of unknowns in the critical path of evaluation.
+ //
+ // Unknown behaves identically to Error with regards to propagation.
+ // Specifically, only unknowns in the critical path are included, unknowns
+ // caused by the presence of other unknowns are not included, and multiple
+ // unknowns *might* be included included when evaluation could result in
+ // different unknowns. For example:
+ //
+ // (<unknown[1]> || true) && <unknown[2]> -> <unknown[2]>
+ // <unknown[1]> || <unknown[2]> -> <unknown[1,2]>
+ // <unknown[1]>.foo -> <unknown[1]>
+ // foo(<unknown[1]>) -> <unknown[1]>
+ // <unknown[1]> + <unknown[2]> -> <unknown[1]> or <unknown[2[>
+ //
+ // Unknown takes precidence over Error in cases where a `Value` can short
+ // circuit the result:
+ //
+ // <error> || <unknown> -> <unknown>
+ // <error> && <unknown> -> <unknown>
+ //
+ // Errors take precidence in all other cases:
+ //
+ // <unknown> + <error> -> <error>
+ // foo(<unknown>, <error>) -> <error>
+ UnknownSet unknown = 3;
+ }
+}
+
+// A set of errors.
+//
+// The errors included depend on the context. See `ExprValue.error`.
+message ErrorSet {
+ // The errors in the set.
+ repeated google.rpc.Status errors = 1;
+}
+
+// A set of expressions for which the value is unknown.
+//
+// The unknowns included depend on the context. See `ExprValue.unknown`.
+message UnknownSet {
+ // The ids of the expressions with unknown values.
+ repeated IdRef exprs = 1;
+}
+
+// A reference to an expression id.
+message IdRef {
+ // The expression id.
+ int32 id = 1;
+}

protos/google/api/expr/v1beta1/expr.proto

@@ -0,0 +1,269 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api.expr.v1beta1;
+
+import "google/api/expr/v1beta1/source.proto";
+import "google/protobuf/struct.proto";
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/api/expr/v1beta1;expr";
+option java_multiple_files = true;
+option java_outer_classname = "ExprProto";
+option java_package = "com.google.api.expr.v1beta1";
+
+// An expression together with source information as returned by the parser.
+message ParsedExpr {
+ // The parsed expression.
+ Expr expr = 2;
+
+ // The source info derived from input that generated the parsed `expr`.
+ SourceInfo source_info = 3;
+
+ // The syntax version of the source, e.g. `cel1`.
+ string syntax_version = 4;
+}
+
+// An abstract representation of a common expression.
+//
+// Expressions are abstractly represented as a collection of identifiers,
+// select statements, function calls, literals, and comprehensions. All
+// operators with the exception of the '.' operator are modelled as function
+// calls. This makes it easy to represent new operators into the existing AST.
+//
+// All references within expressions must resolve to a
+// [Decl][google.api.expr.v1beta1.Decl] provided at type-check for an expression
+// to be valid. A reference may either be a bare identifier `name` or a
+// qualified identifier `google.api.name`. References may either refer to a
+// value or a function declaration.
+//
+// For example, the expression `google.api.name.startsWith('expr')` references
+// the declaration `google.api.name` within a
+// [Expr.Select][google.api.expr.v1beta1.Expr.Select] expression, and the
+// function declaration `startsWith`.
+message Expr {
+ // An identifier expression. e.g. `request`.
+ message Ident {
+ // Required. Holds a single, unqualified identifier, possibly preceded by a
+ // '.'.
+ //
+ // Qualified names are represented by the
+ // [Expr.Select][google.api.expr.v1beta1.Expr.Select] expression.
+ string name = 1;
+ }
+
+ // A field selection expression. e.g. `request.auth`.
+ message Select {
+ // Required. The target of the selection expression.
+ //
+ // For example, in the select expression `request.auth`, the `request`
+ // portion of the expression is the `operand`.
+ Expr operand = 1;
+
+ // Required. The name of the field to select.
+ //
+ // For example, in the select expression `request.auth`, the `auth` portion
+ // of the expression would be the `field`.
+ string field = 2;
+
+ // Whether the select is to be interpreted as a field presence test.
+ //
+ // This results from the macro `has(request.auth)`.
+ bool test_only = 3;
+ }
+
+ // A call expression, including calls to predefined functions and operators.
+ //
+ // For example, `value == 10`, `size(map_value)`.
+ message Call {
+ // The target of an method call-style expression. For example, `x` in
+ // `x.f()`.
+ Expr target = 1;
+
+ // Required. The name of the function or method being called.
+ string function = 2;
+
+ // The arguments.
+ repeated Expr args = 3;
+ }
+
+ // A list creation expression.
+ //
+ // Lists may either be homogenous, e.g. `[1, 2, 3]`, or heterogenous, e.g.
+ // `dyn([1, 'hello', 2.0])`
+ message CreateList {
+ // The elements part of the list.
+ repeated Expr elements = 1;
+ }
+
+ // A map or message creation expression.
+ //
+ // Maps are constructed as `{'key_name': 'value'}`. Message construction is
+ // similar, but prefixed with a type name and composed of field ids:
+ // `types.MyType{field_id: 'value'}`.
+ message CreateStruct {
+ // Represents an entry.
+ message Entry {
+ // Required. An id assigned to this node by the parser which is unique
+ // in a given expression tree. This is used to associate type
+ // information and other attributes to the node.
+ int32 id = 1;
+
+ // The `Entry` key kinds.
+ oneof key_kind {
+ // The field key for a message creator statement.
+ string field_key = 2;
+
+ // The key expression for a map creation statement.
+ Expr map_key = 3;
+ }
+
+ // Required. The value assigned to the key.
+ Expr value = 4;
+ }
+
+ // The type name of the message to be created, empty when creating map
+ // literals.
+ string type = 1;
+
+ // The entries in the creation expression.
+ repeated Entry entries = 2;
+ }
+
+ // A comprehension expression applied to a list or map.
+ //
+ // Comprehensions are not part of the core syntax, but enabled with macros.
+ // A macro matches a specific call signature within a parsed AST and replaces
+ // the call with an alternate AST block. Macro expansion happens at parse
+ // time.
+ //
+ // The following macros are supported within CEL:
+ //
+ // Aggregate type macros may be applied to all elements in a list or all keys
+ // in a map:
+ //
+ // * `all`, `exists`, `exists_one` - test a predicate expression against
+ // the inputs and return `true` if the predicate is satisfied for all,
+ // any, or only one value `list.all(x, x < 10)`.
+ // * `filter` - test a predicate expression against the inputs and return
+ // the subset of elements which satisfy the predicate:
+ // `payments.filter(p, p > 1000)`.
+ // * `map` - apply an expression to all elements in the input and return the
+ // output aggregate type: `[1, 2, 3].map(i, i * i)`.
+ //
+ // The `has(m.x)` macro tests whether the property `x` is present in struct
+ // `m`. The semantics of this macro depend on the type of `m`. For proto2
+ // messages `has(m.x)` is defined as 'defined, but not set`. For proto3, the
+ // macro tests whether the property is set to its default. For map and struct
+ // types, the macro tests whether the property `x` is defined on `m`.
+ message Comprehension {
+ // The name of the iteration variable.
+ string iter_var = 1;
+
+ // The range over which var iterates.
+ Expr iter_range = 2;
+
+ // The name of the variable used for accumulation of the result.
+ string accu_var = 3;
+
+ // The initial value of the accumulator.
+ Expr accu_init = 4;
+
+ // An expression which can contain iter_var and accu_var.
+ //
+ // Returns false when the result has been computed and may be used as
+ // a hint to short-circuit the remainder of the comprehension.
+ Expr loop_condition = 5;
+
+ // An expression which can contain iter_var and accu_var.
+ //
+ // Computes the next value of accu_var.
+ Expr loop_step = 6;
+
+ // An expression which can contain accu_var.
+ //
+ // Computes the result.
+ Expr result = 7;
+ }
+
+ // Required. An id assigned to this node by the parser which is unique in a
+ // given expression tree. This is used to associate type information and other
+ // attributes to a node in the parse tree.
+ int32 id = 2;
+
+ // Required. Variants of expressions.
+ oneof expr_kind {
+ // A literal expression.
+ Literal literal_expr = 3;
+
+ // An identifier expression.
+ Ident ident_expr = 4;
+
+ // A field selection expression, e.g. `request.auth`.
+ Select select_expr = 5;
+
+ // A call expression, including calls to predefined functions and operators.
+ Call call_expr = 6;
+
+ // A list creation expression.
+ CreateList list_expr = 7;
+
+ // A map or object creation expression.
+ CreateStruct struct_expr = 8;
+
+ // A comprehension expression.
+ Comprehension comprehension_expr = 9;
+ }
+}
+
+// Represents a primitive literal.
+//
+// This is similar to the primitives supported in the well-known type
+// `google.protobuf.Value`, but richer so it can represent CEL's full range of
+// primitives.
+//
+// Lists and structs are not included as constants as these aggregate types may
+// contain [Expr][google.api.expr.v1beta1.Expr] elements which require
+// evaluation and are thus not constant.
+//
+// Examples of literals include: `"hello"`, `b'bytes'`, `1u`, `4.2`, `-2`,
+// `true`, `null`.
+message Literal {
+ // Required. The valid constant kinds.
+ oneof constant_kind {
+ // null value.
+ google.protobuf.NullValue null_value = 1;
+
+ // boolean value.
+ bool bool_value = 2;
+
+ // int64 value.
+ int64 int64_value = 3;
+
+ // uint64 value.
+ uint64 uint64_value = 4;
+
+ // double value.
+ double double_value = 5;
+
+ // string value.
+ string string_value = 6;
+
+ // bytes value.
+ bytes bytes_value = 7;
+ }
+}

protos/google/api/expr/v1beta1/source.proto

@@ -0,0 +1,62 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api.expr.v1beta1;
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/api/expr/v1beta1;expr";
+option java_multiple_files = true;
+option java_outer_classname = "SourceProto";
+option java_package = "com.google.api.expr.v1beta1";
+
+// Source information collected at parse time.
+message SourceInfo {
+ // The location name. All position information attached to an expression is
+ // relative to this location.
+ //
+ // The location could be a file, UI element, or similar. For example,
+ // `acme/app/AnvilPolicy.cel`.
+ string location = 2;
+
+ // Monotonically increasing list of character offsets where newlines appear.
+ //
+ // The line number of a given position is the index `i` where for a given
+ // `id` the `line_offsets[i] < id_positions[id] < line_offsets[i+1]`. The
+ // column may be derivd from `id_positions[id] - line_offsets[i]`.
+ repeated int32 line_offsets = 3;
+
+ // A map from the parse node id (e.g. `Expr.id`) to the character offset
+ // within source.
+ map<int32, int32> positions = 4;
+}
+
+// A specific position in source.
+message SourcePosition {
+ // The soucre location name (e.g. file name).
+ string location = 1;
+
+ // The character offset.
+ int32 offset = 2;
+
+ // The 1-based index of the starting line in the source text
+ // where the issue occurs, or 0 if unknown.
+ int32 line = 3;
+
+ // The 0-based index of the starting position within the line of source text
+ // where the issue occurs. Only meaningful if line is nonzer..
+ int32 column = 4;
+}

protos/google/api/expr/v1beta1/value.proto

@@ -0,0 +1,114 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api.expr.v1beta1;
+
+import "google/protobuf/any.proto";
+import "google/protobuf/struct.proto";
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/api/expr/v1beta1;expr";
+option java_multiple_files = true;
+option java_outer_classname = "ValueProto";
+option java_package = "com.google.api.expr.v1beta1";
+
+// Represents a CEL value.
+//
+// This is similar to `google.protobuf.Value`, but can represent CEL's full
+// range of values.
+message Value {
+ // Required. The valid kinds of values.
+ oneof kind {
+ // Null value.
+ google.protobuf.NullValue null_value = 1;
+
+ // Boolean value.
+ bool bool_value = 2;
+
+ // Signed integer value.
+ int64 int64_value = 3;
+
+ // Unsigned integer value.
+ uint64 uint64_value = 4;
+
+ // Floating point value.
+ double double_value = 5;
+
+ // UTF-8 string value.
+ string string_value = 6;
+
+ // Byte string value.
+ bytes bytes_value = 7;
+
+ // An enum value.
+ EnumValue enum_value = 9;
+
+ // The proto message backing an object value.
+ google.protobuf.Any object_value = 10;
+
+ // Map value.
+ MapValue map_value = 11;
+
+ // List value.
+ ListValue list_value = 12;
+
+ // A Type value represented by the fully qualified name of the type.
+ string type_value = 15;
+ }
+}
+
+// An enum value.
+message EnumValue {
+ // The fully qualified name of the enum type.
+ string type = 1;
+
+ // The value of the enum.
+ int32 value = 2;
+}
+
+// A list.
+//
+// Wrapped in a message so 'not set' and empty can be differentiated, which is
+// required for use in a 'oneof'.
+message ListValue {
+ // The ordered values in the list.
+ repeated Value values = 1;
+}
+
+// A map.
+//
+// Wrapped in a message so 'not set' and empty can be differentiated, which is
+// required for use in a 'oneof'.
+message MapValue {
+ // An entry in the map.
+ message Entry {
+ // The key.
+ //
+ // Must be unique with in the map.
+ // Currently only boolean, int, uint, and string values can be keys.
+ Value key = 1;
+
+ // The value.
+ Value value = 2;
+ }
+
+ // The set of map entries.
+ //
+ // CEL has fewer restrictions on keys, so a protobuf map represenation
+ // cannot be used.
+ repeated Entry entries = 1;
+}

protos/google/api/field_behavior.proto

@@ -0,0 +1,79 @@
+// Copyright 2019 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+import "google/protobuf/descriptor.proto";
+
+option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
+option java_multiple_files = true;
+option java_outer_classname = "FieldBehaviorProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+extend google.protobuf.FieldOptions {
+ // A designation of a specific field behavior (required, output only, etc.)
+ // in protobuf messages.
+ //
+ // Examples:
+ //
+ // string name = 1 [(google.api.field_behavior) = REQUIRED];
+ // State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
+ // google.protobuf.Duration ttl = 1
+ // [(google.api.field_behavior) = INPUT_ONLY];
+ // google.protobuf.Timestamp expire_time = 1
+ // [(google.api.field_behavior) = OUTPUT_ONLY,
+ // (google.api.field_behavior) = IMMUTABLE];
+ repeated google.api.FieldBehavior field_behavior = 1052;
+}
+
+// An indicator of the behavior of a given field (for example, that a field
+// is required in requests, or given as output but ignored as input).
+// This **does not** change the behavior in protocol buffers itself; it only
+// denotes the behavior and may affect how API tooling handles the field.
+//
+// Note: This enum **may** receive new values in the future.
+enum FieldBehavior {
+ // Conventional default for enums. Do not use this.
+ FIELD_BEHAVIOR_UNSPECIFIED = 0;
+
+ // Specifically denotes a field as optional.
+ // While all fields in protocol buffers are optional, this may be specified
+ // for emphasis if appropriate.
+ OPTIONAL = 1;
+
+ // Denotes a field as required.
+ // This indicates that the field **must** be provided as part of the request,
+ // and failure to do so will cause an error (usually `INVALID_ARGUMENT`).
+ REQUIRED = 2;
+
+ // Denotes a field as output only.
+ // This indicates that the field is provided in responses, but including the
+ // field in a request does nothing (the server *must* ignore it and
+ // *must not* throw an error as a result of the field's presence).
+ OUTPUT_ONLY = 3;
+
+ // Denotes a field as input only.
+ // This indicates that the field is provided in requests, and the
+ // corresponding field is not included in output.
+ INPUT_ONLY = 4;
+
+ // Denotes a field as immutable.
+ // This indicates that the field may be set once in a request to create a
+ // resource, but may not be changed thereafter.
+ IMMUTABLE = 5;
+}

protos/google/api/httpbody.proto

@@ -0,0 +1,78 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+import "google/protobuf/any.proto";
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/api/httpbody;httpbody";
+option java_multiple_files = true;
+option java_outer_classname = "HttpBodyProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// Message that represents an arbitrary HTTP body. It should only be used for
+// payload formats that can't be represented as JSON, such as raw binary or
+// an HTML page.
+//
+//
+// This message can be used both in streaming and non-streaming API methods in
+// the request as well as the response.
+//
+// It can be used as a top-level request field, which is convenient if one
+// wants to extract parameters from either the URL or HTTP template into the
+// request fields and also want access to the raw HTTP body.
+//
+// Example:
+//
+// message GetResourceRequest {
+// // A unique request id.
+// string request_id = 1;
+//
+// // The raw HTTP body is bound to this field.
+// google.api.HttpBody http_body = 2;
+// }
+//
+// service ResourceService {
+// rpc GetResource(GetResourceRequest) returns (google.api.HttpBody);
+// rpc UpdateResource(google.api.HttpBody) returns
+// (google.protobuf.Empty);
+// }
+//
+// Example with streaming methods:
+//
+// service CaldavService {
+// rpc GetCalendar(stream google.api.HttpBody)
+// returns (stream google.api.HttpBody);
+// rpc UpdateCalendar(stream google.api.HttpBody)
+// returns (stream google.api.HttpBody);
+// }
+//
+// Use of this type only changes how the request and response bodies are
+// handled, all other features will continue to work unchanged.
+message HttpBody {
+ // The HTTP Content-Type header value specifying the content type of the body.
+ string content_type = 1;
+
+ // The HTTP request/response body as raw binary.
+ bytes data = 2;
+
+ // Application specific response metadata. Must be set in the first response
+ // for streaming APIs.
+ repeated google.protobuf.Any extensions = 3;
+}

protos/google/api/http.proto

@@ -0,0 +1,380 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
+option java_multiple_files = true;
+option java_outer_classname = "HttpProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// Defines the HTTP configuration for an API service. It contains a list of
+// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method
+// to one or more HTTP REST API methods.
+message Http {
+ // A list of HTTP configuration rules that apply to individual API methods.
+ //
+ // **NOTE:** All service configuration rules follow "last one wins" order.
+ repeated HttpRule rules = 1;
+
+ // When set to true, URL path parmeters will be fully URI-decoded except in
+ // cases of single segment matches in reserved expansion, where "%2F" will be
+ // left encoded.
+ //
+ // The default behavior is to not decode RFC 6570 reserved characters in multi
+ // segment matches.
+ bool fully_decode_reserved_expansion = 2;
+}
+
+// # gRPC Transcoding
+//
+// gRPC Transcoding is a feature for mapping between a gRPC method and one or
+// more HTTP REST endpoints. It allows developers to build a single API service
+// that supports both gRPC APIs and REST APIs. Many systems, including [Google
+// APIs](https://github.com/googleapis/googleapis),
+// [Cloud Endpoints](https://cloud.google.com/endpoints), [gRPC
+// Gateway](https://github.com/grpc-ecosystem/grpc-gateway),
+// and [Envoy](https://github.com/envoyproxy/envoy) proxy support this feature
+// and use it for large scale production services.
+//
+// `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies
+// how different portions of the gRPC request message are mapped to the URL
+// path, URL query parameters, and HTTP request body. It also controls how the
+// gRPC response message is mapped to the HTTP response body. `HttpRule` is
+// typically specified as an `google.api.http` annotation on the gRPC method.
+//
+// Each mapping specifies a URL path template and an HTTP method. The path
+// template may refer to one or more fields in the gRPC request message, as long
+// as each field is a non-repeated field with a primitive (non-message) type.
+// The path template controls how fields of the request message are mapped to
+// the URL path.
+//
+// Example:
+//
+// service Messaging {
+// rpc GetMessage(GetMessageRequest) returns (Message) {
+// option (google.api.http) = {
+// get: "/v1/{name=messages/*}"
+// };
+// }
+// }
+// message GetMessageRequest {
+// string name = 1; // Mapped to URL path.
+// }
+// message Message {
+// string text = 1; // The resource content.
+// }
+//
+// This enables an HTTP REST to gRPC mapping as below:
+//
+// HTTP | gRPC
+// -----|-----
+// `GET /v1/messages/123456` | `GetMessage(name: "messages/123456")`
+//
+// Any fields in the request message which are not bound by the path template
+// automatically become HTTP query parameters if there is no HTTP request body.
+// For example:
+//
+// service Messaging {
+// rpc GetMessage(GetMessageRequest) returns (Message) {
+// option (google.api.http) = {
+// get:"/v1/messages/{message_id}"
+// };
+// }
+// }
+// message GetMessageRequest {
+// message SubMessage {
+// string subfield = 1;
+// }
+// string message_id = 1; // Mapped to URL path.
+// int64 revision = 2; // Mapped to URL query parameter `revision`.
+// SubMessage sub = 3; // Mapped to URL query parameter `sub.subfield`.
+// }
+//
+// This enables a HTTP JSON to RPC mapping as below:
+//
+// HTTP | gRPC
+// -----|-----
+// `GET /v1/messages/123456?revision=2&sub.subfield=foo` |
+// `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield:
+// "foo"))`
+//
+// Note that fields which are mapped to URL query parameters must have a
+// primitive type or a repeated primitive type or a non-repeated message type.
+// In the case of a repeated type, the parameter can be repeated in the URL
+// as `...?param=A&param=B`. In the case of a message type, each field of the
+// message is mapped to a separate parameter, such as
+// `...?foo.a=A&foo.b=B&foo.c=C`.
+//
+// For HTTP methods that allow a request body, the `body` field
+// specifies the mapping. Consider a REST update method on the
+// message resource collection:
+//
+// service Messaging {
+// rpc UpdateMessage(UpdateMessageRequest) returns (Message) {
+// option (google.api.http) = {
+// patch: "/v1/messages/{message_id}"
+// body: "message"
+// };
+// }
+// }
+// message UpdateMessageRequest {
+// string message_id = 1; // mapped to the URL
+// Message message = 2; // mapped to the body
+// }
+//
+// The following HTTP JSON to RPC mapping is enabled, where the
+// representation of the JSON in the request body is determined by
+// protos JSON encoding:
+//
+// HTTP | gRPC
+// -----|-----
+// `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id:
+// "123456" message { text: "Hi!" })`
+//
+// The special name `*` can be used in the body mapping to define that
+// every field not bound by the path template should be mapped to the
+// request body. This enables the following alternative definition of
+// the update method:
+//
+// service Messaging {
+// rpc UpdateMessage(Message) returns (Message) {
+// option (google.api.http) = {
+// patch: "/v1/messages/{message_id}"
+// body: "*"
+// };
+// }
+// }
+// message Message {
+// string message_id = 1;
+// string text = 2;
+// }
+//
+//
+// The following HTTP JSON to RPC mapping is enabled:
+//
+// HTTP | gRPC
+// -----|-----
+// `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id:
+// "123456" text: "Hi!")`
+//
+// Note that when using `*` in the body mapping, it is not possible to
+// have HTTP parameters, as all fields not bound by the path end in
+// the body. This makes this option more rarely used in practice when
+// defining REST APIs. The common usage of `*` is in custom methods
+// which don't use the URL at all for transferring data.
+//
+// It is possible to define multiple HTTP methods for one RPC by using
+// the `additional_bindings` option. Example:
+//
+// service Messaging {
+// rpc GetMessage(GetMessageRequest) returns (Message) {
+// option (google.api.http) = {
+// get: "/v1/messages/{message_id}"
+// additional_bindings {
+// get: "/v1/users/{user_id}/messages/{message_id}"
+// }
+// };
+// }
+// }
+// message GetMessageRequest {
+// string message_id = 1;
+// string user_id = 2;
+// }
+//
+// This enables the following two alternative HTTP JSON to RPC mappings:
+//
+// HTTP | gRPC
+// -----|-----
+// `GET /v1/messages/123456` | `GetMessage(message_id: "123456")`
+// `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id:
+// "123456")`
+//
+// ## Rules for HTTP mapping
+//
+// 1. Leaf request fields (recursive expansion nested messages in the request
+// message) are classified into three categories:
+// - Fields referred by the path template. They are passed via the URL path.
+// - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They
+// are passed via the HTTP
+// request body.
+// - All other fields are passed via the URL query parameters, and the
+// parameter name is the field path in the request message. A repeated
+// field can be represented as multiple query parameters under the same
+// name.
+// 2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL
+// query parameter, all fields
+// are passed via URL path and HTTP request body.
+// 3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP
+// request body, all
+// fields are passed via URL path and URL query parameters.
+//
+// ### Path template syntax
+//
+// Template = "/" Segments [ Verb ] ;
+// Segments = Segment { "/" Segment } ;
+// Segment = "*" | "**" | LITERAL | Variable ;
+// Variable = "{" FieldPath [ "=" Segments ] "}" ;
+// FieldPath = IDENT { "." IDENT } ;
+// Verb = ":" LITERAL ;
+//
+// The syntax `*` matches a single URL path segment. The syntax `**` matches
+// zero or more URL path segments, which must be the last part of the URL path
+// except the `Verb`.
+//
+// The syntax `Variable` matches part of the URL path as specified by its
+// template. A variable template must not contain other variables. If a variable
+// matches a single path segment, its template may be omitted, e.g. `{var}`
+// is equivalent to `{var=*}`.
+//
+// The syntax `LITERAL` matches literal text in the URL path. If the `LITERAL`
+// contains any reserved character, such characters should be percent-encoded
+// before the matching.
+//
+// If a variable contains exactly one path segment, such as `"{var}"` or
+// `"{var=*}"`, when such a variable is expanded into a URL path on the client
+// side, all characters except `[-_.~0-9a-zA-Z]` are percent-encoded. The
+// server side does the reverse decoding. Such variables show up in the
+// [Discovery
+// Document](https://developers.google.com/discovery/v1/reference/apis) as
+// `{var}`.
+//
+// If a variable contains multiple path segments, such as `"{var=foo/*}"`
+// or `"{var=**}"`, when such a variable is expanded into a URL path on the
+// client side, all characters except `[-_.~/0-9a-zA-Z]` are percent-encoded.
+// The server side does the reverse decoding, except "%2F" and "%2f" are left
+// unchanged. Such variables show up in the
+// [Discovery
+// Document](https://developers.google.com/discovery/v1/reference/apis) as
+// `{+var}`.
+//
+// ## Using gRPC API Service Configuration
+//
+// gRPC API Service Configuration (service config) is a configuration language
+// for configuring a gRPC service to become a user-facing product. The
+// service config is simply the YAML representation of the `google.api.Service`
+// proto message.
+//
+// As an alternative to annotating your proto file, you can configure gRPC
+// transcoding in your service config YAML files. You do this by specifying a
+// `HttpRule` that maps the gRPC method to a REST endpoint, achieving the same
+// effect as the proto annotation. This can be particularly useful if you
+// have a proto that is reused in multiple services. Note that any transcoding
+// specified in the service config will override any matching transcoding
+// configuration in the proto.
+//
+// Example:
+//
+// http:
+// rules:
+// # Selects a gRPC method and applies HttpRule to it.
+// - selector: example.v1.Messaging.GetMessage
+// get: /v1/messages/{message_id}/{sub.subfield}
+//
+// ## Special notes
+//
+// When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the
+// proto to JSON conversion must follow the [proto3
+// specification](https://developers.google.com/protocol-buffers/docs/proto3#json).
+//
+// While the single segment variable follows the semantics of
+// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String
+// Expansion, the multi segment variable **does not** follow RFC 6570 Section
+// 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion
+// does not expand special characters like `?` and `#`, which would lead
+// to invalid URLs. As the result, gRPC Transcoding uses a custom encoding
+// for multi segment variables.
+//
+// The path variables **must not** refer to any repeated or mapped field,
+// because client libraries are not capable of handling such variable expansion.
+//
+// The path variables **must not** capture the leading "/" character. The reason
+// is that the most common use case "{var}" does not capture the leading "/"
+// character. For consistency, all path variables must share the same behavior.
+//
+// Repeated message fields must not be mapped to URL query parameters, because
+// no client library can support such complicated mapping.
+//
+// If an API needs to use a JSON array for request or response body, it can map
+// the request or response body to a repeated field. However, some gRPC
+// Transcoding implementations may not support this feature.
+message HttpRule {
+ // Selects a method to which this rule applies.
+ //
+ // Refer to [selector][google.api.DocumentationRule.selector] for syntax
+ // details.
+ string selector = 1;
+
+ // Determines the URL pattern is matched by this rules. This pattern can be
+ // used with any of the {get|put|post|delete|patch} methods. A custom method
+ // can be defined using the 'custom' field.
+ oneof pattern {
+ // Maps to HTTP GET. Used for listing and getting information about
+ // resources.
+ string get = 2;
+
+ // Maps to HTTP PUT. Used for replacing a resource.
+ string put = 3;
+
+ // Maps to HTTP POST. Used for creating a resource or performing an action.
+ string post = 4;
+
+ // Maps to HTTP DELETE. Used for deleting a resource.
+ string delete = 5;
+
+ // Maps to HTTP PATCH. Used for updating a resource.
+ string patch = 6;
+
+ // The custom pattern is used for specifying an HTTP method that is not
+ // included in the `pattern` field, such as HEAD, or "*" to leave the
+ // HTTP method unspecified for this rule. The wild-card rule is useful
+ // for services that provide content to Web (HTML) clients.
+ CustomHttpPattern custom = 8;
+ }
+
+ // The name of the request field whose value is mapped to the HTTP request
+ // body, or `*` for mapping all request fields not captured by the path
+ // pattern to the HTTP body, or omitted for not having any HTTP request body.
+ //
+ // NOTE: the referred field must be present at the top-level of the request
+ // message type.
+ string body = 7;
+
+ // Optional. The name of the response field whose value is mapped to the HTTP
+ // response body. When omitted, the entire response message will be used
+ // as the HTTP response body.
+ //
+ // NOTE: The referred field must be present at the top-level of the response
+ // message type.
+ string response_body = 12;
+
+ // Additional HTTP bindings for the selector. Nested bindings must
+ // not contain an `additional_bindings` field themselves (that is,
+ // the nesting may only be one level deep).
+ repeated HttpRule additional_bindings = 11;
+}
+
+// A custom pattern is used for defining custom HTTP verb.
+message CustomHttpPattern {
+ // The name of this custom HTTP verb.
+ string kind = 1;
+
+ // The path matched by this custom verb.
+ string path = 2;
+}

protos/google/api/label.proto

@@ -0,0 +1,49 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/api/label;label";
+option java_multiple_files = true;
+option java_outer_classname = "LabelProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// A description of a label.
+message LabelDescriptor {
+ // Value types that can be used as label values.
+ enum ValueType {
+ // A variable-length string. This is the default.
+ STRING = 0;
+
+ // Boolean; true or false.
+ BOOL = 1;
+
+ // A 64-bit signed integer.
+ INT64 = 2;
+ }
+
+ // The label key.
+ string key = 1;
+
+ // The type of data that can be assigned to the label.
+ ValueType value_type = 2;
+
+ // A human-readable description for the label.
+ string description = 3;
+}

protos/google/api/launch_stage.proto

@@ -0,0 +1,67 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+option go_package = "google.golang.org/genproto/googleapis/api;api";
+option java_multiple_files = true;
+option java_outer_classname = "LaunchStageProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// The launch stage as defined by [Google Cloud Platform
+// Launch Stages](http://cloud.google.com/terms/launch-stages).
+enum LaunchStage {
+ // Do not use this default value.
+ LAUNCH_STAGE_UNSPECIFIED = 0;
+
+ // Early Access features are limited to a closed group of testers. To use
+ // these features, you must sign up in advance and sign a Trusted Tester
+ // agreement (which includes confidentiality provisions). These features may
+ // be unstable, changed in backward-incompatible ways, and are not
+ // guaranteed to be released.
+ EARLY_ACCESS = 1;
+
+ // Alpha is a limited availability test for releases before they are cleared
+ // for widespread use. By Alpha, all significant design issues are resolved
+ // and we are in the process of verifying functionality. Alpha customers
+ // need to apply for access, agree to applicable terms, and have their
+ // projects whitelisted. Alpha releases don’t have to be feature complete,
+ // no SLAs are provided, and there are no technical support obligations, but
+ // they will be far enough along that customers can actually use them in
+ // test environments or for limited-use tests -- just like they would in
+ // normal production cases.
+ ALPHA = 2;
+
+ // Beta is the point at which we are ready to open a release for any
+ // customer to use. There are no SLA or technical support obligations in a
+ // Beta release. Products will be complete from a feature perspective, but
+ // may have some open outstanding issues. Beta releases are suitable for
+ // limited production use cases.
+ BETA = 3;
+
+ // GA features are open to all developers and are considered stable and
+ // fully qualified for production use.
+ GA = 4;
+
+ // Deprecated features are scheduled to be shut down and removed. For more
+ // information, see the “Deprecation Policy” section of our [Terms of
+ // Service](https://cloud.google.com/terms/)
+ // and the [Google Cloud Platform Subject to the Deprecation
+ // Policy](https://cloud.google.com/terms/deprecation) documentation.
+ DEPRECATED = 5;
+}

protos/google/api/logging.proto

@@ -0,0 +1,84 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+import "google/api/annotations.proto";
+
+option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig";
+option java_multiple_files = true;
+option java_outer_classname = "LoggingProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// Logging configuration of the service.
+//
+// The following example shows how to configure logs to be sent to the
+// producer and consumer projects. In the example, the `activity_history`
+// log is sent to both the producer and consumer projects, whereas the
+// `purchase_history` log is only sent to the producer project.
+//
+// monitored_resources:
+// - type: library.googleapis.com/branch
+// labels:
+// - key: /city
+// description: The city where the library branch is located in.
+// - key: /name
+// description: The name of the branch.
+// logs:
+// - name: activity_history
+// labels:
+// - key: /customer_id
+// - name: purchase_history
+// logging:
+// producer_destinations:
+// - monitored_resource: library.googleapis.com/branch
+// logs:
+// - activity_history
+// - purchase_history
+// consumer_destinations:
+// - monitored_resource: library.googleapis.com/branch
+// logs:
+// - activity_history
+message Logging {
+ // Configuration of a specific logging destination (the producer project
+ // or the consumer project).
+ message LoggingDestination {
+ // The monitored resource type. The type must be defined in the
+ // [Service.monitored_resources][google.api.Service.monitored_resources]
+ // section.
+ string monitored_resource = 3;
+
+ // Names of the logs to be sent to this destination. Each name must
+ // be defined in the [Service.logs][google.api.Service.logs] section. If the
+ // log name is not a domain scoped name, it will be automatically prefixed
+ // with the service name followed by "/".
+ repeated string logs = 1;
+ }
+
+ // Logging configurations for sending logs to the producer project.
+ // There can be multiple producer destinations, each one must have a
+ // different monitored resource type. A log can be used in at most
+ // one producer destination.
+ repeated LoggingDestination producer_destinations = 1;
+
+ // Logging configurations for sending logs to the consumer project.
+ // There can be multiple consumer destinations, each one must have a
+ // different monitored resource type. A log can be used in at most
+ // one consumer destination.
+ repeated LoggingDestination consumer_destinations = 2;
+}

protos/google/api/log.proto

@@ -0,0 +1,55 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+import "google/api/label.proto";
+
+option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig";
+option java_multiple_files = true;
+option java_outer_classname = "LogProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// A description of a log type. Example in YAML format:
+//
+// - name: library.googleapis.com/activity_history
+// description: The history of borrowing and returning library items.
+// display_name: Activity
+// labels:
+// - key: /customer_id
+// description: Identifier of a library customer
+message LogDescriptor {
+ // The name of the log. It must be less than 512 characters long and can
+ // include the following characters: upper- and lower-case alphanumeric
+ // characters [A-Za-z0-9], and punctuation characters including
+ // slash, underscore, hyphen, period [/_-.].
+ string name = 1;
+
+ // The set of labels that are available to describe a specific log entry.
+ // Runtime requests that contain labels not specified here are
+ // considered invalid.
+ repeated LabelDescriptor labels = 2;
+
+ // A human-readable description of this log. This information appears in
+ // the documentation and can contain details.
+ string description = 3;
+
+ // The human-readable name for this log. This information appears on
+ // the user interface and should be concise.
+ string display_name = 4;
+}

protos/google/api/metric.proto

@@ -0,0 +1,216 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+import "google/api/label.proto";
+import "google/api/launch_stage.proto";
+import "google/protobuf/duration.proto";
+
+option go_package = "google.golang.org/genproto/googleapis/api/metric;metric";
+option java_multiple_files = true;
+option java_outer_classname = "MetricProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// Defines a metric type and its schema. Once a metric descriptor is created,
+// deleting or altering it stops data collection and makes the metric type's
+// existing data unusable.
+message MetricDescriptor {
+ // Additional annotations that can be used to guide the usage of a metric.
+ message MetricDescriptorMetadata {
+ // The launch stage of the metric definition.
+ LaunchStage launch_stage = 1;
+
+ // The sampling period of metric data points. For metrics which are written
+ // periodically, consecutive data points are stored at this time interval,
+ // excluding data loss due to errors. Metrics with a higher granularity have
+ // a smaller sampling period.
+ google.protobuf.Duration sample_period = 2;
+
+ // The delay of data points caused by ingestion. Data points older than this
+ // age are guaranteed to be ingested and available to be read, excluding
+ // data loss due to errors.
+ google.protobuf.Duration ingest_delay = 3;
+ }
+
+ // The kind of measurement. It describes how the data is reported.
+ enum MetricKind {
+ // Do not use this default value.
+ METRIC_KIND_UNSPECIFIED = 0;
+
+ // An instantaneous measurement of a value.
+ GAUGE = 1;
+
+ // The change in a value during a time interval.
+ DELTA = 2;
+
+ // A value accumulated over a time interval. Cumulative
+ // measurements in a time series should have the same start time
+ // and increasing end times, until an event resets the cumulative
+ // value to zero and sets a new start time for the following
+ // points.
+ CUMULATIVE = 3;
+ }
+
+ // The value type of a metric.
+ enum ValueType {
+ // Do not use this default value.
+ VALUE_TYPE_UNSPECIFIED = 0;
+
+ // The value is a boolean.
+ // This value type can be used only if the metric kind is `GAUGE`.
+ BOOL = 1;
+
+ // The value is a signed 64-bit integer.
+ INT64 = 2;
+
+ // The value is a double precision floating point number.
+ DOUBLE = 3;
+
+ // The value is a text string.
+ // This value type can be used only if the metric kind is `GAUGE`.
+ STRING = 4;
+
+ // The value is a [`Distribution`][google.api.Distribution].
+ DISTRIBUTION = 5;
+
+ // The value is money.
+ MONEY = 6;
+ }
+
+ // The resource name of the metric descriptor.
+ string name = 1;
+
+ // The metric type, including its DNS name prefix. The type is not
+ // URL-encoded. All user-defined metric types have the DNS name
+ // `custom.googleapis.com` or `external.googleapis.com`. Metric types should
+ // use a natural hierarchical grouping. For example:
+ //
+ // "custom.googleapis.com/invoice/paid/amount"
+ // "external.googleapis.com/prometheus/up"
+ // "appengine.googleapis.com/http/server/response_latencies"
+ string type = 8;
+
+ // The set of labels that can be used to describe a specific
+ // instance of this metric type. For example, the
+ // `appengine.googleapis.com/http/server/response_latencies` metric
+ // type has a label for the HTTP response code, `response_code`, so
+ // you can look at latencies for successful responses or just
+ // for responses that failed.
+ repeated LabelDescriptor labels = 2;
+
+ // Whether the metric records instantaneous values, changes to a value, etc.
+ // Some combinations of `metric_kind` and `value_type` might not be supported.
+ MetricKind metric_kind = 3;
+
+ // Whether the measurement is an integer, a floating-point number, etc.
+ // Some combinations of `metric_kind` and `value_type` might not be supported.
+ ValueType value_type = 4;
+
+ // The unit in which the metric value is reported. It is only applicable
+ // if the `value_type` is `INT64`, `DOUBLE`, or `DISTRIBUTION`. The
+ // supported units are a subset of [The Unified Code for Units of
+ // Measure](http://unitsofmeasure.org/ucum.html) standard:
+ //
+ // **Basic units (UNIT)**
+ //
+ // * `bit` bit
+ // * `By` byte
+ // * `s` second
+ // * `min` minute
+ // * `h` hour
+ // * `d` day
+ //
+ // **Prefixes (PREFIX)**
+ //
+ // * `k` kilo (10**3)
+ // * `M` mega (10**6)
+ // * `G` giga (10**9)
+ // * `T` tera (10**12)
+ // * `P` peta (10**15)
+ // * `E` exa (10**18)
+ // * `Z` zetta (10**21)
+ // * `Y` yotta (10**24)
+ // * `m` milli (10**-3)
+ // * `u` micro (10**-6)
+ // * `n` nano (10**-9)
+ // * `p` pico (10**-12)
+ // * `f` femto (10**-15)
+ // * `a` atto (10**-18)
+ // * `z` zepto (10**-21)
+ // * `y` yocto (10**-24)
+ // * `Ki` kibi (2**10)
+ // * `Mi` mebi (2**20)
+ // * `Gi` gibi (2**30)
+ // * `Ti` tebi (2**40)
+ //
+ // **Grammar**
+ //
+ // The grammar also includes these connectors:
+ //
+ // * `/` division (as an infix operator, e.g. `1/s`).
+ // * `.` multiplication (as an infix operator, e.g. `GBy.d`)
+ //
+ // The grammar for a unit is as follows:
+ //
+ // Expression = Component { "." Component } { "/" Component } ;
+ //
+ // Component = ( [ PREFIX ] UNIT | "%" ) [ Annotation ]
+ // | Annotation
+ // | "1"
+ // ;
+ //
+ // Annotation = "{" NAME "}" ;
+ //
+ // Notes:
+ //
+ // * `Annotation` is just a comment if it follows a `UNIT` and is
+ // equivalent to `1` if it is used alone. For examples,
+ // `{requests}/s == 1/s`, `By{transmitted}/s == By/s`.
+ // * `NAME` is a sequence of non-blank printable ASCII characters not
+ // containing '{' or '}'.
+ // * `1` represents dimensionless value 1, such as in `1/s`.
+ // * `%` represents dimensionless value 1/100, and annotates values giving
+ // a percentage.
+ string unit = 5;
+
+ // A detailed description of the metric, which can be used in documentation.
+ string description = 6;
+
+ // A concise name for the metric, which can be displayed in user interfaces.
+ // Use sentence case without an ending period, for example "Request count".
+ // This field is optional but it is recommended to be set for any metrics
+ // associated with user-visible concepts, such as Quota.
+ string display_name = 7;
+
+ // Optional. Metadata which can be used to guide usage of the metric.
+ MetricDescriptorMetadata metadata = 10;
+}
+
+// A specific metric, identified by specifying values for all of the
+// labels of a [`MetricDescriptor`][google.api.MetricDescriptor].
+message Metric {
+ // An existing metric type, see
+ // [google.api.MetricDescriptor][google.api.MetricDescriptor]. For example,
+ // `custom.googleapis.com/invoice/paid/amount`.
+ string type = 3;
+
+ // The set of label values that uniquely identify this metric. All
+ // labels listed in the `MetricDescriptor` must be assigned values.
+ map<string, string> labels = 2;
+}

protos/google/api/monitored_resource.proto

@@ -0,0 +1,120 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+import "google/api/label.proto";
+import "google/protobuf/struct.proto";
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/api/monitoredres;monitoredres";
+option java_multiple_files = true;
+option java_outer_classname = "MonitoredResourceProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// An object that describes the schema of a
+// [MonitoredResource][google.api.MonitoredResource] object using a type name
+// and a set of labels. For example, the monitored resource descriptor for
+// Google Compute Engine VM instances has a type of
+// `"gce_instance"` and specifies the use of the labels `"instance_id"` and
+// `"zone"` to identify particular VM instances.
+//
+// Different APIs can support different monitored resource types. APIs generally
+// provide a `list` method that returns the monitored resource descriptors used
+// by the API.
+message MonitoredResourceDescriptor {
+ // Optional. The resource name of the monitored resource descriptor:
+ // `"projects/{project_id}/monitoredResourceDescriptors/{type}"` where
+ // {type} is the value of the `type` field in this object and
+ // {project_id} is a project ID that provides API-specific context for
+ // accessing the type. APIs that do not use project information can use the
+ // resource name format `"monitoredResourceDescriptors/{type}"`.
+ string name = 5;
+
+ // Required. The monitored resource type. For example, the type
+ // `"cloudsql_database"` represents databases in Google Cloud SQL.
+ // The maximum length of this value is 256 characters.
+ string type = 1;
+
+ // Optional. A concise name for the monitored resource type that might be
+ // displayed in user interfaces. It should be a Title Cased Noun Phrase,
+ // without any article or other determiners. For example,
+ // `"Google Cloud SQL Database"`.
+ string display_name = 2;
+
+ // Optional. A detailed description of the monitored resource type that might
+ // be used in documentation.
+ string description = 3;
+
+ // Required. A set of labels used to describe instances of this monitored
+ // resource type. For example, an individual Google Cloud SQL database is
+ // identified by values for the labels `"database_id"` and `"zone"`.
+ repeated LabelDescriptor labels = 4;
+}
+
+// An object representing a resource that can be used for monitoring, logging,
+// billing, or other purposes. Examples include virtual machine instances,
+// databases, and storage devices such as disks. The `type` field identifies a
+// [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor] object
+// that describes the resource's schema. Information in the `labels` field
+// identifies the actual resource and its attributes according to the schema.
+// For example, a particular Compute Engine VM instance could be represented by
+// the following object, because the
+// [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor] for
+// `"gce_instance"` has labels
+// `"instance_id"` and `"zone"`:
+//
+// { "type": "gce_instance",
+// "labels": { "instance_id": "12345678901234",
+// "zone": "us-central1-a" }}
+message MonitoredResource {
+ // Required. The monitored resource type. This field must match
+ // the `type` field of a
+ // [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor]
+ // object. For example, the type of a Compute Engine VM instance is
+ // `gce_instance`.
+ string type = 1;
+
+ // Required. Values for all of the labels listed in the associated monitored
+ // resource descriptor. For example, Compute Engine VM instances use the
+ // labels `"project_id"`, `"instance_id"`, and `"zone"`.
+ map<string, string> labels = 2;
+}
+
+// Auxiliary metadata for a [MonitoredResource][google.api.MonitoredResource]
+// object. [MonitoredResource][google.api.MonitoredResource] objects contain the
+// minimum set of information to uniquely identify a monitored resource
+// instance. There is some other useful auxiliary metadata. Monitoring and
+// Logging use an ingestion pipeline to extract metadata for cloud resources of
+// all types, and store the metadata in this message.
+message MonitoredResourceMetadata {
+ // Output only. Values for predefined system metadata labels.
+ // System labels are a kind of metadata extracted by Google, including
+ // "machine_image", "vpc", "subnet_id",
+ // "security_group", "name", etc.
+ // System label values can be only strings, Boolean values, or a list of
+ // strings. For example:
+ //
+ // { "name": "my-test-instance",
+ // "security_group": ["a", "b", "c"],
+ // "spot_instance": false }
+ google.protobuf.Struct system_labels = 1;
+
+ // Output only. A map of user-defined metadata labels.
+ map<string, string> user_labels = 2;
+}

protos/google/api/monitoring.proto

@@ -0,0 +1,95 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+import "google/api/annotations.proto";
+
+option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig";
+option java_multiple_files = true;
+option java_outer_classname = "MonitoringProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// Monitoring configuration of the service.
+//
+// The example below shows how to configure monitored resources and metrics
+// for monitoring. In the example, a monitored resource and two metrics are
+// defined. The `library.googleapis.com/book/returned_count` metric is sent
+// to both producer and consumer projects, whereas the
+// `library.googleapis.com/book/overdue_count` metric is only sent to the
+// consumer project.
+//
+// monitored_resources:
+// - type: library.googleapis.com/branch
+// labels:
+// - key: /city
+// description: The city where the library branch is located in.
+// - key: /name
+// description: The name of the branch.
+// metrics:
+// - name: library.googleapis.com/book/returned_count
+// metric_kind: DELTA
+// value_type: INT64
+// labels:
+// - key: /customer_id
+// - name: library.googleapis.com/book/overdue_count
+// metric_kind: GAUGE
+// value_type: INT64
+// labels:
+// - key: /customer_id
+// monitoring:
+// producer_destinations:
+// - monitored_resource: library.googleapis.com/branch
+// metrics:
+// - library.googleapis.com/book/returned_count
+// consumer_destinations:
+// - monitored_resource: library.googleapis.com/branch
+// metrics:
+// - library.googleapis.com/book/returned_count
+// - library.googleapis.com/book/overdue_count
+message Monitoring {
+ // Configuration of a specific monitoring destination (the producer project
+ // or the consumer project).
+ message MonitoringDestination {
+ // The monitored resource type. The type must be defined in
+ // [Service.monitored_resources][google.api.Service.monitored_resources]
+ // section.
+ string monitored_resource = 1;
+
+ // Types of the metrics to report to this monitoring destination.
+ // Each type must be defined in
+ // [Service.metrics][google.api.Service.metrics] section.
+ repeated string metrics = 2;
+ }
+
+ // Monitoring configurations for sending metrics to the producer project.
+ // There can be multiple producer destinations. A monitored resouce type may
+ // appear in multiple monitoring destinations if different aggregations are
+ // needed for different sets of metrics associated with that monitored
+ // resource type. A monitored resource and metric pair may only be used once
+ // in the Monitoring configuration.
+ repeated MonitoringDestination producer_destinations = 1;
+
+ // Monitoring configurations for sending metrics to the consumer project.
+ // There can be multiple consumer destinations. A monitored resouce type may
+ // appear in multiple monitoring destinations if different aggregations are
+ // needed for different sets of metrics associated with that monitored
+ // resource type. A monitored resource and metric pair may only be used once
+ // in the Monitoring configuration.
+ repeated MonitoringDestination consumer_destinations = 2;
+}

protos/google/api/quota.proto

@@ -0,0 +1,188 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+import "google/api/annotations.proto";
+
+option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig";
+option java_multiple_files = true;
+option java_outer_classname = "QuotaProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// Quota configuration helps to achieve fairness and budgeting in service
+// usage.
+//
+// The quota configuration works this way:
+// - The service configuration defines a set of metrics.
+// - For API calls, the quota.metric_rules maps methods to metrics with
+// corresponding costs.
+// - The quota.limits defines limits on the metrics, which will be used for
+// quota checks at runtime.
+//
+// An example quota configuration in yaml format:
+//
+// quota:
+// limits:
+//
+// - name: apiWriteQpsPerProject
+// metric: library.googleapis.com/write_calls
+// unit: "1/min/{project}" # rate limit for consumer projects
+// values:
+// STANDARD: 10000
+//
+//
+// # The metric rules bind all methods to the read_calls metric,
+// # except for the UpdateBook and DeleteBook methods. These two methods
+// # are mapped to the write_calls metric, with the UpdateBook method
+// # consuming at twice rate as the DeleteBook method.
+// metric_rules:
+// - selector: "*"
+// metric_costs:
+// library.googleapis.com/read_calls: 1
+// - selector: google.example.library.v1.LibraryService.UpdateBook
+// metric_costs:
+// library.googleapis.com/write_calls: 2
+// - selector: google.example.library.v1.LibraryService.DeleteBook
+// metric_costs:
+// library.googleapis.com/write_calls: 1
+//
+// Corresponding Metric definition:
+//
+// metrics:
+// - name: library.googleapis.com/read_calls
+// display_name: Read requests
+// metric_kind: DELTA
+// value_type: INT64
+//
+// - name: library.googleapis.com/write_calls
+// display_name: Write requests
+// metric_kind: DELTA
+// value_type: INT64
+message Quota {
+ // List of `QuotaLimit` definitions for the service.
+ repeated QuotaLimit limits = 3;
+
+ // List of `MetricRule` definitions, each one mapping a selected method to one
+ // or more metrics.
+ repeated MetricRule metric_rules = 4;
+}
+
+// Bind API methods to metrics. Binding a method to a metric causes that
+// metric's configured quota behaviors to apply to the method call.
+message MetricRule {
+ // Selects the methods to which this rule applies.
+ //
+ // Refer to [selector][google.api.DocumentationRule.selector] for syntax
+ // details.
+ string selector = 1;
+
+ // Metrics to update when the selected methods are called, and the associated
+ // cost applied to each metric.
+ //
+ // The key of the map is the metric name, and the values are the amount
+ // increased for the metric against which the quota limits are defined.
+ // The value must not be negative.
+ map<string, int64> metric_costs = 2;
+}
+
+// `QuotaLimit` defines a specific limit that applies over a specified duration
+// for a limit type. There can be at most one limit for a duration and limit
+// type combination defined within a `QuotaGroup`.
+message QuotaLimit {
+ // Name of the quota limit.
+ //
+ // The name must be provided, and it must be unique within the service. The
+ // name can only include alphanumeric characters as well as '-'.
+ //
+ // The maximum length of the limit name is 64 characters.
+ string name = 6;
+
+ // Optional. User-visible, extended description for this quota limit.
+ // Should be used only when more context is needed to understand this limit
+ // than provided by the limit's display name (see: `display_name`).
+ string description = 2;
+
+ // Default number of tokens that can be consumed during the specified
+ // duration. This is the number of tokens assigned when a client
+ // application developer activates the service for his/her project.
+ //
+ // Specifying a value of 0 will block all requests. This can be used if you
+ // are provisioning quota to selected consumers and blocking others.
+ // Similarly, a value of -1 will indicate an unlimited quota. No other
+ // negative values are allowed.
+ //
+ // Used by group-based quotas only.
+ int64 default_limit = 3;
+
+ // Maximum number of tokens that can be consumed during the specified
+ // duration. Client application developers can override the default limit up
+ // to this maximum. If specified, this value cannot be set to a value less
+ // than the default limit. If not specified, it is set to the default limit.
+ //
+ // To allow clients to apply overrides with no upper bound, set this to -1,
+ // indicating unlimited maximum quota.
+ //
+ // Used by group-based quotas only.
+ int64 max_limit = 4;
+
+ // Free tier value displayed in the Developers Console for this limit.
+ // The free tier is the number of tokens that will be subtracted from the
+ // billed amount when billing is enabled.
+ // This field can only be set on a limit with duration "1d", in a billable
+ // group; it is invalid on any other limit. If this field is not set, it
+ // defaults to 0, indicating that there is no free tier for this service.
+ //
+ // Used by group-based quotas only.
+ int64 free_tier = 7;
+
+ // Duration of this limit in textual notation. Example: "100s", "24h", "1d".
+ // For duration longer than a day, only multiple of days is supported. We
+ // support only "100s" and "1d" for now. Additional support will be added in
+ // the future. "0" indicates indefinite duration.
+ //
+ // Used by group-based quotas only.
+ string duration = 5;
+
+ // The name of the metric this quota limit applies to. The quota limits with
+ // the same metric will be checked together during runtime. The metric must be
+ // defined within the service config.
+ string metric = 8;
+
+ // Specify the unit of the quota limit. It uses the same syntax as
+ // [Metric.unit][]. The supported unit kinds are determined by the quota
+ // backend system.
+ //
+ // Here are some examples:
+ // * "1/min/{project}" for quota per minute per project.
+ //
+ // Note: the order of unit components is insignificant.
+ // The "1" at the beginning is required to follow the metric unit syntax.
+ string unit = 9;
+
+ // Tiered limit values. You must specify this as a key:value pair, with an
+ // integer value that is the maximum number of requests allowed for the
+ // specified unit. Currently only STANDARD is supported.
+ map<string, int64> values = 10;
+
+ // User-visible display name for this limit.
+ // Optional. If not set, the UI will provide a default display name based on
+ // the quota configuration. This field can be used to override the default
+ // display name generated from the configuration.
+ string display_name = 12;
+}

protos/google/api/resource.proto

@@ -0,0 +1,117 @@
+// Copyright 2019 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+import "google/protobuf/descriptor.proto";
+
+option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
+option java_multiple_files = true;
+option java_outer_classname = "ResourceProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+option (google.api.resource_definition) = {
+ pattern: "projects/{project}"
+ symbol: "Project"
+};
+
+option (google.api.resource_definition) = {
+ pattern: "organizations/{organization}"
+ symbol: "Organization"
+};
+
+extend google.protobuf.FieldOptions {
+ // A representation of the resource.
+ // This is generally intended to be attached to the "name" field of
+ // the message representing the resource.
+ //
+ // Example:
+ //
+ // message Topic {
+ // string name = 1 [(google.api.resource) = {
+ // pattern: "projects/{project}/topics/{topic}"
+ // }];
+ // }
+ //
+ // Only one of {`resource`, `resource_reference`} may be set.
+ google.api.Resource resource = 1053;
+
+ // The fully qualified message name of the type that this field references.
+ // Marks this as a field referring to a resource in another message.
+ //
+ // Example:
+ //
+ // message Subscription {
+ // string topic = 2
+ // [(google.api.resource_reference) = "google.pubsub.v1.Topic"];
+ // }
+ //
+ // If the referenced message is in the same proto package, the package
+ // may be omitted:
+ //
+ // message Subscription {
+ // string topic = 2
+ // [(google.api.resource_reference) = "Topic"];
+ // }
+ //
+ // Only one of {`resource`, `resource_reference`} may be set.
+ string resource_reference = 1055;
+}
+
+extend google.protobuf.FileOptions {
+ // A representation of a resource.
+ // At a file level, this is generally used to define information for a
+ // resource from another API, or for a resource that does not have an
+ // associated proto message.
+ //
+ // See the example of `google.api.Project` and `google.api.Organization`
+ // at the bottom of this file.
+ repeated google.api.Resource resource_definition = 1053;
+}
+
+// An annotation designating that this field designates a resource.
+//
+// Example:
+//
+// message Topic {
+// string name = 1 [(google.api.resource) = {
+// name: "projects/{project}/topics/{topic}"
+// }];
+// }
+message Resource {
+ // Required. The resource's name template.
+ //
+ // Examples:
+ // - "projects/{project}/topics/{topic}"
+ // - "projects/{project}/knowledgeBases/{knowledge_base}"
+ string pattern = 1;
+
+ // The name that should be used in code to describe the resource,
+ // in PascalCase.
+ //
+ // If omitted, this is inferred from the name of the message.
+ // This is required if the resource is being defined without the context
+ // of a message (see `resource_definition`, below).
+ //
+ // Example:
+ // option (google.api.resource_definition) = {
+ // pattern: "projects/{project}"
+ // symbol: "Project"
+ // };
+ string symbol = 2;
+}

protos/google/api/servicecontrol/v1/check_error.proto

@@ -0,0 +1,98 @@
+// Copyright 2017 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.api.servicecontrol.v1;
+
+import "google/api/annotations.proto";
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/api/servicecontrol/v1;servicecontrol";
+option java_multiple_files = true;
+option java_outer_classname = "CheckErrorProto";
+option java_package = "com.google.api.servicecontrol.v1";
+
+// Defines the errors to be returned in
+// [google.api.servicecontrol.v1.CheckResponse.check_errors][google.api.servicecontrol.v1.CheckResponse.check_errors].
+message CheckError {
+ // Error codes for Check responses.
+ enum Code {
+ // This is never used in `CheckResponse`.
+ ERROR_CODE_UNSPECIFIED = 0;
+
+ // The consumer's project id was not found.
+ // Same as [google.rpc.Code.NOT_FOUND][].
+ NOT_FOUND = 5;
+
+ // The consumer doesn't have access to the specified resource.
+ // Same as [google.rpc.Code.PERMISSION_DENIED][].
+ PERMISSION_DENIED = 7;
+
+ // Quota check failed. Same as [google.rpc.Code.RESOURCE_EXHAUSTED][].
+ RESOURCE_EXHAUSTED = 8;
+
+ // The consumer hasn't activated the service.
+ SERVICE_NOT_ACTIVATED = 104;
+
+ // The consumer cannot access the service because billing is disabled.
+ BILLING_DISABLED = 107;
+
+ // The consumer's project has been marked as deleted (soft deletion).
+ PROJECT_DELETED = 108;
+
+ // The consumer's project number or id does not represent a valid project.
+ PROJECT_INVALID = 114;
+
+ // The IP address of the consumer is invalid for the specific consumer
+ // project.
+ IP_ADDRESS_BLOCKED = 109;
+
+ // The referer address of the consumer request is invalid for the specific
+ // consumer project.
+ REFERER_BLOCKED = 110;
+
+ // The client application of the consumer request is invalid for the
+ // specific consumer project.
+ CLIENT_APP_BLOCKED = 111;
+
+ // The API targeted by this request is invalid for the specified consumer
+ // project.
+ API_TARGET_BLOCKED = 122;
+
+ // The consumer's API key is invalid.
+ API_KEY_INVALID = 105;
+
+ // The consumer's API Key has expired.
+ API_KEY_EXPIRED = 112;
+
+ // The consumer's API Key was not found in config record.
+ API_KEY_NOT_FOUND = 113;
+
+ // The backend server for looking up project id/number is unavailable.
+ NAMESPACE_LOOKUP_UNAVAILABLE = 300;
+
+ // The backend server for checking service status is unavailable.
+ SERVICE_STATUS_UNAVAILABLE = 301;
+
+ // The backend server for checking billing status is unavailable.
+ BILLING_STATUS_UNAVAILABLE = 302;
+ }
+
+ // The error code.
+ Code code = 1;
+
+ // Free-form text providing details on the error cause of the error.
+ string detail = 2;
+}

protos/google/api/servicecontrol/v1/distribution.proto

@@ -0,0 +1,158 @@
+// Copyright 2017 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.api.servicecontrol.v1;
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/api/servicecontrol/v1;servicecontrol";
+option java_multiple_files = true;
+option java_outer_classname = "DistributionProto";
+option java_package = "com.google.api.servicecontrol.v1";
+
+// Distribution represents a frequency distribution of double-valued sample
+// points. It contains the size of the population of sample points plus
+// additional optional information:
+//
+// - the arithmetic mean of the samples
+// - the minimum and maximum of the samples
+// - the sum-squared-deviation of the samples, used to compute variance
+// - a histogram of the values of the sample points
+message Distribution {
+ // Describing buckets with constant width.
+ message LinearBuckets {
+ // The number of finite buckets. With the underflow and overflow buckets,
+ // the total number of buckets is `num_finite_buckets` + 2.
+ // See comments on `bucket_options` for details.
+ int32 num_finite_buckets = 1;
+
+ // The i'th linear bucket covers the interval
+ // [offset + (i-1) * width, offset + i * width)
+ // where i ranges from 1 to num_finite_buckets, inclusive.
+ // Must be strictly positive.
+ double width = 2;
+
+ // The i'th linear bucket covers the interval
+ // [offset + (i-1) * width, offset + i * width)
+ // where i ranges from 1 to num_finite_buckets, inclusive.
+ double offset = 3;
+ }
+
+ // Describing buckets with exponentially growing width.
+ message ExponentialBuckets {
+ // The number of finite buckets. With the underflow and overflow buckets,
+ // the total number of buckets is `num_finite_buckets` + 2.
+ // See comments on `bucket_options` for details.
+ int32 num_finite_buckets = 1;
+
+ // The i'th exponential bucket covers the interval
+ // [scale * growth_factor^(i-1), scale * growth_factor^i)
+ // where i ranges from 1 to num_finite_buckets inclusive.
+ // Must be larger than 1.0.
+ double growth_factor = 2;
+
+ // The i'th exponential bucket covers the interval
+ // [scale * growth_factor^(i-1), scale * growth_factor^i)
+ // where i ranges from 1 to num_finite_buckets inclusive.
+ // Must be > 0.
+ double scale = 3;
+ }
+
+ // Describing buckets with arbitrary user-provided width.
+ message ExplicitBuckets {
+ // 'bound' is a list of strictly increasing boundaries between
+ // buckets. Note that a list of length N-1 defines N buckets because
+ // of fenceposting. See comments on `bucket_options` for details.
+ //
+ // The i'th finite bucket covers the interval
+ // [bound[i-1], bound[i])
+ // where i ranges from 1 to bound_size() - 1. Note that there are no
+ // finite buckets at all if 'bound' only contains a single element; in
+ // that special case the single bound defines the boundary between the
+ // underflow and overflow buckets.
+ //
+ // bucket number lower bound upper bound
+ // i == 0 (underflow) -inf bound[i]
+ // 0 < i < bound_size() bound[i-1] bound[i]
+ // i == bound_size() (overflow) bound[i-1] +inf
+ repeated double bounds = 1;
+ }
+
+ // The total number of samples in the distribution. Must be >= 0.
+ int64 count = 1;
+
+ // The arithmetic mean of the samples in the distribution. If `count` is
+ // zero then this field must be zero.
+ double mean = 2;
+
+ // The minimum of the population of values. Ignored if `count` is zero.
+ double minimum = 3;
+
+ // The maximum of the population of values. Ignored if `count` is zero.
+ double maximum = 4;
+
+ // The sum of squared deviations from the mean:
+ // Sum[i=1..count]((x_i - mean)^2)
+ // where each x_i is a sample values. If `count` is zero then this field
+ // must be zero, otherwise validation of the request fails.
+ double sum_of_squared_deviation = 5;
+
+ // The number of samples in each histogram bucket. `bucket_counts` are
+ // optional. If present, they must sum to the `count` value.
+ //
+ // The buckets are defined below in `bucket_option`. There are N buckets.
+ // `bucket_counts[0]` is the number of samples in the underflow bucket.
+ // `bucket_counts[1]` to `bucket_counts[N-1]` are the numbers of samples
+ // in each of the finite buckets. And `bucket_counts[N] is the number
+ // of samples in the overflow bucket. See the comments of `bucket_option`
+ // below for more details.
+ //
+ // Any suffix of trailing zeros may be omitted.
+ repeated int64 bucket_counts = 6;
+
+ // Defines the buckets in the histogram. `bucket_option` and `bucket_counts`
+ // must be both set, or both unset.
+ //
+ // Buckets are numbered in the range of [0, N], with a total of N+1 buckets.
+ // There must be at least two buckets (a single-bucket histogram gives
+ // no information that isn't already provided by `count`).
+ //
+ // The first bucket is the underflow bucket which has a lower bound
+ // of -inf. The last bucket is the overflow bucket which has an
+ // upper bound of +inf. All other buckets (if any) are called "finite"
+ // buckets because they have finite lower and upper bounds. As described
+ // below, there are three ways to define the finite buckets.
+ //
+ // (1) Buckets with constant width.
+ // (2) Buckets with exponentially growing widths.
+ // (3) Buckets with arbitrary user-provided widths.
+ //
+ // In all cases, the buckets cover the entire real number line (-inf,
+ // +inf). Bucket upper bounds are exclusive and lower bounds are
+ // inclusive. The upper bound of the underflow bucket is equal to the
+ // lower bound of the smallest finite bucket; the lower bound of the
+ // overflow bucket is equal to the upper bound of the largest finite
+ // bucket.
+ oneof bucket_option {
+ // Buckets with constant width.
+ LinearBuckets linear_buckets = 7;
+
+ // Buckets with exponentially growing width.
+ ExponentialBuckets exponential_buckets = 8;
+
+ // Buckets with arbitrary user-provided width.
+ ExplicitBuckets explicit_buckets = 9;
+ }
+}

protos/google/api/servicecontrol/v1/log_entry.proto

@@ -0,0 +1,66 @@
+// Copyright 2017 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.api.servicecontrol.v1;
+
+import "google/api/annotations.proto";
+import "google/logging/type/log_severity.proto";
+import "google/protobuf/any.proto";
+import "google/protobuf/struct.proto";
+import "google/protobuf/timestamp.proto";
+
+option go_package = "google.golang.org/genproto/googleapis/api/servicecontrol/v1;servicecontrol";
+option java_multiple_files = true;
+option java_outer_classname = "LogEntryProto";
+option java_package = "com.google.api.servicecontrol.v1";
+
+// An individual log entry.
+message LogEntry {
+ // Required. The log to which this log entry belongs. Examples: `"syslog"`,
+ // `"book_log"`.
+ string name = 10;
+
+ // The time the event described by the log entry occurred. If
+ // omitted, defaults to operation start time.
+ google.protobuf.Timestamp timestamp = 11;
+
+ // The severity of the log entry. The default value is
+ // `LogSeverity.DEFAULT`.
+ google.logging.type.LogSeverity severity = 12;
+
+ // A unique ID for the log entry used for deduplication. If omitted,
+ // the implementation will generate one based on operation_id.
+ string insert_id = 4;
+
+ // A set of user-defined (key, value) data that provides additional
+ // information about the log entry.
+ map<string, string> labels = 13;
+
+ // The log entry payload, which can be one of multiple types.
+ oneof payload {
+ // The log entry payload, represented as a protocol buffer that is
+ // expressed as a JSON object. The only accepted type currently is
+ // [AuditLog][google.cloud.audit.AuditLog].
+ google.protobuf.Any proto_payload = 2;
+
+ // The log entry payload, represented as a Unicode string (UTF-8).
+ string text_payload = 3;
+
+ // The log entry payload, represented as a structure that
+ // is expressed as a JSON object.
+ google.protobuf.Struct struct_payload = 6;
+ }
+}

protos/google/api/servicecontrol/v1/metric_value.proto

@@ -0,0 +1,78 @@
+// Copyright 2017 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.api.servicecontrol.v1;
+
+import "google/api/annotations.proto";
+import "google/api/servicecontrol/v1/distribution.proto";
+import "google/protobuf/timestamp.proto";
+import "google/type/money.proto";
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/api/servicecontrol/v1;servicecontrol";
+option java_multiple_files = true;
+option java_outer_classname = "MetricValueSetProto";
+option java_package = "com.google.api.servicecontrol.v1";
+
+// Represents a single metric value.
+message MetricValue {
+ // The labels describing the metric value.
+ // See comments on
+ // [google.api.servicecontrol.v1.Operation.labels][google.api.servicecontrol.v1.Operation.labels]
+ // for the overriding relationship.
+ map<string, string> labels = 1;
+
+ // The start of the time period over which this metric value's measurement
+ // applies. The time period has different semantics for different metric
+ // types (cumulative, delta, and gauge). See the metric definition
+ // documentation in the service configuration for details.
+ google.protobuf.Timestamp start_time = 2;
+
+ // The end of the time period over which this metric value's measurement
+ // applies.
+ google.protobuf.Timestamp end_time = 3;
+
+ // The value. The type of value used in the request must
+ // agree with the metric definition in the service configuration, otherwise
+ // the MetricValue is rejected.
+ oneof value {
+ // A boolean value.
+ bool bool_value = 4;
+
+ // A signed 64-bit integer value.
+ int64 int64_value = 5;
+
+ // A double precision floating point value.
+ double double_value = 6;
+
+ // A text string value.
+ string string_value = 7;
+
+ // A distribution value.
+ Distribution distribution_value = 8;
+ }
+}
+
+// Represents a set of metric values in the same metric.
+// Each metric value in the set should have a unique combination of start time,
+// end time, and label values.
+message MetricValueSet {
+ // The metric name defined in the service configuration.
+ string metric_name = 1;
+
+ // The values in this metric.
+ repeated MetricValue metric_values = 2;
+}

protos/google/api/servicecontrol/v1/operation.proto

@@ -0,0 +1,113 @@
+// Copyright 2017 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.api.servicecontrol.v1;
+
+import "google/api/annotations.proto";
+import "google/api/servicecontrol/v1/log_entry.proto";
+import "google/api/servicecontrol/v1/metric_value.proto";
+import "google/protobuf/timestamp.proto";
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/api/servicecontrol/v1;servicecontrol";
+option java_multiple_files = true;
+option java_outer_classname = "OperationProto";
+option java_package = "com.google.api.servicecontrol.v1";
+
+// Represents information regarding an operation.
+message Operation {
+ // Defines the importance of the data contained in the operation.
+ enum Importance {
+ // The API implementation may cache and aggregate the data.
+ // The data may be lost when rare and unexpected system failures occur.
+ LOW = 0;
+
+ // The API implementation doesn't cache and aggregate the data.
+ // If the method returns successfully, it's guaranteed that the data has
+ // been persisted in durable storage.
+ HIGH = 1;
+ }
+
+ // Identity of the operation. This must be unique within the scope of the
+ // service that generated the operation. If the service calls
+ // Check() and Report() on the same operation, the two calls should carry
+ // the same id.
+ //
+ // UUID version 4 is recommended, though not required.
+ // In scenarios where an operation is computed from existing information
+ // and an idempotent id is desirable for deduplication purpose, UUID version 5
+ // is recommended. See RFC 4122 for details.
+ string operation_id = 1;
+
+ // Fully qualified name of the operation. Reserved for future use.
+ string operation_name = 2;
+
+ // Identity of the consumer who is using the service.
+ // This field should be filled in for the operations initiated by a
+ // consumer, but not for service-initiated operations that are
+ // not related to a specific consumer.
+ //
+ // This can be in one of the following formats:
+ // project:<project_id>,
+ // project_number:<project_number>,
+ // api_key:<api_key>.
+ string consumer_id = 3;
+
+ // Required. Start time of the operation.
+ google.protobuf.Timestamp start_time = 4;
+
+ // End time of the operation.
+ // Required when the operation is used in
+ // [ServiceController.Report][google.api.servicecontrol.v1.ServiceController.Report],
+ // but optional when the operation is used in
+ // [ServiceController.Check][google.api.servicecontrol.v1.ServiceController.Check].
+ google.protobuf.Timestamp end_time = 5;
+
+ // Labels describing the operation. Only the following labels are allowed:
+ //
+ // - Labels describing monitored resources as defined in
+ // the service configuration.
+ // - Default labels of metric values. When specified, labels defined in the
+ // metric value override these default.
+ // - The following labels defined by Google Cloud Platform:
+ // - `cloud.googleapis.com/location` describing the location where the
+ // operation happened,
+ // - `servicecontrol.googleapis.com/user_agent` describing the user agent
+ // of the API request,
+ // - `servicecontrol.googleapis.com/service_agent` describing the service
+ // used to handle the API request (e.g. ESP),
+ // - `servicecontrol.googleapis.com/platform` describing the platform
+ // where the API is served (e.g. GAE, GCE, GKE).
+ map<string, string> labels = 6;
+
+ // Represents information about this operation. Each MetricValueSet
+ // corresponds to a metric defined in the service configuration.
+ // The data type used in the MetricValueSet must agree with
+ // the data type specified in the metric definition.
+ //
+ // Within a single operation, it is not allowed to have more than one
+ // MetricValue instances that have the same metric names and identical
+ // label value combinations. If a request has such duplicated MetricValue
+ // instances, the entire request is rejected with
+ // an invalid argument error.
+ repeated MetricValueSet metric_value_sets = 7;
+
+ // Represents information to be logged.
+ repeated LogEntry log_entries = 8;
+
+ // DO NOT USE. This is an experimental field.
+ Importance importance = 11;
+}

protos/google/api/servicecontrol/v1/quota_controller.proto

@@ -0,0 +1,206 @@
+// Copyright 2017 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.api.servicecontrol.v1;
+
+import "google/api/annotations.proto";
+import "google/api/servicecontrol/v1/metric_value.proto";
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/api/servicecontrol/v1;servicecontrol";
+option java_multiple_files = true;
+option java_outer_classname = "QuotaControllerProto";
+option java_package = "com.google.api.servicecontrol.v1";
+
+// [Google Quota Control API](/service-control/overview)
+//
+// Allows clients to allocate and release quota against a [managed
+// service](https://cloud.google.com/service-management/reference/rpc/google.api/servicemanagement.v1#google.api.servicemanagement.v1.ManagedService).
+service QuotaController {
+ // Attempts to allocate quota for the specified consumer. It should be called
+ // before the operation is executed.
+ //
+ // This method requires the `servicemanagement.services.quota`
+ // permission on the specified service. For more information, see
+ // [Cloud IAM](https://cloud.google.com/iam).
+ //
+ // **NOTE:** The client **must** fail-open on server errors `INTERNAL`,
+ // `UNKNOWN`, `DEADLINE_EXCEEDED`, and `UNAVAILABLE`. To ensure system
+ // reliability, the server may inject these errors to prohibit any hard
+ // dependency on the quota functionality.
+ rpc AllocateQuota(AllocateQuotaRequest) returns (AllocateQuotaResponse) {
+ option (google.api.http) = {
+ post: "/v1/services/{service_name}:allocateQuota"
+ body: "*"
+ };
+ }
+}
+
+// Request message for the AllocateQuota method.
+message AllocateQuotaRequest {
+ // Name of the service as specified in the service configuration. For example,
+ // `"pubsub.googleapis.com"`.
+ //
+ // See [google.api.Service][google.api.Service] for the definition of a
+ // service name.
+ string service_name = 1;
+
+ // Operation that describes the quota allocation.
+ QuotaOperation allocate_operation = 2;
+
+ // Specifies which version of service configuration should be used to process
+ // the request. If unspecified or no matching version can be found, the latest
+ // one will be used.
+ string service_config_id = 4;
+}
+
+// Represents information regarding a quota operation.
+message QuotaOperation {
+ // Supported quota modes.
+ enum QuotaMode {
+ // Guard against implicit default. Must not be used.
+ UNSPECIFIED = 0;
+
+ // For AllocateQuota request, allocates quota for the amount specified in
+ // the service configuration or specified using the quota metrics. If the
+ // amount is higher than the available quota, allocation error will be
+ // returned and no quota will be allocated.
+ NORMAL = 1;
+
+ // The operation allocates quota for the amount specified in the service
+ // configuration or specified using the quota metrics. If the amount is
+ // higher than the available quota, request does not fail but all available
+ // quota will be allocated.
+ BEST_EFFORT = 2;
+
+ // For AllocateQuota request, only checks if there is enough quota
+ // available and does not change the available quota. No lock is placed on
+ // the available quota either.
+ CHECK_ONLY = 3;
+ }
+
+ // Identity of the operation. This is expected to be unique within the scope
+ // of the service that generated the operation, and guarantees idempotency in
+ // case of retries.
+ //
+ // UUID version 4 is recommended, though not required. In scenarios where an
+ // operation is computed from existing information and an idempotent id is
+ // desirable for deduplication purpose, UUID version 5 is recommended. See
+ // RFC 4122 for details.
+ string operation_id = 1;
+
+ // Fully qualified name of the API method for which this quota operation is
+ // requested. This name is used for matching quota rules or metric rules and
+ // billing status rules defined in service configuration. This field is not
+ // required if the quota operation is performed on non-API resources.
+ //
+ // Example of an RPC method name:
+ // google.example.library.v1.LibraryService.CreateShelf
+ string method_name = 2;
+
+ // Identity of the consumer for whom this quota operation is being performed.
+ //
+ // This can be in one of the following formats:
+ // project:<project_id>,
+ // project_number:<project_number>,
+ // api_key:<api_key>.
+ string consumer_id = 3;
+
+ // Labels describing the operation.
+ map<string, string> labels = 4;
+
+ // Represents information about this operation. Each MetricValueSet
+ // corresponds to a metric defined in the service configuration.
+ // The data type used in the MetricValueSet must agree with
+ // the data type specified in the metric definition.
+ //
+ // Within a single operation, it is not allowed to have more than one
+ // MetricValue instances that have the same metric names and identical
+ // label value combinations. If a request has such duplicated MetricValue
+ // instances, the entire request is rejected with
+ // an invalid argument error.
+ repeated MetricValueSet quota_metrics = 5;
+
+ // Quota mode for this operation.
+ QuotaMode quota_mode = 6;
+}
+
+// Response message for the AllocateQuota method.
+message AllocateQuotaResponse {
+ // The same operation_id value used in the AllocateQuotaRequest. Used for
+ // logging and diagnostics purposes.
+ string operation_id = 1;
+
+ // Indicates the decision of the allocate.
+ repeated QuotaError allocate_errors = 2;
+
+ // Quota metrics to indicate the result of allocation. Depending on the
+ // request, one or more of the following metrics will be included:
+ //
+ // 1. Per quota group or per quota metric incremental usage will be specified
+ // using the following delta metric :
+ // "serviceruntime.googleapis.com/api/consumer/quota_used_count"
+ //
+ // 2. The quota limit reached condition will be specified using the following
+ // boolean metric :
+ // "serviceruntime.googleapis.com/quota/exceeded"
+ repeated MetricValueSet quota_metrics = 3;
+
+ // ID of the actual config used to process the request.
+ string service_config_id = 4;
+}
+
+// Represents error information for
+// [QuotaOperation][google.api.servicecontrol.v1.QuotaOperation].
+message QuotaError {
+ // Error codes related to project config validations are deprecated since the
+ // quota controller methods do not perform these validations. Instead services
+ // have to call the Check method, without quota_properties field, to perform
+ // these validations before calling the quota controller methods. These
+ // methods check only for project deletion to be wipe out compliant.
+ enum Code {
+ // This is never used.
+ UNSPECIFIED = 0;
+
+ // Quota allocation failed.
+ // Same as [google.rpc.Code.RESOURCE_EXHAUSTED][].
+ RESOURCE_EXHAUSTED = 8;
+
+ // Consumer cannot access the service because the service requires active
+ // billing.
+ BILLING_NOT_ACTIVE = 107;
+
+ // Consumer's project has been marked as deleted (soft deletion).
+ PROJECT_DELETED = 108;
+
+ // Specified API key is invalid.
+ API_KEY_INVALID = 105;
+
+ // Specified API Key has expired.
+ API_KEY_EXPIRED = 112;
+ }
+
+ // Error code.
+ Code code = 1;
+
+ // Subject to whom this error applies. See the specific enum for more details
+ // on this field. For example, "clientip:<ip address of client>" or
+ // "project:<Google developer project id>".
+ string subject = 2;
+
+ // Free-form text that provides details on the cause of the error.
+ string description = 3;
+}

protos/google/api/servicecontrol/v1/service_controller.proto

@@ -0,0 +1,198 @@
+// Copyright 2017 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.api.servicecontrol.v1;
+
+import "google/api/annotations.proto";
+import "google/api/servicecontrol/v1/check_error.proto";
+import "google/api/servicecontrol/v1/operation.proto";
+import "google/rpc/status.proto";
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/api/servicecontrol/v1;servicecontrol";
+option java_multiple_files = true;
+option java_outer_classname = "ServiceControllerProto";
+option java_package = "com.google.api.servicecontrol.v1";
+option objc_class_prefix = "GASC";
+
+// [Google Service Control API](/service-control/overview)
+//
+// Lets clients check and report operations against a [managed
+// service](https://cloud.google.com/service-management/reference/rpc/google.api/servicemanagement.v1#google.api.servicemanagement.v1.ManagedService).
+service ServiceController {
+ // Checks an operation with Google Service Control to decide whether
+ // the given operation should proceed. It should be called before the
+ // operation is executed.
+ //
+ // If feasible, the client should cache the check results and reuse them for
+ // 60 seconds. In case of server errors, the client can rely on the cached
+ // results for longer time.
+ //
+ // NOTE: the [CheckRequest][google.api.servicecontrol.v1.CheckRequest] has the
+ // size limit of 64KB.
+ //
+ // This method requires the `servicemanagement.services.check` permission
+ // on the specified service. For more information, see
+ // [Google Cloud IAM](https://cloud.google.com/iam).
+ rpc Check(CheckRequest) returns (CheckResponse) {
+ option (google.api.http) = {
+ post: "/v1/services/{service_name}:check"
+ body: "*"
+ };
+ }
+
+ // Reports operation results to Google Service Control, such as logs and
+ // metrics. It should be called after an operation is completed.
+ //
+ // If feasible, the client should aggregate reporting data for up to 5
+ // seconds to reduce API traffic. Limiting aggregation to 5 seconds is to
+ // reduce data loss during client crashes. Clients should carefully choose
+ // the aggregation time window to avoid data loss risk more than 0.01%
+ // for business and compliance reasons.
+ //
+ // NOTE: the [ReportRequest][google.api.servicecontrol.v1.ReportRequest] has
+ // the size limit of 1MB.
+ //
+ // This method requires the `servicemanagement.services.report` permission
+ // on the specified service. For more information, see
+ // [Google Cloud IAM](https://cloud.google.com/iam).
+ rpc Report(ReportRequest) returns (ReportResponse) {
+ option (google.api.http) = {
+ post: "/v1/services/{service_name}:report"
+ body: "*"
+ };
+ }
+}
+
+// Request message for the Check method.
+message CheckRequest {
+ // The service name as specified in its service configuration. For example,
+ // `"pubsub.googleapis.com"`.
+ //
+ // See
+ // [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service)
+ // for the definition of a service name.
+ string service_name = 1;
+
+ // The operation to be checked.
+ Operation operation = 2;
+
+ // Specifies which version of service configuration should be used to process
+ // the request.
+ //
+ // If unspecified or no matching version can be found, the
+ // latest one will be used.
+ string service_config_id = 4;
+}
+
+// Response message for the Check method.
+message CheckResponse {
+ message CheckInfo {
+ // Consumer info of this check.
+ ConsumerInfo consumer_info = 2;
+ }
+
+ // `ConsumerInfo` provides information about the consumer project.
+ message ConsumerInfo {
+ // The Google cloud project number, e.g. 1234567890. A value of 0 indicates
+ // no project number is found.
+ int64 project_number = 1;
+ }
+
+ // The same operation_id value used in the
+ // [CheckRequest][google.api.servicecontrol.v1.CheckRequest]. Used for logging
+ // and diagnostics purposes.
+ string operation_id = 1;
+
+ // Indicate the decision of the check.
+ //
+ // If no check errors are present, the service should process the operation.
+ // Otherwise the service should use the list of errors to determine the
+ // appropriate action.
+ repeated CheckError check_errors = 2;
+
+ // The actual config id used to process the request.
+ string service_config_id = 5;
+
+ // Feedback data returned from the server during processing a Check request.
+ CheckInfo check_info = 6;
+}
+
+// Request message for the Report method.
+message ReportRequest {
+ // The service name as specified in its service configuration. For example,
+ // `"pubsub.googleapis.com"`.
+ //
+ // See
+ // [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service)
+ // for the definition of a service name.
+ string service_name = 1;
+
+ // Operations to be reported.
+ //
+ // Typically the service should report one operation per request.
+ // Putting multiple operations into a single request is allowed, but should
+ // be used only when multiple operations are natually available at the time
+ // of the report.
+ //
+ // If multiple operations are in a single request, the total request size
+ // should be no larger than 1MB. See
+ // [ReportResponse.report_errors][google.api.servicecontrol.v1.ReportResponse.report_errors]
+ // for partial failure behavior.
+ repeated Operation operations = 2;
+
+ // Specifies which version of service config should be used to process the
+ // request.
+ //
+ // If unspecified or no matching version can be found, the
+ // latest one will be used.
+ string service_config_id = 3;
+}
+
+// Response message for the Report method.
+message ReportResponse {
+ // Represents the processing error of one
+ // [Operation][google.api.servicecontrol.v1.Operation] in the request.
+ message ReportError {
+ // The
+ // [Operation.operation_id][google.api.servicecontrol.v1.Operation.operation_id]
+ // value from the request.
+ string operation_id = 1;
+
+ // Details of the error when processing the
+ // [Operation][google.api.servicecontrol.v1.Operation].
+ google.rpc.Status status = 2;
+ }
+
+ // Partial failures, one for each `Operation` in the request that failed
+ // processing. There are three possible combinations of the RPC status:
+ //
+ // 1. The combination of a successful RPC status and an empty `report_errors`
+ // list indicates a complete success where all `Operations` in the
+ // request are processed successfully.
+ // 2. The combination of a successful RPC status and a non-empty
+ // `report_errors` list indicates a partial success where some
+ // `Operations` in the request succeeded. Each
+ // `Operation` that failed processing has a corresponding item
+ // in this list.
+ // 3. A failed RPC status indicates a general non-deterministic failure.
+ // When this happens, it's impossible to know which of the
+ // 'Operations' in the request succeeded or failed.
+ repeated ReportError report_errors = 1;
+
+ // The actual config id used to process the request.
+ string service_config_id = 2;
+}

protos/google/api/servicemanagement/v1/resources.proto

@@ -0,0 +1,299 @@
+// Copyright 2018 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.api.servicemanagement.v1;
+
+import "google/api/annotations.proto";
+import "google/api/config_change.proto";
+import "google/api/metric.proto";
+import "google/api/service.proto";
+import "google/longrunning/operations.proto";
+import "google/protobuf/any.proto";
+import "google/protobuf/field_mask.proto";
+import "google/protobuf/struct.proto";
+import "google/protobuf/timestamp.proto";
+import "google/rpc/status.proto";
+
+option csharp_namespace = "Google.Cloud.ServiceManagement.V1";
+option go_package = "google.golang.org/genproto/googleapis/api/servicemanagement/v1;servicemanagement";
+option java_multiple_files = true;
+option java_outer_classname = "ResourcesProto";
+option java_package = "com.google.api.servicemanagement.v1";
+option objc_class_prefix = "GASM";
+option php_namespace = "Google\\Cloud\\ServiceManagement\\V1";
+
+// The full representation of a Service that is managed by
+// Google Service Management.
+message ManagedService {
+ // The name of the service. See the [overview](/service-management/overview)
+ // for naming requirements.
+ string service_name = 2;
+
+ // ID of the project that produces and owns this service.
+ string producer_project_id = 3;
+}
+
+// The metadata associated with a long running operation resource.
+message OperationMetadata {
+ // Represents the status of one operation step.
+ message Step {
+ // The short description of the step.
+ string description = 2;
+
+ // The status code.
+ Status status = 4;
+ }
+
+ // Code describes the status of the operation (or one of its steps).
+ enum Status {
+ // Unspecifed code.
+ STATUS_UNSPECIFIED = 0;
+
+ // The operation or step has completed without errors.
+ DONE = 1;
+
+ // The operation or step has not started yet.
+ NOT_STARTED = 2;
+
+ // The operation or step is in progress.
+ IN_PROGRESS = 3;
+
+ // The operation or step has completed with errors. If the operation is
+ // rollbackable, the rollback completed with errors too.
+ FAILED = 4;
+
+ // The operation or step has completed with cancellation.
+ CANCELLED = 5;
+ }
+
+ // The full name of the resources that this operation is directly
+ // associated with.
+ repeated string resource_names = 1;
+
+ // Detailed status information for each step. The order is undetermined.
+ repeated Step steps = 2;
+
+ // Percentage of completion of this operation, ranging from 0 to 100.
+ int32 progress_percentage = 3;
+
+ // The start time of the operation.
+ google.protobuf.Timestamp start_time = 4;
+}
+
+// Represents a diagnostic message (error or warning)
+message Diagnostic {
+ // The kind of diagnostic information possible.
+ enum Kind {
+ // Warnings and errors
+ WARNING = 0;
+
+ // Only errors
+ ERROR = 1;
+ }
+
+ // File name and line number of the error or warning.
+ string location = 1;
+
+ // The kind of diagnostic information provided.
+ Kind kind = 2;
+
+ // Message describing the error or warning.
+ string message = 3;
+}
+
+// Represents a source file which is used to generate the service configuration
+// defined by `google.api.Service`.
+message ConfigSource {
+ // A unique ID for a specific instance of this message, typically assigned
+ // by the client for tracking purpose. If empty, the server may choose to
+ // generate one instead.
+ string id = 5;
+
+ // Set of source configuration files that are used to generate a service
+ // configuration (`google.api.Service`).
+ repeated ConfigFile files = 2;
+}
+
+// Generic specification of a source configuration file
+message ConfigFile {
+ enum FileType {
+ // Unknown file type.
+ FILE_TYPE_UNSPECIFIED = 0;
+
+ // YAML-specification of service.
+ SERVICE_CONFIG_YAML = 1;
+
+ // OpenAPI specification, serialized in JSON.
+ OPEN_API_JSON = 2;
+
+ // OpenAPI specification, serialized in YAML.
+ OPEN_API_YAML = 3;
+
+ // FileDescriptorSet, generated by protoc.
+ //
+ // To generate, use protoc with imports and source info included.
+ // For an example test.proto file, the following command would put the value
+ // in a new file named out.pb.
+ //
+ // $protoc --include_imports --include_source_info test.proto -o out.pb
+ FILE_DESCRIPTOR_SET_PROTO = 4;
+
+ // Uncompiled Proto file. Used for storage and display purposes only,
+ // currently server-side compilation is not supported. Should match the
+ // inputs to 'protoc' command used to generated FILE_DESCRIPTOR_SET_PROTO. A
+ // file of this type can only be included if at least one file of type
+ // FILE_DESCRIPTOR_SET_PROTO is included.
+ PROTO_FILE = 6;
+ }
+
+ // The file name of the configuration file (full or relative path).
+ string file_path = 1;
+
+ // The bytes that constitute the file.
+ bytes file_contents = 3;
+
+ // The type of configuration file this represents.
+ FileType file_type = 4;
+}
+
+// Represents a service configuration with its name and id.
+message ConfigRef {
+ // Resource name of a service config. It must have the following
+ // format: "services/{service name}/configs/{config id}".
+ string name = 1;
+}
+
+// Change report associated with a particular service configuration.
+//
+// It contains a list of ConfigChanges based on the comparison between
+// two service configurations.
+message ChangeReport {
+ // List of changes between two service configurations.
+ // The changes will be alphabetically sorted based on the identifier
+ // of each change.
+ // A ConfigChange identifier is a dot separated path to the configuration.
+ // Example: visibility.rules[selector='LibraryService.CreateBook'].restriction
+ repeated google.api.ConfigChange config_changes = 1;
+}
+
+// A rollout resource that defines how service configuration versions are pushed
+// to control plane systems. Typically, you create a new version of the
+// service config, and then create a Rollout to push the service config.
+message Rollout {
+ // Strategy that specifies how clients of Google Service Controller want to
+ // send traffic to use different config versions. This is generally
+ // used by API proxy to split traffic based on your configured precentage for
+ // each config version.
+ //
+ // One example of how to gradually rollout a new service configuration using
+ // this
+ // strategy:
+ // Day 1
+ //
+ // Rollout {
+ // id: "example.googleapis.com/rollout_20160206"
+ // traffic_percent_strategy {
+ // percentages: {
+ // "example.googleapis.com/20160201": 70.00
+ // "example.googleapis.com/20160206": 30.00
+ // }
+ // }
+ // }
+ //
+ // Day 2
+ //
+ // Rollout {
+ // id: "example.googleapis.com/rollout_20160207"
+ // traffic_percent_strategy: {
+ // percentages: {
+ // "example.googleapis.com/20160206": 100.00
+ // }
+ // }
+ // }
+ message TrafficPercentStrategy {
+ // Maps service configuration IDs to their corresponding traffic percentage.
+ // Key is the service configuration ID, Value is the traffic percentage
+ // which must be greater than 0.0 and the sum must equal to 100.0.
+ map<string, double> percentages = 1;
+ }
+
+ // Strategy used to delete a service. This strategy is a placeholder only
+ // used by the system generated rollout to delete a service.
+ message DeleteServiceStrategy {}
+
+ // Status of a Rollout.
+ enum RolloutStatus {
+ // No status specified.
+ ROLLOUT_STATUS_UNSPECIFIED = 0;
+
+ // The Rollout is in progress.
+ IN_PROGRESS = 1;
+
+ // The Rollout has completed successfully.
+ SUCCESS = 2;
+
+ // The Rollout has been cancelled. This can happen if you have overlapping
+ // Rollout pushes, and the previous ones will be cancelled.
+ CANCELLED = 3;
+
+ // The Rollout has failed and the rollback attempt has failed too.
+ FAILED = 4;
+
+ // The Rollout has not started yet and is pending for execution.
+ PENDING = 5;
+
+ // The Rollout has failed and rolled back to the previous successful
+ // Rollout.
+ FAILED_ROLLED_BACK = 6;
+ }
+
+ // Optional unique identifier of this Rollout. Only lower case letters, digits
+ // and '-' are allowed.
+ //
+ // If not specified by client, the server will generate one. The generated id
+ // will have the form of <date><revision number>, where "date" is the create
+ // date in ISO 8601 format. "revision number" is a monotonically increasing
+ // positive number that is reset every day for each service.
+ // An example of the generated rollout_id is '2016-02-16r1'
+ string rollout_id = 1;
+
+ // Creation time of the rollout. Readonly.
+ google.protobuf.Timestamp create_time = 2;
+
+ // The user who created the Rollout. Readonly.
+ string created_by = 3;
+
+ // The status of this rollout. Readonly. In case of a failed rollout,
+ // the system will automatically rollback to the current Rollout
+ // version. Readonly.
+ RolloutStatus status = 4;
+
+ // Strategy that defines which versions of service configurations should be
+ // pushed
+ // and how they should be used at runtime.
+ oneof strategy {
+ // Google Service Control selects service configurations based on
+ // traffic percentage.
+ TrafficPercentStrategy traffic_percent_strategy = 5;
+
+ // The strategy associated with a rollout to delete a `ManagedService`.
+ // Readonly.
+ DeleteServiceStrategy delete_service_strategy = 200;
+ }
+
+ // The name of the service associated with this Rollout.
+ string service_name = 8;
+}

protos/google/api/servicemanagement/v1/servicemanager.proto

@@ -0,0 +1,503 @@
+// Copyright 2018 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.api.servicemanagement.v1;
+
+import "google/api/annotations.proto";
+import "google/api/service.proto";
+import "google/api/servicemanagement/v1/resources.proto";
+import "google/longrunning/operations.proto";
+import "google/protobuf/any.proto";
+import "google/protobuf/field_mask.proto";
+import "google/protobuf/struct.proto";
+import "google/rpc/status.proto";
+
+option csharp_namespace = "Google.Cloud.ServiceManagement.V1";
+option go_package = "google.golang.org/genproto/googleapis/api/servicemanagement/v1;servicemanagement";
+option java_multiple_files = true;
+option java_outer_classname = "ServiceManagerProto";
+option java_package = "com.google.api.servicemanagement.v1";
+option objc_class_prefix = "GASM";
+option php_namespace = "Google\\Cloud\\ServiceManagement\\V1";
+
+// [Google Service Management API](/service-management/overview)
+service ServiceManager {
+ // Lists managed services.
+ //
+ // Returns all public services. For authenticated users, also returns all
+ // services the calling user has "servicemanagement.services.get" permission
+ // for.
+ //
+ // **BETA:** If the caller specifies the `consumer_id`, it returns only the
+ // services enabled on the consumer. The `consumer_id` must have the format
+ // of "project:{PROJECT-ID}".
+ rpc ListServices(ListServicesRequest) returns (ListServicesResponse) {
+ option (google.api.http) = {
+ get: "/v1/services"
+ };
+ }
+
+ // Gets a managed service. Authentication is required unless the service is
+ // public.
+ rpc GetService(GetServiceRequest) returns (ManagedService) {
+ option (google.api.http) = {
+ get: "/v1/services/{service_name}"
+ };
+ }
+
+ // Creates a new managed service.
+ // Please note one producer project can own no more than 20 services.
+ //
+ // Operation<response: ManagedService>
+ rpc CreateService(CreateServiceRequest)
+ returns (google.longrunning.Operation) {
+ option (google.api.http) = {
+ post: "/v1/services"
+ body: "service"
+ };
+ }
+
+ // Deletes a managed service. This method will change the service to the
+ // `Soft-Delete` state for 30 days. Within this period, service producers may
+ // call
+ // [UndeleteService][google.api.servicemanagement.v1.ServiceManager.UndeleteService]
+ // to restore the service. After 30 days, the service will be permanently
+ // deleted.
+ //
+ // Operation<response: google.protobuf.Empty>
+ rpc DeleteService(DeleteServiceRequest)
+ returns (google.longrunning.Operation) {
+ option (google.api.http) = {
+ delete: "/v1/services/{service_name}"
+ };
+ }
+
+ // Revives a previously deleted managed service. The method restores the
+ // service using the configuration at the time the service was deleted.
+ // The target service must exist and must have been deleted within the
+ // last 30 days.
+ //
+ // Operation<response: UndeleteServiceResponse>
+ rpc UndeleteService(UndeleteServiceRequest)
+ returns (google.longrunning.Operation) {
+ option (google.api.http) = {
+ post: "/v1/services/{service_name}:undelete"
+ };
+ }
+
+ // Lists the history of the service configuration for a managed service,
+ // from the newest to the oldest.
+ rpc ListServiceConfigs(ListServiceConfigsRequest)
+ returns (ListServiceConfigsResponse) {
+ option (google.api.http) = {
+ get: "/v1/services/{service_name}/configs"
+ };
+ }
+
+ // Gets a service configuration (version) for a managed service.
+ rpc GetServiceConfig(GetServiceConfigRequest) returns (google.api.Service) {
+ option (google.api.http) = {
+ get: "/v1/services/{service_name}/configs/{config_id}"
+ additional_bindings { get: "/v1/services/{service_name}/config" }
+ };
+ }
+
+ // Creates a new service configuration (version) for a managed service.
+ // This method only stores the service configuration. To roll out the service
+ // configuration to backend systems please call
+ // [CreateServiceRollout][google.api.servicemanagement.v1.ServiceManager.CreateServiceRollout].
+ //
+ // Only the 100 most recent service configurations and ones referenced by
+ // existing rollouts are kept for each service. The rest will be deleted
+ // eventually.
+ rpc CreateServiceConfig(CreateServiceConfigRequest)
+ returns (google.api.Service) {
+ option (google.api.http) = {
+ post: "/v1/services/{service_name}/configs"
+ body: "service_config"
+ };
+ }
+
+ // Creates a new service configuration (version) for a managed service based
+ // on
+ // user-supplied configuration source files (for example: OpenAPI
+ // Specification). This method stores the source configurations as well as the
+ // generated service configuration. To rollout the service configuration to
+ // other services,
+ // please call
+ // [CreateServiceRollout][google.api.servicemanagement.v1.ServiceManager.CreateServiceRollout].
+ //
+ // Only the 100 most recent configuration sources and ones referenced by
+ // existing service configurtions are kept for each service. The rest will be
+ // deleted eventually.
+ //
+ // Operation<response: SubmitConfigSourceResponse>
+ rpc SubmitConfigSource(SubmitConfigSourceRequest)
+ returns (google.longrunning.Operation) {
+ option (google.api.http) = {
+ post: "/v1/services/{service_name}/configs:submit"
+ body: "*"
+ };
+ }
+
+ // Lists the history of the service configuration rollouts for a managed
+ // service, from the newest to the oldest.
+ rpc ListServiceRollouts(ListServiceRolloutsRequest)
+ returns (ListServiceRolloutsResponse) {
+ option (google.api.http) = {
+ get: "/v1/services/{service_name}/rollouts"
+ };
+ }
+
+ // Gets a service configuration
+ // [rollout][google.api.servicemanagement.v1.Rollout].
+ rpc GetServiceRollout(GetServiceRolloutRequest) returns (Rollout) {
+ option (google.api.http) = {
+ get: "/v1/services/{service_name}/rollouts/{rollout_id}"
+ };
+ }
+
+ // Creates a new service configuration rollout. Based on rollout, the
+ // Google Service Management will roll out the service configurations to
+ // different backend services. For example, the logging configuration will be
+ // pushed to Google Cloud Logging.
+ //
+ // Please note that any previous pending and running Rollouts and associated
+ // Operations will be automatically cancelled so that the latest Rollout will
+ // not be blocked by previous Rollouts.
+ //
+ // Only the 100 most recent (in any state) and the last 10 successful (if not
+ // already part of the set of 100 most recent) rollouts are kept for each
+ // service. The rest will be deleted eventually.
+ //
+ // Operation<response: Rollout>
+ rpc CreateServiceRollout(CreateServiceRolloutRequest)
+ returns (google.longrunning.Operation) {
+ option (google.api.http) = {
+ post: "/v1/services/{service_name}/rollouts"
+ body: "rollout"
+ };
+ }
+
+ // Generates and returns a report (errors, warnings and changes from
+ // existing configurations) associated with
+ // GenerateConfigReportRequest.new_value
+ //
+ // If GenerateConfigReportRequest.old_value is specified,
+ // GenerateConfigReportRequest will contain a single ChangeReport based on the
+ // comparison between GenerateConfigReportRequest.new_value and
+ // GenerateConfigReportRequest.old_value.
+ // If GenerateConfigReportRequest.old_value is not specified, this method
+ // will compare GenerateConfigReportRequest.new_value with the last pushed
+ // service configuration.
+ rpc GenerateConfigReport(GenerateConfigReportRequest)
+ returns (GenerateConfigReportResponse) {
+ option (google.api.http) = {
+ post: "/v1/services:generateConfigReport"
+ body: "*"
+ };
+ }
+
+ // Enables a [service][google.api.servicemanagement.v1.ManagedService] for a
+ // project, so it can be used for the project. See [Cloud Auth
+ // Guide](https://cloud.google.com/docs/authentication) for more information.
+ //
+ // Operation<response: EnableServiceResponse>
+ rpc EnableService(EnableServiceRequest)
+ returns (google.longrunning.Operation) {
+ option (google.api.http) = {
+ post: "/v1/services/{service_name}:enable"
+ body: "*"
+ };
+ }
+
+ // Disables a [service][google.api.servicemanagement.v1.ManagedService] for a
+ // project, so it can no longer be be used for the project. It prevents
+ // accidental usage that may cause unexpected billing charges or security
+ // leaks.
+ //
+ // Operation<response: DisableServiceResponse>
+ rpc DisableService(DisableServiceRequest)
+ returns (google.longrunning.Operation) {
+ option (google.api.http) = {
+ post: "/v1/services/{service_name}:disable"
+ body: "*"
+ };
+ }
+}
+
+// Request message for `ListServices` method.
+message ListServicesRequest {
+ // Include services produced by the specified project.
+ string producer_project_id = 1;
+
+ // Requested size of the next page of data.
+ int32 page_size = 5;
+
+ // Token identifying which result to start with; returned by a previous list
+ // call.
+ string page_token = 6;
+
+ // Include services consumed by the specified consumer.
+ //
+ // The Google Service Management implementation accepts the following
+ // forms:
+ // - project:<project_id>
+ string consumer_id = 7;
+}
+
+// Response message for `ListServices` method.
+message ListServicesResponse {
+ // The returned services will only have the name field set.
+ repeated ManagedService services = 1;
+
+ // Token that can be passed to `ListServices` to resume a paginated query.
+ string next_page_token = 2;
+}
+
+// Request message for `GetService` method.
+message GetServiceRequest {
+ // The name of the service. See the `ServiceManager` overview for naming
+ // requirements. For example: `example.googleapis.com`.
+ string service_name = 1;
+}
+
+// Request message for CreateService method.
+message CreateServiceRequest {
+ // Initial values for the service resource.
+ ManagedService service = 1;
+}
+
+// Request message for DeleteService method.
+message DeleteServiceRequest {
+ // The name of the service. See the [overview](/service-management/overview)
+ // for naming requirements. For example: `example.googleapis.com`.
+ string service_name = 1;
+}
+
+// Request message for UndeleteService method.
+message UndeleteServiceRequest {
+ // The name of the service. See the [overview](/service-management/overview)
+ // for naming requirements. For example: `example.googleapis.com`.
+ string service_name = 1;
+}
+
+// Response message for UndeleteService method.
+message UndeleteServiceResponse {
+ // Revived service resource.
+ ManagedService service = 1;
+}
+
+// Request message for GetServiceConfig method.
+message GetServiceConfigRequest {
+ enum ConfigView {
+ // Server response includes all fields except SourceInfo.
+ BASIC = 0;
+
+ // Server response includes all fields including SourceInfo.
+ // SourceFiles are of type 'google.api.servicemanagement.v1.ConfigFile'
+ // and are only available for configs created using the
+ // SubmitConfigSource method.
+ FULL = 1;
+ }
+
+ // The name of the service. See the [overview](/service-management/overview)
+ // for naming requirements. For example: `example.googleapis.com`.
+ string service_name = 1;
+
+ // The id of the service configuration resource.
+ string config_id = 2;
+
+ // Specifies which parts of the Service Config should be returned in the
+ // response.
+ ConfigView view = 3;
+}
+
+// Request message for ListServiceConfigs method.
+message ListServiceConfigsRequest {
+ // The name of the service. See the [overview](/service-management/overview)
+ // for naming requirements. For example: `example.googleapis.com`.
+ string service_name = 1;
+
+ // The token of the page to retrieve.
+ string page_token = 2;
+
+ // The max number of items to include in the response list.
+ int32 page_size = 3;
+}
+
+// Response message for ListServiceConfigs method.
+message ListServiceConfigsResponse {
+ // The list of service configuration resources.
+ repeated google.api.Service service_configs = 1;
+
+ // The token of the next page of results.
+ string next_page_token = 2;
+}
+
+// Request message for CreateServiceConfig method.
+message CreateServiceConfigRequest {
+ // The name of the service. See the [overview](/service-management/overview)
+ // for naming requirements. For example: `example.googleapis.com`.
+ string service_name = 1;
+
+ // The service configuration resource.
+ google.api.Service service_config = 2;
+}
+
+// Request message for SubmitConfigSource method.
+message SubmitConfigSourceRequest {
+ // The name of the service. See the [overview](/service-management/overview)
+ // for naming requirements. For example: `example.googleapis.com`.
+ string service_name = 1;
+
+ // The source configuration for the service.
+ ConfigSource config_source = 2;
+
+ // Optional. If set, this will result in the generation of a
+ // `google.api.Service` configuration based on the `ConfigSource` provided,
+ // but the generated config and the sources will NOT be persisted.
+ bool validate_only = 3;
+}
+
+// Response message for SubmitConfigSource method.
+message SubmitConfigSourceResponse {
+ // The generated service configuration.
+ google.api.Service service_config = 1;
+}
+
+// Request message for 'CreateServiceRollout'
+message CreateServiceRolloutRequest {
+ // The name of the service. See the [overview](/service-management/overview)
+ // for naming requirements. For example: `example.googleapis.com`.
+ string service_name = 1;
+
+ // The rollout resource. The `service_name` field is output only.
+ Rollout rollout = 2;
+}
+
+// Request message for 'ListServiceRollouts'
+message ListServiceRolloutsRequest {
+ // The name of the service. See the [overview](/service-management/overview)
+ // for naming requirements. For example: `example.googleapis.com`.
+ string service_name = 1;
+
+ // The token of the page to retrieve.
+ string page_token = 2;
+
+ // The max number of items to include in the response list.
+ int32 page_size = 3;
+
+ // Use `filter` to return subset of rollouts.
+ // The following filters are supported:
+ // -- To limit the results to only those in
+ // [status](google.api.servicemanagement.v1.RolloutStatus) 'SUCCESS',
+ // use filter='status=SUCCESS'
+ // -- To limit the results to those in
+ // [status](google.api.servicemanagement.v1.RolloutStatus) 'CANCELLED'
+ // or 'FAILED', use filter='status=CANCELLED OR status=FAILED'
+ string filter = 4;
+}
+
+// Response message for ListServiceRollouts method.
+message ListServiceRolloutsResponse {
+ // The list of rollout resources.
+ repeated Rollout rollouts = 1;
+
+ // The token of the next page of results.
+ string next_page_token = 2;
+}
+
+// Request message for GetServiceRollout method.
+message GetServiceRolloutRequest {
+ // The name of the service. See the [overview](/service-management/overview)
+ // for naming requirements. For example: `example.googleapis.com`.
+ string service_name = 1;
+
+ // The id of the rollout resource.
+ string rollout_id = 2;
+}
+
+// Request message for EnableService method.
+message EnableServiceRequest {
+ // Name of the service to enable. Specifying an unknown service name will
+ // cause the request to fail.
+ string service_name = 1;
+
+ // The identity of consumer resource which service enablement will be
+ // applied to.
+ //
+ // The Google Service Management implementation accepts the following
+ // forms:
+ // - "project:<project_id>"
+ //
+ // Note: this is made compatible with
+ // google.api.servicecontrol.v1.Operation.consumer_id.
+ string consumer_id = 2;
+}
+
+// Request message for DisableService method.
+message DisableServiceRequest {
+ // Name of the service to disable. Specifying an unknown service name
+ // will cause the request to fail.
+ string service_name = 1;
+
+ // The identity of consumer resource which service disablement will be
+ // applied to.
+ //
+ // The Google Service Management implementation accepts the following
+ // forms:
+ // - "project:<project_id>"
+ //
+ // Note: this is made compatible with
+ // google.api.servicecontrol.v1.Operation.consumer_id.
+ string consumer_id = 2;
+}
+
+// Request message for GenerateConfigReport method.
+message GenerateConfigReportRequest {
+ // Service configuration for which we want to generate the report.
+ // For this version of API, the supported types are
+ // [google.api.servicemanagement.v1.ConfigRef][google.api.servicemanagement.v1.ConfigRef],
+ // [google.api.servicemanagement.v1.ConfigSource][google.api.servicemanagement.v1.ConfigSource],
+ // and [google.api.Service][google.api.Service]
+ google.protobuf.Any new_config = 1;
+
+ // Service configuration against which the comparison will be done.
+ // For this version of API, the supported types are
+ // [google.api.servicemanagement.v1.ConfigRef][google.api.servicemanagement.v1.ConfigRef],
+ // [google.api.servicemanagement.v1.ConfigSource][google.api.servicemanagement.v1.ConfigSource],
+ // and [google.api.Service][google.api.Service]
+ google.protobuf.Any old_config = 2;
+}
+
+// Response message for GenerateConfigReport method.
+message GenerateConfigReportResponse {
+ // Name of the service this report belongs to.
+ string service_name = 1;
+
+ // ID of the service configuration this report belongs to.
+ string id = 2;
+
+ // list of ChangeReport, each corresponding to comparison between two
+ // service configurations.
+ repeated ChangeReport change_reports = 3;
+
+ // Errors / Linter warnings associated with the service definition this
+ // report
+ // belongs to.
+ repeated Diagnostic diagnostics = 4;
+}

protos/google/api/service.proto

@@ -0,0 +1,181 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+import "google/api/annotations.proto";
+import "google/api/auth.proto";
+import "google/api/backend.proto";
+import "google/api/billing.proto";
+import "google/api/context.proto";
+import "google/api/control.proto";
+import "google/api/documentation.proto";
+import "google/api/endpoint.proto";
+import "google/api/experimental/experimental.proto";
+import "google/api/http.proto";
+import "google/api/label.proto";
+import "google/api/log.proto";
+import "google/api/logging.proto";
+import "google/api/metric.proto";
+import "google/api/monitored_resource.proto";
+import "google/api/monitoring.proto";
+import "google/api/quota.proto";
+import "google/api/source_info.proto";
+import "google/api/system_parameter.proto";
+import "google/api/usage.proto";
+import "google/protobuf/any.proto";
+import "google/protobuf/api.proto";
+import "google/protobuf/type.proto";
+import "google/protobuf/wrappers.proto";
+
+option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig";
+option java_multiple_files = true;
+option java_outer_classname = "ServiceProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// `Service` is the root object of Google service configuration schema. It
+// describes basic information about a service, such as the name and the
+// title, and delegates other aspects to sub-sections. Each sub-section is
+// either a proto message or a repeated proto message that configures a
+// specific aspect, such as auth. See each proto message definition for details.
+//
+// Example:
+//
+// type: google.api.Service
+// config_version: 3
+// name: calendar.googleapis.com
+// title: Google Calendar API
+// apis:
+// - name: google.calendar.v3.Calendar
+// authentication:
+// providers:
+// - id: google_calendar_auth
+// jwks_uri: https://www.googleapis.com/oauth2/v1/certs
+// issuer: https://securetoken.google.com
+// rules:
+// - selector: "*"
+// requirements:
+// provider_id: google_calendar_auth
+message Service {
+ // The semantic version of the service configuration. The config version
+ // affects the interpretation of the service configuration. For example,
+ // certain features are enabled by default for certain config versions.
+ // The latest config version is `3`.
+ google.protobuf.UInt32Value config_version = 20;
+
+ // The service name, which is a DNS-like logical identifier for the
+ // service, such as `calendar.googleapis.com`. The service name
+ // typically goes through DNS verification to make sure the owner
+ // of the service also owns the DNS name.
+ string name = 1;
+
+ // A unique ID for a specific instance of this message, typically assigned
+ // by the client for tracking purpose. If empty, the server may choose to
+ // generate one instead. Must be no longer than 60 characters.
+ string id = 33;
+
+ // The product title for this service.
+ string title = 2;
+
+ // The Google project that owns this service.
+ string producer_project_id = 22;
+
+ // A list of API interfaces exported by this service. Only the `name` field
+ // of the [google.protobuf.Api][google.protobuf.Api] needs to be provided by
+ // the configuration author, as the remaining fields will be derived from the
+ // IDL during the normalization process. It is an error to specify an API
+ // interface here which cannot be resolved against the associated IDL files.
+ repeated google.protobuf.Api apis = 3;
+
+ // A list of all proto message types included in this API service.
+ // Types referenced directly or indirectly by the `apis` are
+ // automatically included. Messages which are not referenced but
+ // shall be included, such as types used by the `google.protobuf.Any` type,
+ // should be listed here by name. Example:
+ //
+ // types:
+ // - name: google.protobuf.Int32
+ repeated google.protobuf.Type types = 4;
+
+ // A list of all enum types included in this API service. Enums
+ // referenced directly or indirectly by the `apis` are automatically
+ // included. Enums which are not referenced but shall be included
+ // should be listed here by name. Example:
+ //
+ // enums:
+ // - name: google.someapi.v1.SomeEnum
+ repeated google.protobuf.Enum enums = 5;
+
+ // Additional API documentation.
+ Documentation documentation = 6;
+
+ // API backend configuration.
+ Backend backend = 8;
+
+ // HTTP configuration.
+ Http http = 9;
+
+ // Quota configuration.
+ Quota quota = 10;
+
+ // Auth configuration.
+ Authentication authentication = 11;
+
+ // Context configuration.
+ Context context = 12;
+
+ // Configuration controlling usage of this service.
+ Usage usage = 15;
+
+ // Configuration for network endpoints. If this is empty, then an endpoint
+ // with the same name as the service is automatically generated to service all
+ // defined APIs.
+ repeated Endpoint endpoints = 18;
+
+ // Configuration for the service control plane.
+ Control control = 21;
+
+ // Defines the logs used by this service.
+ repeated LogDescriptor logs = 23;
+
+ // Defines the metrics used by this service.
+ repeated MetricDescriptor metrics = 24;
+
+ // Defines the monitored resources used by this service. This is required
+ // by the [Service.monitoring][google.api.Service.monitoring] and
+ // [Service.logging][google.api.Service.logging] configurations.
+ repeated MonitoredResourceDescriptor monitored_resources = 25;
+
+ // Billing configuration.
+ Billing billing = 26;
+
+ // Logging configuration.
+ Logging logging = 27;
+
+ // Monitoring configuration.
+ Monitoring monitoring = 28;
+
+ // System parameter configuration.
+ SystemParameters system_parameters = 29;
+
+ // Output only. The source information for this configuration if available.
+ SourceInfo source_info = 37;
+
+ // Experimental configuration.
+ Experimental experimental = 101;
+}

protos/google/api/source_info.proto

@@ -0,0 +1,32 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+import "google/protobuf/any.proto";
+
+option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig";
+option java_multiple_files = true;
+option java_outer_classname = "SourceInfoProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// Source information used to create a Service Config
+message SourceInfo {
+ // All files used during config generation.
+ repeated google.protobuf.Any source_files = 1;
+}

protos/google/api/system_parameter.proto

@@ -0,0 +1,97 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig";
+option java_multiple_files = true;
+option java_outer_classname = "SystemParameterProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// ### System parameter configuration
+//
+// A system parameter is a special kind of parameter defined by the API
+// system, not by an individual API. It is typically mapped to an HTTP header
+// and/or a URL query parameter. This configuration specifies which methods
+// change the names of the system parameters.
+message SystemParameters {
+ // Define system parameters.
+ //
+ // The parameters defined here will override the default parameters
+ // implemented by the system. If this field is missing from the service
+ // config, default system parameters will be used. Default system parameters
+ // and names is implementation-dependent.
+ //
+ // Example: define api key for all methods
+ //
+ // system_parameters
+ // rules:
+ // - selector: "*"
+ // parameters:
+ // - name: api_key
+ // url_query_parameter: api_key
+ //
+ //
+ // Example: define 2 api key names for a specific method.
+ //
+ // system_parameters
+ // rules:
+ // - selector: "/ListShelves"
+ // parameters:
+ // - name: api_key
+ // http_header: Api-Key1
+ // - name: api_key
+ // http_header: Api-Key2
+ //
+ // **NOTE:** All service configuration rules follow "last one wins" order.
+ repeated SystemParameterRule rules = 1;
+}
+
+// Define a system parameter rule mapping system parameter definitions to
+// methods.
+message SystemParameterRule {
+ // Selects the methods to which this rule applies. Use '*' to indicate all
+ // methods in all APIs.
+ //
+ // Refer to [selector][google.api.DocumentationRule.selector] for syntax
+ // details.
+ string selector = 1;
+
+ // Define parameters. Multiple names may be defined for a parameter.
+ // For a given method call, only one of them should be used. If multiple
+ // names are used the behavior is implementation-dependent.
+ // If none of the specified names are present the behavior is
+ // parameter-dependent.
+ repeated SystemParameter parameters = 2;
+}
+
+// Define a parameter's name and location. The parameter may be passed as either
+// an HTTP header or a URL query parameter, and if both are passed the behavior
+// is implementation-dependent.
+message SystemParameter {
+ // Define the name of the parameter, such as "api_key" . It is case sensitive.
+ string name = 1;
+
+ // Define the HTTP header name to use for the parameter. It is case
+ // insensitive.
+ string http_header = 2;
+
+ // Define the URL query parameter name to use for the parameter. It is case
+ // sensitive.
+ string url_query_parameter = 3;
+}

protos/google/api/usage.proto

@@ -0,0 +1,93 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.api;
+
+import "google/api/annotations.proto";
+
+option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig";
+option java_multiple_files = true;
+option java_outer_classname = "UsageProto";
+option java_package = "com.google.api";
+option objc_class_prefix = "GAPI";
+
+// Configuration controlling usage of a service.
+message Usage {
+ // Requirements that must be satisfied before a consumer project can use the
+ // service. Each requirement is of the form <service.name>/<requirement-id>;
+ // for example 'serviceusage.googleapis.com/billing-enabled'.
+ repeated string requirements = 1;
+
+ // A list of usage rules that apply to individual API methods.
+ //
+ // **NOTE:** All service configuration rules follow "last one wins" order.
+ repeated UsageRule rules = 6;
+
+ // The full resource name of a channel used for sending notifications to the
+ // service producer.
+ //
+ // Google Service Management currently only supports
+ // [Google Cloud Pub/Sub](https://cloud.google.com/pubsub) as a notification
+ // channel. To use Google Cloud Pub/Sub as the channel, this must be the name
+ // of a Cloud Pub/Sub topic that uses the Cloud Pub/Sub topic name format
+ // documented in https://cloud.google.com/pubsub/docs/overview.
+ string producer_notification_channel = 7;
+}
+
+// Usage configuration rules for the service.
+//
+// NOTE: Under development.
+//
+//
+// Use this rule to configure unregistered calls for the service. Unregistered
+// calls are calls that do not contain consumer project identity.
+// (Example: calls that do not contain an API key).
+// By default, API methods do not allow unregistered calls, and each method call
+// must be identified by a consumer project identity. Use this rule to
+// allow/disallow unregistered calls.
+//
+// Example of an API that wants to allow unregistered calls for entire service.
+//
+// usage:
+// rules:
+// - selector: "*"
+// allow_unregistered_calls: true
+//
+// Example of a method that wants to allow unregistered calls.
+//
+// usage:
+// rules:
+// - selector: "google.example.library.v1.LibraryService.CreateBook"
+// allow_unregistered_calls: true
+message UsageRule {
+ // Selects the methods to which this rule applies. Use '*' to indicate all
+ // methods in all APIs.
+ //
+ // Refer to [selector][google.api.DocumentationRule.selector] for syntax
+ // details.
+ string selector = 1;
+
+ // If true, the selected method allows unregistered calls, e.g. calls
+ // that don't identify any user or application.
+ bool allow_unregistered_calls = 2;
+
+ // If true, the selected method should skip service control and the control
+ // plane features, such as quota and billing, will not be available.
+ // This flag is used by Google Cloud Endpoints to bypass checks for internal
+ // methods, such as service health check methods.
+ bool skip_service_control = 3;
+}

protos/google/iam/v1/iam_policy.proto

@@ -0,0 +1,128 @@
+// Copyright 2016 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.iam.v1;
+
+import "google/api/annotations.proto";
+import "google/iam/v1/policy.proto";
+
+option cc_enable_arenas = true;
+option csharp_namespace = "Google.Cloud.Iam.V1";
+option go_package = "google.golang.org/genproto/googleapis/iam/v1;iam";
+option java_multiple_files = true;
+option java_outer_classname = "IamPolicyProto";
+option java_package = "com.google.iam.v1";
+option php_namespace = "Google\\Cloud\\Iam\\V1";
+
+// ## API Overview
+//
+// Manages Identity and Access Management (IAM) policies.
+//
+// Any implementation of an API that offers access control features
+// implements the google.iam.v1.IAMPolicy interface.
+//
+// ## Data model
+//
+// Access control is applied when a principal (user or service account), takes
+// some action on a resource exposed by a service. Resources, identified by
+// URI-like names, are the unit of access control specification. Service
+// implementations can choose the granularity of access control and the
+// supported permissions for their resources.
+// For example one database service may allow access control to be
+// specified only at the Table level, whereas another might allow access control
+// to also be specified at the Column level.
+//
+// ## Policy Structure
+//
+// See google.iam.v1.Policy
+//
+// This is intentionally not a CRUD style API because access control policies
+// are created and deleted implicitly with the resources to which they are
+// attached.
+service IAMPolicy {
+ // Sets the access control policy on the specified resource. Replaces any
+ // existing policy.
+ rpc SetIamPolicy(SetIamPolicyRequest) returns (Policy) {
+ option (google.api.http) = {
+ post: "/v1/{resource=**}:setIamPolicy"
+ body: "*"
+ };
+ }
+
+ // Gets the access control policy for a resource.
+ // Returns an empty policy if the resource exists and does not have a policy
+ // set.
+ rpc GetIamPolicy(GetIamPolicyRequest) returns (Policy) {
+ option (google.api.http) = {
+ post: "/v1/{resource=**}:getIamPolicy"
+ body: "*"
+ };
+ }
+
+ // Returns permissions that a caller has on the specified resource.
+ // If the resource does not exist, this will return an empty set of
+ // permissions, not a NOT_FOUND error.
+ rpc TestIamPermissions(TestIamPermissionsRequest)
+ returns (TestIamPermissionsResponse) {
+ option (google.api.http) = {
+ post: "/v1/{resource=**}:testIamPermissions"
+ body: "*"
+ };
+ }
+}
+
+// Request message for `SetIamPolicy` method.
+message SetIamPolicyRequest {
+ // REQUIRED: The resource for which the policy is being specified.
+ // `resource` is usually specified as a path. For example, a Project
+ // resource is specified as `projects/{project}`.
+ string resource = 1;
+
+ // REQUIRED: The complete policy to be applied to the `resource`. The size of
+ // the policy is limited to a few 10s of KB. An empty policy is a
+ // valid policy but certain Cloud Platform services (such as Projects)
+ // might reject them.
+ Policy policy = 2;
+}
+
+// Request message for `GetIamPolicy` method.
+message GetIamPolicyRequest {
+ // REQUIRED: The resource for which the policy is being requested.
+ // `resource` is usually specified as a path. For example, a Project
+ // resource is specified as `projects/{project}`.
+ string resource = 1;
+}
+
+// Request message for `TestIamPermissions` method.
+message TestIamPermissionsRequest {
+ // REQUIRED: The resource for which the policy detail is being requested.
+ // `resource` is usually specified as a path. For example, a Project
+ // resource is specified as `projects/{project}`.
+ string resource = 1;
+
+ // The set of permissions to check for the `resource`. Permissions with
+ // wildcards (such as '*' or 'storage.*') are not allowed. For more
+ // information see
+ // [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
+ repeated string permissions = 2;
+}
+
+// Response message for `TestIamPermissions` method.
+message TestIamPermissionsResponse {
+ // A subset of `TestPermissionsRequest.permissions` that the caller is
+ // allowed.
+ repeated string permissions = 1;
+}

protos/google/iam/v1/logging/audit_data.proto

@@ -0,0 +1,34 @@
+// Copyright 2017 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.iam.v1.logging;
+
+import "google/api/annotations.proto";
+import "google/iam/v1/policy.proto";
+
+option csharp_namespace = "Google.Cloud.Iam.V1.Logging";
+option go_package = "google.golang.org/genproto/googleapis/iam/v1/logging;logging";
+option java_multiple_files = true;
+option java_outer_classname = "AuditDataProto";
+option java_package = "com.google.iam.v1.logging";
+
+// Audit log information specific to Cloud IAM. This message is serialized
+// as an `Any` type in the `ServiceData` message of an
+// `AuditLog` message.
+message AuditData {
+ // Policy delta between the original policy and the newly set policy.
+ google.iam.v1.PolicyDelta policy_delta = 2;
+}

protos/google/iam/v1/policy.proto

@@ -0,0 +1,149 @@
+// Copyright 2016 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.iam.v1;
+
+import "google/api/annotations.proto";
+
+option cc_enable_arenas = true;
+option csharp_namespace = "Google.Cloud.Iam.V1";
+option go_package = "google.golang.org/genproto/googleapis/iam/v1;iam";
+option java_multiple_files = true;
+option java_outer_classname = "PolicyProto";
+option java_package = "com.google.iam.v1";
+option php_namespace = "Google\\Cloud\\Iam\\V1";
+
+// Defines an Identity and Access Management (IAM) policy. It is used to
+// specify access control policies for Cloud Platform resources.
+//
+//
+// A `Policy` consists of a list of `bindings`. A `Binding` binds a list of
+// `members` to a `role`, where the members can be user accounts, Google groups,
+// Google domains, and service accounts. A `role` is a named list of permissions
+// defined by IAM.
+//
+// **Example**
+//
+// {
+// "bindings": [
+// {
+// "role": "roles/owner",
+// "members": [
+// "user:mike@example.com",
+// "group:admins@example.com",
+// "domain:google.com",
+// "serviceAccount:my-other-app@appspot.gserviceaccount.com",
+// ]
+// },
+// {
+// "role": "roles/viewer",
+// "members": ["user:sean@example.com"]
+// }
+// ]
+// }
+//
+// For a description of IAM and its features, see the
+// [IAM developer's guide](https://cloud.google.com/iam).
+message Policy {
+ // Version of the `Policy`. The default version is 0.
+ int32 version = 1;
+
+ // Associates a list of `members` to a `role`.
+ // Multiple `bindings` must not be specified for the same `role`.
+ // `bindings` with no members will result in an error.
+ repeated Binding bindings = 4;
+
+ // `etag` is used for optimistic concurrency control as a way to help
+ // prevent simultaneous updates of a policy from overwriting each other.
+ // It is strongly suggested that systems make use of the `etag` in the
+ // read-modify-write cycle to perform policy updates in order to avoid race
+ // conditions: An `etag` is returned in the response to `getIamPolicy`, and
+ // systems are expected to put that etag in the request to `setIamPolicy` to
+ // ensure that their change will be applied to the same version of the policy.
+ //
+ // If no `etag` is provided in the call to `setIamPolicy`, then the existing
+ // policy is overwritten blindly.
+ bytes etag = 3;
+}
+
+// Associates `members` with a `role`.
+message Binding {
+ // Role that is assigned to `members`.
+ // For example, `roles/viewer`, `roles/editor`, or `roles/owner`.
+ // Required
+ string role = 1;
+
+ // Specifies the identities requesting access for a Cloud Platform resource.
+ // `members` can have the following values:
+ //
+ // * `allUsers`: A special identifier that represents anyone who is
+ // on the internet; with or without a Google account.
+ //
+ // * `allAuthenticatedUsers`: A special identifier that represents anyone
+ // who is authenticated with a Google account or a service account.
+ //
+ // * `user:{emailid}`: An email address that represents a specific Google
+ // account. For example, `alice@gmail.com` or `joe@example.com`.
+ //
+ //
+ // * `serviceAccount:{emailid}`: An email address that represents a service
+ // account. For example, `my-other-app@appspot.gserviceaccount.com`.
+ //
+ // * `group:{emailid}`: An email address that represents a Google group.
+ // For example, `admins@example.com`.
+ //
+ // * `domain:{domain}`: A Google Apps domain name that represents all the
+ // users of that domain. For example, `google.com` or `example.com`.
+ //
+ //
+ repeated string members = 2;
+}
+
+// The difference delta between two policies.
+message PolicyDelta {
+ // The delta for Bindings between two policies.
+ repeated BindingDelta binding_deltas = 1;
+}
+
+// One delta entry for Binding. Each individual change (only one member in each
+// entry) to a binding will be a separate entry.
+message BindingDelta {
+ // The type of action performed on a Binding in a policy.
+ enum Action {
+ // Unspecified.
+ ACTION_UNSPECIFIED = 0;
+
+ // Addition of a Binding.
+ ADD = 1;
+
+ // Removal of a Binding.
+ REMOVE = 2;
+ }
+
+ // The action that was performed on a Binding.
+ // Required
+ Action action = 1;
+
+ // Role that is assigned to `members`.
+ // For example, `roles/viewer`, `roles/editor`, or `roles/owner`.
+ // Required
+ string role = 2;
+
+ // A single identity requesting access for a Cloud Platform resource.
+ // Follows the same format of Binding.members.
+ // Required
+ string member = 3;
+}

protos/google/logging/type/http_request.proto

@@ -0,0 +1,94 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.logging.type;
+
+import "google/api/annotations.proto";
+import "google/protobuf/duration.proto";
+
+option csharp_namespace = "Google.Cloud.Logging.Type";
+option go_package = "google.golang.org/genproto/googleapis/logging/type;ltype";
+option java_multiple_files = true;
+option java_outer_classname = "HttpRequestProto";
+option java_package = "com.google.logging.type";
+option php_namespace = "Google\\Cloud\\Logging\\Type";
+
+// A common proto for logging HTTP requests. Only contains semantics
+// defined by the HTTP specification. Product-specific logging
+// information MUST be defined in a separate message.
+message HttpRequest {
+ // The request method. Examples: `"GET"`, `"HEAD"`, `"PUT"`, `"POST"`.
+ string request_method = 1;
+
+ // The scheme (http, https), the host name, the path and the query
+ // portion of the URL that was requested.
+ // Example: `"http://example.com/some/info?color=red"`.
+ string request_url = 2;
+
+ // The size of the HTTP request message in bytes, including the request
+ // headers and the request body.
+ int64 request_size = 3;
+
+ // The response code indicating the status of response.
+ // Examples: 200, 404.
+ int32 status = 4;
+
+ // The size of the HTTP response message sent back to the client, in bytes,
+ // including the response headers and the response body.
+ int64 response_size = 5;
+
+ // The user agent sent by the client. Example:
+ // `"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Q312461; .NET
+ // CLR 1.0.3705)"`.
+ string user_agent = 6;
+
+ // The IP address (IPv4 or IPv6) of the client that issued the HTTP
+ // request. Examples: `"192.168.1.1"`, `"FE80::0202:B3FF:FE1E:8329"`.
+ string remote_ip = 7;
+
+ // The IP address (IPv4 or IPv6) of the origin server that the request was
+ // sent to.
+ string server_ip = 13;
+
+ // The referer URL of the request, as defined in
+ // [HTTP/1.1 Header Field
+ // Definitions](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
+ string referer = 8;
+
+ // The request processing latency on the server, from the time the request was
+ // received until the response was sent.
+ google.protobuf.Duration latency = 14;
+
+ // Whether or not a cache lookup was attempted.
+ bool cache_lookup = 11;
+
+ // Whether or not an entity was served from cache
+ // (with or without validation).
+ bool cache_hit = 9;
+
+ // Whether or not the response was validated with the origin server before
+ // being served from cache. This field is only meaningful if `cache_hit` is
+ // True.
+ bool cache_validated_with_origin_server = 10;
+
+ // The number of HTTP response bytes inserted into cache. Set only when a
+ // cache fill was attempted.
+ int64 cache_fill_bytes = 12;
+
+ // Protocol used for the request. Examples: "HTTP/1.1", "HTTP/2", "websocket"
+ string protocol = 15;
+}

protos/google/logging/type/log_severity.proto

@@ -0,0 +1,72 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.logging.type;
+
+import "google/api/annotations.proto";
+
+option csharp_namespace = "Google.Cloud.Logging.Type";
+option go_package = "google.golang.org/genproto/googleapis/logging/type;ltype";
+option java_multiple_files = true;
+option java_outer_classname = "LogSeverityProto";
+option java_package = "com.google.logging.type";
+option php_namespace = "Google\\Cloud\\Logging\\Type";
+
+// The severity of the event described in a log entry, expressed as one of the
+// standard severity levels listed below. For your reference, the levels are
+// assigned the listed numeric values. The effect of using numeric values other
+// than those listed is undefined.
+//
+// You can filter for log entries by severity. For example, the following
+// filter expression will match log entries with severities `INFO`, `NOTICE`,
+// and `WARNING`:
+//
+// severity > DEBUG AND severity <= WARNING
+//
+// If you are writing log entries, you should map other severity encodings to
+// one of these standard levels. For example, you might map all of Java's FINE,
+// FINER, and FINEST levels to `LogSeverity.DEBUG`. You can preserve the
+// original severity level in the log entry payload if you wish.
+enum LogSeverity {
+ // (0) The log entry has no assigned severity level.
+ DEFAULT = 0;
+
+ // (100) Debug or trace information.
+ DEBUG = 100;
+
+ // (200) Routine information, such as ongoing status or performance.
+ INFO = 200;
+
+ // (300) Normal but significant events, such as start up, shut down, or
+ // a configuration change.
+ NOTICE = 300;
+
+ // (400) Warning events might cause problems.
+ WARNING = 400;
+
+ // (500) Error events are likely to cause problems.
+ ERROR = 500;
+
+ // (600) Critical events cause more severe problems or outages.
+ CRITICAL = 600;
+
+ // (700) A person must take an action immediately.
+ ALERT = 700;
+
+ // (800) One or more systems are unusable.
+ EMERGENCY = 800;
+}

protos/google/longrunning/operations.proto

@@ -0,0 +1,241 @@
+// Copyright 2019 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.longrunning;
+
+import "google/api/annotations.proto";
+import "google/protobuf/any.proto";
+import "google/protobuf/duration.proto";
+import "google/protobuf/empty.proto";
+import "google/rpc/status.proto";
+import "google/protobuf/descriptor.proto";
+
+option cc_enable_arenas = true;
+option csharp_namespace = "Google.LongRunning";
+option go_package = "google.golang.org/genproto/googleapis/longrunning;longrunning";
+option java_multiple_files = true;
+option java_outer_classname = "OperationsProto";
+option java_package = "com.google.longrunning";
+option php_namespace = "Google\\LongRunning";
+
+extend google.protobuf.MethodOptions {
+ // Additional information regarding long-running operations.
+ // In particular, this specifies the types that are returned from
+ // long-running operations.
+ //
+ // Required for methods that return `google.longrunning.Operation`; invalid
+ // otherwise.
+ google.longrunning.OperationInfo operation_info = 1049;
+}
+
+// Manages long-running operations with an API service.
+//
+// When an API method normally takes long time to complete, it can be designed
+// to return [Operation][google.longrunning.Operation] to the client, and the client can use this
+// interface to receive the real response asynchronously by polling the
+// operation resource, or pass the operation resource to another API (such as
+// Google Cloud Pub/Sub API) to receive the response. Any API service that
+// returns long-running operations should implement the `Operations` interface
+// so developers can have a consistent client experience.
+service Operations {
+ // Lists operations that match the specified filter in the request. If the
+ // server doesn't support this method, it returns `UNIMPLEMENTED`.
+ //
+ // NOTE: the `name` binding allows API services to override the binding
+ // to use different resource name schemes, such as `users/*/operations`. To
+ // override the binding, API services can add a binding such as
+ // `"/v1/{name=users/*}/operations"` to their service configuration.
+ // For backwards compatibility, the default name includes the operations
+ // collection id, however overriding users must ensure the name binding
+ // is the parent resource, without the operations collection id.
+ rpc ListOperations(ListOperationsRequest) returns (ListOperationsResponse) {
+ option (google.api.http) = {
+ get: "/v1/{name=operations}"
+ };
+ }
+
+ // Gets the latest state of a long-running operation. Clients can use this
+ // method to poll the operation result at intervals as recommended by the API
+ // service.
+ rpc GetOperation(GetOperationRequest) returns (Operation) {
+ option (google.api.http) = {
+ get: "/v1/{name=operations/**}"
+ };
+ }
+
+ // Deletes a long-running operation. This method indicates that the client is
+ // no longer interested in the operation result. It does not cancel the
+ // operation. If the server doesn't support this method, it returns
+ // `google.rpc.Code.UNIMPLEMENTED`.
+ rpc DeleteOperation(DeleteOperationRequest) returns (google.protobuf.Empty) {
+ option (google.api.http) = {
+ delete: "/v1/{name=operations/**}"
+ };
+ }
+
+ // Starts asynchronous cancellation on a long-running operation. The server
+ // makes a best effort to cancel the operation, but success is not
+ // guaranteed. If the server doesn't support this method, it returns
+ // `google.rpc.Code.UNIMPLEMENTED`. Clients can use
+ // [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
+ // other methods to check whether the cancellation succeeded or whether the
+ // operation completed despite cancellation. On successful cancellation,
+ // the operation is not deleted; instead, it becomes an operation with
+ // an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1,
+ // corresponding to `Code.CANCELLED`.
+ rpc CancelOperation(CancelOperationRequest) returns (google.protobuf.Empty) {
+ option (google.api.http) = {
+ post: "/v1/{name=operations/**}:cancel"
+ body: "*"
+ };
+ }
+
+ // Waits for the specified long-running operation until it is done or reaches
+ // at most a specified timeout, returning the latest state. If the operation
+ // is already done, the latest state is immediately returned. If the timeout
+ // specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
+ // timeout is used. If the server does not support this method, it returns
+ // `google.rpc.Code.UNIMPLEMENTED`.
+ // Note that this method is on a best-effort basis. It may return the latest
+ // state before the specified timeout (including immediately), meaning even an
+ // immediate response is no guarantee that the operation is done.
+ rpc WaitOperation(WaitOperationRequest) returns (Operation) {
+ }
+}
+
+// This resource represents a long-running operation that is the result of a
+// network API call.
+message Operation {
+ // The server-assigned name, which is only unique within the same service that
+ // originally returns it. If you use the default HTTP mapping, the
+ // `name` should have the format of `operations/some/unique/name`.
+ string name = 1;
+
+ // Service-specific metadata associated with the operation. It typically
+ // contains progress information and common metadata such as create time.
+ // Some services might not provide such metadata. Any method that returns a
+ // long-running operation should document the metadata type, if any.
+ google.protobuf.Any metadata = 2;
+
+ // If the value is `false`, it means the operation is still in progress.
+ // If `true`, the operation is completed, and either `error` or `response` is
+ // available.
+ bool done = 3;
+
+ // The operation result, which can be either an `error` or a valid `response`.
+ // If `done` == `false`, neither `error` nor `response` is set.
+ // If `done` == `true`, exactly one of `error` or `response` is set.
+ oneof result {
+ // The error result of the operation in case of failure or cancellation.
+ google.rpc.Status error = 4;
+
+ // The normal response of the operation in case of success. If the original
+ // method returns no data on success, such as `Delete`, the response is
+ // `google.protobuf.Empty`. If the original method is standard
+ // `Get`/`Create`/`Update`, the response should be the resource. For other
+ // methods, the response should have the type `XxxResponse`, where `Xxx`
+ // is the original method name. For example, if the original method name
+ // is `TakeSnapshot()`, the inferred response type is
+ // `TakeSnapshotResponse`.
+ google.protobuf.Any response = 5;
+ }
+}
+
+// The request message for [Operations.GetOperation][google.longrunning.Operations.GetOperation].
+message GetOperationRequest {
+ // The name of the operation resource.
+ string name = 1;
+}
+
+// The request message for [Operations.ListOperations][google.longrunning.Operations.ListOperations].
+message ListOperationsRequest {
+ // The name of the operation's parent resource.
+ string name = 4;
+
+ // The standard list filter.
+ string filter = 1;
+
+ // The standard list page size.
+ int32 page_size = 2;
+
+ // The standard list page token.
+ string page_token = 3;
+}
+
+// The response message for [Operations.ListOperations][google.longrunning.Operations.ListOperations].
+message ListOperationsResponse {
+ // A list of operations that matches the specified filter in the request.
+ repeated Operation operations = 1;
+
+ // The standard List next-page token.
+ string next_page_token = 2;
+}
+
+// The request message for [Operations.CancelOperation][google.longrunning.Operations.CancelOperation].
+message CancelOperationRequest {
+ // The name of the operation resource to be cancelled.
+ string name = 1;
+}
+
+// The request message for [Operations.DeleteOperation][google.longrunning.Operations.DeleteOperation].
+message DeleteOperationRequest {
+ // The name of the operation resource to be deleted.
+ string name = 1;
+}
+
+// The request message for [Operations.WaitOperation][google.longrunning.Operations.WaitOperation].
+message WaitOperationRequest {
+ // The name of the operation resource to wait on.
+ string name = 1;
+
+ // The maximum duration to wait before timing out. If left blank, the wait
+ // will be at most the time permitted by the underlying HTTP/RPC protocol.
+ // If RPC context deadline is also specified, the shorter one will be used.
+ google.protobuf.Duration timeout = 2;
+}
+
+// A message representing the message types used by a long-running operation.
+//
+// Example:
+//
+// rpc LongRunningRecognize(LongRunningRecognizeRequest)
+// returns (google.longrunning.Operation) {
+// option (google.longrunning.operation_info) = {
+// response_type: "LongRunningRecognizeResponse"
+// metadata_type: "LongRunningRecognizeMetadata"
+// };
+// }
+message OperationInfo {
+ // Required. The message name of the primary return type for this
+ // long-running operation.
+ // This type will be used to deserialize the LRO's response.
+ //
+ // If the response is in a different package from the rpc, a fully-qualified
+ // message name must be used (e.g. `google.protobuf.Struct`).
+ //
+ // Note: Altering this value constitutes a breaking change.
+ string response_type = 1;
+
+ // Required. The message name of the metadata type for this long-running
+ // operation.
+ //
+ // If the response is in a different package from the rpc, a fully-qualified
+ // message name must be used (e.g. `google.protobuf.Struct`).
+ //
+ // Note: Altering this value constitutes a breaking change.
+ string metadata_type = 2;
+}

protos/google/monitoring/v3/alert.proto

@@ -0,0 +1,347 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.monitoring.v3;
+
+import "google/api/annotations.proto";
+import "google/monitoring/v3/common.proto";
+import "google/monitoring/v3/mutation_record.proto";
+import "google/protobuf/duration.proto";
+import "google/protobuf/wrappers.proto";
+
+option csharp_namespace = "Google.Cloud.Monitoring.V3";
+option go_package = "google.golang.org/genproto/googleapis/monitoring/v3;monitoring";
+option java_multiple_files = true;
+option java_outer_classname = "AlertProto";
+option java_package = "com.google.monitoring.v3";
+option php_namespace = "Google\\Cloud\\Monitoring\\V3";
+
+// A description of the conditions under which some aspect of your system is
+// considered to be "unhealthy" and the ways to notify people or services about
+// this state. For an overview of alert policies, see
+// [Introduction to Alerting](/monitoring/alerts/).
+message AlertPolicy {
+ // A content string and a MIME type that describes the content string's
+ // format.
+ message Documentation {
+ // The text of the documentation, interpreted according to `mime_type`.
+ // The content may not exceed 8,192 Unicode characters and may not exceed
+ // more than 10,240 bytes when encoded in UTF-8 format, whichever is
+ // smaller.
+ string content = 1;
+
+ // The format of the `content` field. Presently, only the value
+ // `"text/markdown"` is supported. See
+ // [Markdown](https://en.wikipedia.org/wiki/Markdown) for more information.
+ string mime_type = 2;
+ }
+
+ // A condition is a true/false test that determines when an alerting policy
+ // should open an incident. If a condition evaluates to true, it signifies
+ // that something is wrong.
+ message Condition {
+ // Specifies how many time series must fail a predicate to trigger a
+ // condition. If not specified, then a `{count: 1}` trigger is used.
+ message Trigger {
+ // A type of trigger.
+ oneof type {
+ // The absolute number of time series that must fail
+ // the predicate for the condition to be triggered.
+ int32 count = 1;
+
+ // The percentage of time series that must fail the
+ // predicate for the condition to be triggered.
+ double percent = 2;
+ }
+ }
+
+ // A condition type that compares a collection of time series
+ // against a threshold.
+ message MetricThreshold {
+ // A [filter](/monitoring/api/v3/filters) that
+ // identifies which time series should be compared with the threshold.
+ //
+ // The filter is similar to the one that is specified in the
+ // [`MetricService.ListTimeSeries`
+ // request](/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list) (that
+ // call is useful to verify the time series that will be retrieved /
+ // processed) and must specify the metric type and optionally may contain
+ // restrictions on resource type, resource labels, and metric labels.
+ // This field may not exceed 2048 Unicode characters in length.
+ string filter = 2;
+
+ // Specifies the alignment of data points in individual time series as
+ // well as how to combine the retrieved time series together (such as
+ // when aggregating multiple streams on each resource to a single
+ // stream for each resource or when aggregating streams across all
+ // members of a group of resrouces). Multiple aggregations
+ // are applied in the order specified.
+ //
+ // This field is similar to the one in the
+ // [`MetricService.ListTimeSeries`
+ // request](/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list). It
+ // is advisable to use the `ListTimeSeries` method when debugging this
+ // field.
+ repeated Aggregation aggregations = 8;
+
+ // A [filter](/monitoring/api/v3/filters) that identifies a time
+ // series that should be used as the denominator of a ratio that will be
+ // compared with the threshold. If a `denominator_filter` is specified,
+ // the time series specified by the `filter` field will be used as the
+ // numerator.
+ //
+ // The filter is similar to the one that is specified in the
+ // [`MetricService.ListTimeSeries`
+ // request](/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list) (that
+ // call is useful to verify the time series that will be retrieved /
+ // processed) and must specify the metric type and optionally may contain
+ // restrictions on resource type, resource labels, and metric labels.
+ // This field may not exceed 2048 Unicode characters in length.
+ string denominator_filter = 9;
+
+ // Specifies the alignment of data points in individual time series
+ // selected by `denominatorFilter` as
+ // well as how to combine the retrieved time series together (such as
+ // when aggregating multiple streams on each resource to a single
+ // stream for each resource or when aggregating streams across all
+ // members of a group of resources).
+ //
+ // When computing ratios, the `aggregations` and
+ // `denominator_aggregations` fields must use the same alignment period
+ // and produce time series that have the same periodicity and labels.
+ //
+ // This field is similar to the one in the
+ // [`MetricService.ListTimeSeries`
+ // request](/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list). It
+ // is advisable to use the `ListTimeSeries` method when debugging this
+ // field.
+ repeated Aggregation denominator_aggregations = 10;
+
+ // The comparison to apply between the time series (indicated by `filter`
+ // and `aggregation`) and the threshold (indicated by `threshold_value`).
+ // The comparison is applied on each time series, with the time series
+ // on the left-hand side and the threshold on the right-hand side.
+ //
+ // Only `COMPARISON_LT` and `COMPARISON_GT` are supported currently.
+ ComparisonType comparison = 4;
+
+ // A value against which to compare the time series.
+ double threshold_value = 5;
+
+ // The amount of time that a time series must violate the
+ // threshold to be considered failing. Currently, only values
+ // that are a multiple of a minute--e.g., 0, 60, 120, or 300
+ // seconds--are supported. If an invalid value is given, an
+ // error will be returned. When choosing a duration, it is useful to
+ // keep in mind the frequency of the underlying time series data
+ // (which may also be affected by any alignments specified in the
+ // `aggregations` field); a good duration is long enough so that a single
+ // outlier does not generate spurious alerts, but short enough that
+ // unhealthy states are detected and alerted on quickly.
+ google.protobuf.Duration duration = 6;
+
+ // The number/percent of time series for which the comparison must hold
+ // in order for the condition to trigger. If unspecified, then the
+ // condition will trigger if the comparison is true for any of the
+ // time series that have been identified by `filter` and `aggregations`,
+ // or by the ratio, if `denominator_filter` and `denominator_aggregations`
+ // are specified.
+ Trigger trigger = 7;
+ }
+
+ // A condition type that checks that monitored resources
+ // are reporting data. The configuration defines a metric and
+ // a set of monitored resources. The predicate is considered in violation
+ // when a time series for the specified metric of a monitored
+ // resource does not include any data in the specified `duration`.
+ message MetricAbsence {
+ // A [filter](/monitoring/api/v3/filters) that
+ // identifies which time series should be compared with the threshold.
+ //
+ // The filter is similar to the one that is specified in the
+ // [`MetricService.ListTimeSeries`
+ // request](/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list) (that
+ // call is useful to verify the time series that will be retrieved /
+ // processed) and must specify the metric type and optionally may contain
+ // restrictions on resource type, resource labels, and metric labels.
+ // This field may not exceed 2048 Unicode characters in length.
+ string filter = 1;
+
+ // Specifies the alignment of data points in individual time series as
+ // well as how to combine the retrieved time series together (such as
+ // when aggregating multiple streams on each resource to a single
+ // stream for each resource or when aggregating streams across all
+ // members of a group of resrouces). Multiple aggregations
+ // are applied in the order specified.
+ //
+ // This field is similar to the
+ // one in the [`MetricService.ListTimeSeries`
+ // request](/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list). It
+ // is advisable to use the `ListTimeSeries` method when debugging this
+ // field.
+ repeated Aggregation aggregations = 5;
+
+ // The amount of time that a time series must fail to report new
+ // data to be considered failing. Currently, only values that
+ // are a multiple of a minute--e.g. 60, 120, or 300
+ // seconds--are supported. If an invalid value is given, an
+ // error will be returned. The `Duration.nanos` field is
+ // ignored.
+ google.protobuf.Duration duration = 2;
+
+ // The number/percent of time series for which the comparison must hold
+ // in order for the condition to trigger. If unspecified, then the
+ // condition will trigger if the comparison is true for any of the
+ // time series that have been identified by `filter` and `aggregations`.
+ Trigger trigger = 3;
+ }
+
+ // Required if the condition exists. The unique resource name for this
+ // condition. Its syntax is:
+ //
+ // projects/[PROJECT_ID]/alertPolicies/[POLICY_ID]/conditions/[CONDITION_ID]
+ //
+ // `[CONDITION_ID]` is assigned by Stackdriver Monitoring when the
+ // condition is created as part of a new or updated alerting policy.
+ //
+ // When calling the
+ // [alertPolicies.create][google.monitoring.v3.AlertPolicyService.CreateAlertPolicy]
+ // method, do not include the `name` field in the conditions of the
+ // requested alerting policy. Stackdriver Monitoring creates the
+ // condition identifiers and includes them in the new policy.
+ //
+ // When calling the
+ // [alertPolicies.update][google.monitoring.v3.AlertPolicyService.UpdateAlertPolicy]
+ // method to update a policy, including a condition `name` causes the
+ // existing condition to be updated. Conditions without names are added to
+ // the updated policy. Existing conditions are deleted if they are not
+ // updated.
+ //
+ // Best practice is to preserve `[CONDITION_ID]` if you make only small
+ // changes, such as those to condition thresholds, durations, or trigger
+ // values. Otherwise, treat the change as a new condition and let the
+ // existing condition be deleted.
+ string name = 12;
+
+ // A short name or phrase used to identify the condition in dashboards,
+ // notifications, and incidents. To avoid confusion, don't use the same
+ // display name for multiple conditions in the same policy.
+ string display_name = 6;
+
+ // Only one of the following condition types will be specified.
+ oneof condition {
+ // A condition that compares a time series against a threshold.
+ MetricThreshold condition_threshold = 1;
+
+ // A condition that checks that a time series continues to
+ // receive new data points.
+ MetricAbsence condition_absent = 2;
+ }
+ }
+
+ // Operators for combining conditions.
+ enum ConditionCombinerType {
+ // An unspecified combiner.
+ COMBINE_UNSPECIFIED = 0;
+
+ // Combine conditions using the logical `AND` operator. An
+ // incident is created only if all conditions are met
+ // simultaneously. This combiner is satisfied if all conditions are
+ // met, even if they are met on completely different resources.
+ AND = 1;
+
+ // Combine conditions using the logical `OR` operator. An incident
+ // is created if any of the listed conditions is met.
+ OR = 2;
+
+ // Combine conditions using logical `AND` operator, but unlike the regular
+ // `AND` option, an incident is created only if all conditions are met
+ // simultaneously on at least one resource.
+ AND_WITH_MATCHING_RESOURCE = 3;
+ }
+
+ // Required if the policy exists. The resource name for this policy. The
+ // syntax is:
+ //
+ // projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID]
+ //
+ // `[ALERT_POLICY_ID]` is assigned by Stackdriver Monitoring when the policy
+ // is created. When calling the
+ // [alertPolicies.create][google.monitoring.v3.AlertPolicyService.CreateAlertPolicy]
+ // method, do not include the `name` field in the alerting policy passed as
+ // part of the request.
+ string name = 1;
+
+ // A short name or phrase used to identify the policy in dashboards,
+ // notifications, and incidents. To avoid confusion, don't use the same
+ // display name for multiple policies in the same project. The name is
+ // limited to 512 Unicode characters.
+ string display_name = 2;
+
+ // Documentation that is included with notifications and incidents related to
+ // this policy. Best practice is for the documentation to include information
+ // to help responders understand, mitigate, escalate, and correct the
+ // underlying problems detected by the alerting policy. Notification channels
+ // that have limited capacity might not show this documentation.
+ Documentation documentation = 13;
+
+ // User-supplied key/value data to be used for organizing and
+ // identifying the `AlertPolicy` objects.
+ //
+ // The field can contain up to 64 entries. Each key and value is limited to
+ // 63 Unicode characters or 128 bytes, whichever is smaller. Labels and
+ // values can contain only lowercase letters, numerals, underscores, and
+ // dashes. Keys must begin with a letter.
+ map<string, string> user_labels = 16;
+
+ // A list of conditions for the policy. The conditions are combined by AND or
+ // OR according to the `combiner` field. If the combined conditions evaluate
+ // to true, then an incident is created. A policy can have from one to six
+ // conditions.
+ repeated Condition conditions = 12;
+
+ // How to combine the results of multiple conditions
+ // to determine if an incident should be opened.
+ ConditionCombinerType combiner = 6;
+
+ // Whether or not the policy is enabled. On write, the default interpretation
+ // if unset is that the policy is enabled. On read, clients should not make
+ // any assumption about the state if it has not been populated. The
+ // field should always be populated on List and Get operations, unless
+ // a field projection has been specified that strips it out.
+ google.protobuf.BoolValue enabled = 17;
+
+ // Identifies the notification channels to which notifications should be sent
+ // when incidents are opened or closed or when new violations occur on
+ // an already opened incident. Each element of this array corresponds to
+ // the `name` field in each of the
+ // [`NotificationChannel`][google.monitoring.v3.NotificationChannel]
+ // objects that are returned from the [`ListNotificationChannels`]
+ // [google.monitoring.v3.NotificationChannelService.ListNotificationChannels]
+ // method. The syntax of the entries in this field is:
+ //
+ // projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]
+ repeated string notification_channels = 14;
+
+ // A read-only record of the creation of the alerting policy. If provided
+ // in a call to create or update, this field will be ignored.
+ MutationRecord creation_record = 10;
+
+ // A read-only record of the most recent change to the alerting policy. If
+ // provided in a call to create or update, this field will be ignored.
+ MutationRecord mutation_record = 11;
+}

protos/google/monitoring/v3/alert_service.proto

@@ -0,0 +1,199 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.monitoring.v3;
+
+import "google/api/annotations.proto";
+import "google/monitoring/v3/alert.proto";
+import "google/protobuf/empty.proto";
+import "google/protobuf/field_mask.proto";
+
+option csharp_namespace = "Google.Cloud.Monitoring.V3";
+option go_package = "google.golang.org/genproto/googleapis/monitoring/v3;monitoring";
+option java_multiple_files = true;
+option java_outer_classname = "AlertServiceProto";
+option java_package = "com.google.monitoring.v3";
+option php_namespace = "Google\\Cloud\\Monitoring\\V3";
+
+// The AlertPolicyService API is used to manage (list, create, delete,
+// edit) alert policies in Stackdriver Monitoring. An alerting policy is
+// a description of the conditions under which some aspect of your
+// system is considered to be "unhealthy" and the ways to notify
+// people or services about this state. In addition to using this API, alert
+// policies can also be managed through
+// [Stackdriver Monitoring](https://cloud.google.com/monitoring/docs/),
+// which can be reached by clicking the "Monitoring" tab in
+// [Cloud Console](https://console.cloud.google.com/).
+service AlertPolicyService {
+ // Lists the existing alerting policies for the project.
+ rpc ListAlertPolicies(ListAlertPoliciesRequest)
+ returns (ListAlertPoliciesResponse) {
+ option (google.api.http) = {
+ get: "/v3/{name=projects/*}/alertPolicies"
+ };
+ }
+
+ // Gets a single alerting policy.
+ rpc GetAlertPolicy(GetAlertPolicyRequest) returns (AlertPolicy) {
+ option (google.api.http) = {
+ get: "/v3/{name=projects/*/alertPolicies/*}"
+ };
+ }
+
+ // Creates a new alerting policy.
+ rpc CreateAlertPolicy(CreateAlertPolicyRequest) returns (AlertPolicy) {
+ option (google.api.http) = {
+ post: "/v3/{name=projects/*}/alertPolicies"
+ body: "alert_policy"
+ };
+ }
+
+ // Deletes an alerting policy.
+ rpc DeleteAlertPolicy(DeleteAlertPolicyRequest)
+ returns (google.protobuf.Empty) {
+ option (google.api.http) = {
+ delete: "/v3/{name=projects/*/alertPolicies/*}"
+ };
+ }
+
+ // Updates an alerting policy. You can either replace the entire policy with
+ // a new one or replace only certain fields in the current alerting policy by
+ // specifying the fields to be updated via `updateMask`. Returns the
+ // updated alerting policy.
+ rpc UpdateAlertPolicy(UpdateAlertPolicyRequest) returns (AlertPolicy) {
+ option (google.api.http) = {
+ patch: "/v3/{alert_policy.name=projects/*/alertPolicies/*}"
+ body: "alert_policy"
+ };
+ }
+}
+
+// The protocol for the `CreateAlertPolicy` request.
+message CreateAlertPolicyRequest {
+ // The project in which to create the alerting policy. The format is
+ // `projects/[PROJECT_ID]`.
+ //
+ // Note that this field names the parent container in which the alerting
+ // policy will be written, not the name of the created policy. The alerting
+ // policy that is returned will have a name that contains a normalized
+ // representation of this name as a prefix but adds a suffix of the form
+ // `/alertPolicies/[POLICY_ID]`, identifying the policy in the container.
+ string name = 3;
+
+ // The requested alerting policy. You should omit the `name` field in this
+ // policy. The name will be returned in the new policy, including
+ // a new [ALERT_POLICY_ID] value.
+ AlertPolicy alert_policy = 2;
+}
+
+// The protocol for the `GetAlertPolicy` request.
+message GetAlertPolicyRequest {
+ // The alerting policy to retrieve. The format is
+ //
+ // projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID]
+ string name = 3;
+}
+
+// The protocol for the `ListAlertPolicies` request.
+message ListAlertPoliciesRequest {
+ // The project whose alert policies are to be listed. The format is
+ //
+ // projects/[PROJECT_ID]
+ //
+ // Note that this field names the parent container in which the alerting
+ // policies to be listed are stored. To retrieve a single alerting policy
+ // by name, use the
+ // [GetAlertPolicy][google.monitoring.v3.AlertPolicyService.GetAlertPolicy]
+ // operation, instead.
+ string name = 4;
+
+ // If provided, this field specifies the criteria that must be met by
+ // alert policies to be included in the response.
+ //
+ // For more details, see [sorting and
+ // filtering](/monitoring/api/v3/sorting-and-filtering).
+ string filter = 5;
+
+ // A comma-separated list of fields by which to sort the result. Supports
+ // the same set of field references as the `filter` field. Entries can be
+ // prefixed with a minus sign to sort by the field in descending order.
+ //
+ // For more details, see [sorting and
+ // filtering](/monitoring/api/v3/sorting-and-filtering).
+ string order_by = 6;
+
+ // The maximum number of results to return in a single response.
+ int32 page_size = 2;
+
+ // If this field is not empty then it must contain the `nextPageToken` value
+ // returned by a previous call to this method. Using this field causes the
+ // method to return more results from the previous method call.
+ string page_token = 3;
+}
+
+// The protocol for the `ListAlertPolicies` response.
+message ListAlertPoliciesResponse {
+ // The returned alert policies.
+ repeated AlertPolicy alert_policies = 3;
+
+ // If there might be more results than were returned, then this field is set
+ // to a non-empty value. To see the additional results,
+ // use that value as `pageToken` in the next call to this method.
+ string next_page_token = 2;
+}
+
+// The protocol for the `UpdateAlertPolicy` request.
+message UpdateAlertPolicyRequest {
+ // Optional. A list of alerting policy field names. If this field is not
+ // empty, each listed field in the existing alerting policy is set to the
+ // value of the corresponding field in the supplied policy (`alert_policy`),
+ // or to the field's default value if the field is not in the supplied
+ // alerting policy. Fields not listed retain their previous value.
+ //
+ // Examples of valid field masks include `display_name`, `documentation`,
+ // `documentation.content`, `documentation.mime_type`, `user_labels`,
+ // `user_label.nameofkey`, `enabled`, `conditions`, `combiner`, etc.
+ //
+ // If this field is empty, then the supplied alerting policy replaces the
+ // existing policy. It is the same as deleting the existing policy and
+ // adding the supplied policy, except for the following:
+ //
+ // + The new policy will have the same `[ALERT_POLICY_ID]` as the former
+ // policy. This gives you continuity with the former policy in your
+ // notifications and incidents.
+ // + Conditions in the new policy will keep their former `[CONDITION_ID]` if
+ // the supplied condition includes the `name` field with that
+ // `[CONDITION_ID]`. If the supplied condition omits the `name` field,
+ // then a new `[CONDITION_ID]` is created.
+ google.protobuf.FieldMask update_mask = 2;
+
+ // Required. The updated alerting policy or the updated values for the
+ // fields listed in `update_mask`.
+ // If `update_mask` is not empty, any fields in this policy that are
+ // not in `update_mask` are ignored.
+ AlertPolicy alert_policy = 3;
+}
+
+// The protocol for the `DeleteAlertPolicy` request.
+message DeleteAlertPolicyRequest {
+ // The alerting policy to delete. The format is:
+ //
+ // projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID]
+ //
+ // For more information, see [AlertPolicy][google.monitoring.v3.AlertPolicy].
+ string name = 3;
+}

protos/google/monitoring/v3/common.proto

@@ -0,0 +1,418 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.monitoring.v3;
+
+import "google/api/annotations.proto";
+import "google/api/distribution.proto";
+import "google/protobuf/duration.proto";
+import "google/protobuf/timestamp.proto";
+
+option csharp_namespace = "Google.Cloud.Monitoring.V3";
+option go_package = "google.golang.org/genproto/googleapis/monitoring/v3;monitoring";
+option java_multiple_files = true;
+option java_outer_classname = "CommonProto";
+option java_package = "com.google.monitoring.v3";
+option php_namespace = "Google\\Cloud\\Monitoring\\V3";
+
+// A single strongly-typed value.
+message TypedValue {
+ // The typed value field.
+ oneof value {
+ // A Boolean value: `true` or `false`.
+ bool bool_value = 1;
+
+ // A 64-bit integer. Its range is approximately &plusmn;9.2x10<sup>18</sup>.
+ int64 int64_value = 2;
+
+ // A 64-bit double-precision floating-point number. Its magnitude
+ // is approximately &plusmn;10<sup>&plusmn;300</sup> and it has 16
+ // significant digits of precision.
+ double double_value = 3;
+
+ // A variable-length string value.
+ string string_value = 4;
+
+ // A distribution value.
+ google.api.Distribution distribution_value = 5;
+ }
+}
+
+// A time interval extending just after a start time through an end time.
+// If the start time is the same as the end time, then the interval
+// represents a single point in time.
+message TimeInterval {
+ // Required. The end of the time interval.
+ google.protobuf.Timestamp end_time = 2;
+
+ // Optional. The beginning of the time interval. The default value
+ // for the start time is the end time. The start time must not be
+ // later than the end time.
+ google.protobuf.Timestamp start_time = 1;
+}
+
+// Describes how to combine multiple time series to provide different views of
+// the data. Aggregation consists of an alignment step on individual time
+// series (`alignment_period` and `per_series_aligner`) followed by an optional
+// reduction step of the data across the aligned time series
+// (`cross_series_reducer` and `group_by_fields`). For more details, see
+// [Aggregation](/monitoring/api/learn_more#aggregation).
+message Aggregation {
+ // The Aligner describes how to bring the data points in a single
+ // time series into temporal alignment.
+ enum Aligner {
+ // No alignment. Raw data is returned. Not valid if cross-time
+ // series reduction is requested. The value type of the result is
+ // the same as the value type of the input.
+ ALIGN_NONE = 0;
+
+ // Align and convert to delta metric type. This alignment is valid
+ // for cumulative metrics and delta metrics. Aligning an existing
+ // delta metric to a delta metric requires that the alignment
+ // period be increased. The value type of the result is the same
+ // as the value type of the input.
+ //
+ // One can think of this aligner as a rate but without time units; that
+ // is, the output is conceptually (second_point - first_point).
+ ALIGN_DELTA = 1;
+
+ // Align and convert to a rate. This alignment is valid for
+ // cumulative metrics and delta metrics with numeric values. The output is a
+ // gauge metric with value type
+ // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE].
+ //
+ // One can think of this aligner as conceptually providing the slope of
+ // the line that passes through the value at the start and end of the
+ // window. In other words, this is conceptually ((y1 - y0)/(t1 - t0)),
+ // and the output unit is one that has a "/time" dimension.
+ //
+ // If, by rate, you are looking for percentage change, see the
+ // `ALIGN_PERCENT_CHANGE` aligner option.
+ ALIGN_RATE = 2;
+
+ // Align by interpolating between adjacent points around the
+ // period boundary. This alignment is valid for gauge
+ // metrics with numeric values. The value type of the result is the same
+ // as the value type of the input.
+ ALIGN_INTERPOLATE = 3;
+
+ // Align by shifting the oldest data point before the period
+ // boundary to the boundary. This alignment is valid for gauge
+ // metrics. The value type of the result is the same as the
+ // value type of the input.
+ ALIGN_NEXT_OLDER = 4;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the minimum of all data points in the
+ // period. This alignment is valid for gauge and delta metrics with numeric
+ // values. The value type of the result is the same as the value
+ // type of the input.
+ ALIGN_MIN = 10;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the maximum of all data points in the
+ // period. This alignment is valid for gauge and delta metrics with numeric
+ // values. The value type of the result is the same as the value
+ // type of the input.
+ ALIGN_MAX = 11;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the average or arithmetic mean of all
+ // data points in the period. This alignment is valid for gauge and delta
+ // metrics with numeric values. The value type of the output is
+ // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE].
+ ALIGN_MEAN = 12;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the count of all data points in the
+ // period. This alignment is valid for gauge and delta metrics with numeric
+ // or Boolean values. The value type of the output is
+ // [INT64][google.api.MetricDescriptor.ValueType.INT64].
+ ALIGN_COUNT = 13;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the sum of all data points in the
+ // period. This alignment is valid for gauge and delta metrics with numeric
+ // and distribution values. The value type of the output is the
+ // same as the value type of the input.
+ ALIGN_SUM = 14;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the standard deviation of all data
+ // points in the period. This alignment is valid for gauge and delta metrics
+ // with numeric values. The value type of the output is
+ // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE].
+ ALIGN_STDDEV = 15;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the count of True-valued data points in the
+ // period. This alignment is valid for gauge metrics with
+ // Boolean values. The value type of the output is
+ // [INT64][google.api.MetricDescriptor.ValueType.INT64].
+ ALIGN_COUNT_TRUE = 16;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the count of False-valued data points in the
+ // period. This alignment is valid for gauge metrics with
+ // Boolean values. The value type of the output is
+ // [INT64][google.api.MetricDescriptor.ValueType.INT64].
+ ALIGN_COUNT_FALSE = 24;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the fraction of True-valued data points in the
+ // period. This alignment is valid for gauge metrics with Boolean values.
+ // The output value is in the range [0, 1] and has value type
+ // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE].
+ ALIGN_FRACTION_TRUE = 17;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the 99th percentile of all data
+ // points in the period. This alignment is valid for gauge and delta metrics
+ // with distribution values. The output is a gauge metric with value type
+ // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE].
+ ALIGN_PERCENTILE_99 = 18;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the 95th percentile of all data
+ // points in the period. This alignment is valid for gauge and delta metrics
+ // with distribution values. The output is a gauge metric with value type
+ // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE].
+ ALIGN_PERCENTILE_95 = 19;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the 50th percentile of all data
+ // points in the period. This alignment is valid for gauge and delta metrics
+ // with distribution values. The output is a gauge metric with value type
+ // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE].
+ ALIGN_PERCENTILE_50 = 20;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the 5th percentile of all data
+ // points in the period. This alignment is valid for gauge and delta metrics
+ // with distribution values. The output is a gauge metric with value type
+ // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE].
+ ALIGN_PERCENTILE_05 = 21;
+
+ // Align and convert to a percentage change. This alignment is valid for
+ // gauge and delta metrics with numeric values. This alignment conceptually
+ // computes the equivalent of "((current - previous)/previous)*100"
+ // where previous value is determined based on the alignmentPeriod.
+ // In the event that previous is 0 the calculated value is infinity with the
+ // exception that if both (current - previous) and previous are 0 the
+ // calculated value is 0.
+ // A 10 minute moving mean is computed at each point of the time window
+ // prior to the above calculation to smooth the metric and prevent false
+ // positives from very short lived spikes.
+ // Only applicable for data that is >= 0. Any values < 0 are treated as
+ // no data. While delta metrics are accepted by this alignment special care
+ // should be taken that the values for the metric will always be positive.
+ // The output is a gauge metric with value type
+ // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE].
+ ALIGN_PERCENT_CHANGE = 23;
+ }
+
+ // A Reducer describes how to aggregate data points from multiple
+ // time series into a single time series.
+ enum Reducer {
+ // No cross-time series reduction. The output of the aligner is
+ // returned.
+ REDUCE_NONE = 0;
+
+ // Reduce by computing the mean across time series for each
+ // alignment period. This reducer is valid for delta and
+ // gauge metrics with numeric or distribution values. The value type of the
+ // output is [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE].
+ REDUCE_MEAN = 1;
+
+ // Reduce by computing the minimum across time series for each
+ // alignment period. This reducer is valid for delta and
+ // gauge metrics with numeric values. The value type of the output
+ // is the same as the value type of the input.
+ REDUCE_MIN = 2;
+
+ // Reduce by computing the maximum across time series for each
+ // alignment period. This reducer is valid for delta and
+ // gauge metrics with numeric values. The value type of the output
+ // is the same as the value type of the input.
+ REDUCE_MAX = 3;
+
+ // Reduce by computing the sum across time series for each
+ // alignment period. This reducer is valid for delta and
+ // gauge metrics with numeric and distribution values. The value type of
+ // the output is the same as the value type of the input.
+ REDUCE_SUM = 4;
+
+ // Reduce by computing the standard deviation across time series
+ // for each alignment period. This reducer is valid for delta
+ // and gauge metrics with numeric or distribution values. The value type of
+ // the output is [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE].
+ REDUCE_STDDEV = 5;
+
+ // Reduce by computing the count of data points across time series
+ // for each alignment period. This reducer is valid for delta
+ // and gauge metrics of numeric, Boolean, distribution, and string value
+ // type. The value type of the output is
+ // [INT64][google.api.MetricDescriptor.ValueType.INT64].
+ REDUCE_COUNT = 6;
+
+ // Reduce by computing the count of True-valued data points across time
+ // series for each alignment period. This reducer is valid for delta
+ // and gauge metrics of Boolean value type. The value type of
+ // the output is [INT64][google.api.MetricDescriptor.ValueType.INT64].
+ REDUCE_COUNT_TRUE = 7;
+
+ // Reduce by computing the count of False-valued data points across time
+ // series for each alignment period. This reducer is valid for delta
+ // and gauge metrics of Boolean value type. The value type of
+ // the output is [INT64][google.api.MetricDescriptor.ValueType.INT64].
+ REDUCE_COUNT_FALSE = 15;
+
+ // Reduce by computing the fraction of True-valued data points across time
+ // series for each alignment period. This reducer is valid for delta
+ // and gauge metrics of Boolean value type. The output value is in the
+ // range [0, 1] and has value type
+ // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE].
+ REDUCE_FRACTION_TRUE = 8;
+
+ // Reduce by computing 99th percentile of data points across time series
+ // for each alignment period. This reducer is valid for gauge and delta
+ // metrics of numeric and distribution type. The value of the output is
+ // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE]
+ REDUCE_PERCENTILE_99 = 9;
+
+ // Reduce by computing 95th percentile of data points across time series
+ // for each alignment period. This reducer is valid for gauge and delta
+ // metrics of numeric and distribution type. The value of the output is
+ // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE]
+ REDUCE_PERCENTILE_95 = 10;
+
+ // Reduce by computing 50th percentile of data points across time series
+ // for each alignment period. This reducer is valid for gauge and delta
+ // metrics of numeric and distribution type. The value of the output is
+ // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE]
+ REDUCE_PERCENTILE_50 = 11;
+
+ // Reduce by computing 5th percentile of data points across time series
+ // for each alignment period. This reducer is valid for gauge and delta
+ // metrics of numeric and distribution type. The value of the output is
+ // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE]
+ REDUCE_PERCENTILE_05 = 12;
+ }
+
+ // The alignment period for per-[time series][google.monitoring.v3.TimeSeries]
+ // alignment. If present, `alignmentPeriod` must be at least 60
+ // seconds. After per-time series alignment, each time series will
+ // contain data points only on the period boundaries. If
+ // `perSeriesAligner` is not specified or equals `ALIGN_NONE`, then
+ // this field is ignored. If `perSeriesAligner` is specified and
+ // does not equal `ALIGN_NONE`, then this field must be defined;
+ // otherwise an error is returned.
+ google.protobuf.Duration alignment_period = 1;
+
+ // The approach to be used to align individual time series. Not all
+ // alignment functions may be applied to all time series, depending
+ // on the metric type and value type of the original time
+ // series. Alignment may change the metric type or the value type of
+ // the time series.
+ //
+ // Time series data must be aligned in order to perform cross-time
+ // series reduction. If `crossSeriesReducer` is specified, then
+ // `perSeriesAligner` must be specified and not equal `ALIGN_NONE`
+ // and `alignmentPeriod` must be specified; otherwise, an error is
+ // returned.
+ Aligner per_series_aligner = 2;
+
+ // The approach to be used to combine time series. Not all reducer
+ // functions may be applied to all time series, depending on the
+ // metric type and the value type of the original time
+ // series. Reduction may change the metric type of value type of the
+ // time series.
+ //
+ // Time series data must be aligned in order to perform cross-time
+ // series reduction. If `crossSeriesReducer` is specified, then
+ // `perSeriesAligner` must be specified and not equal `ALIGN_NONE`
+ // and `alignmentPeriod` must be specified; otherwise, an error is
+ // returned.
+ Reducer cross_series_reducer = 4;
+
+ // The set of fields to preserve when `crossSeriesReducer` is
+ // specified. The `groupByFields` determine how the time series are
+ // partitioned into subsets prior to applying the aggregation
+ // function. Each subset contains time series that have the same
+ // value for each of the grouping fields. Each individual time
+ // series is a member of exactly one subset. The
+ // `crossSeriesReducer` is applied to each subset of time series.
+ // It is not possible to reduce across different resource types, so
+ // this field implicitly contains `resource.type`. Fields not
+ // specified in `groupByFields` are aggregated away. If
+ // `groupByFields` is not specified and all the time series have
+ // the same resource type, then the time series are aggregated into
+ // a single output time series. If `crossSeriesReducer` is not
+ // defined, this field is ignored.
+ repeated string group_by_fields = 5;
+}
+
+// Specifies an ordering relationship on two arguments, here called left and
+// right.
+enum ComparisonType {
+ // No ordering relationship is specified.
+ COMPARISON_UNSPECIFIED = 0;
+
+ // The left argument is greater than the right argument.
+ COMPARISON_GT = 1;
+
+ // The left argument is greater than or equal to the right argument.
+ COMPARISON_GE = 2;
+
+ // The left argument is less than the right argument.
+ COMPARISON_LT = 3;
+
+ // The left argument is less than or equal to the right argument.
+ COMPARISON_LE = 4;
+
+ // The left argument is equal to the right argument.
+ COMPARISON_EQ = 5;
+
+ // The left argument is not equal to the right argument.
+ COMPARISON_NE = 6;
+}
+
+// The tier of service for a Workspace. Please see the
+// [service tiers
+// documentation](https://cloud.google.com/monitoring/workspaces/tiers) for more
+// details.
+enum ServiceTier {
+ option deprecated = true;
+
+ // An invalid sentinel value, used to indicate that a tier has not
+ // been provided explicitly.
+ SERVICE_TIER_UNSPECIFIED = 0;
+
+ // The Stackdriver Basic tier, a free tier of service that provides basic
+ // features, a moderate allotment of logs, and access to built-in metrics.
+ // A number of features are not available in this tier. For more details,
+ // see [the service tiers
+ // documentation](https://cloud.google.com/monitoring/workspaces/tiers).
+ SERVICE_TIER_BASIC = 1;
+
+ // The Stackdriver Premium tier, a higher, more expensive tier of service
+ // that provides access to all Stackdriver features, lets you use Stackdriver
+ // with AWS accounts, and has a larger allotments for logs and metrics. For
+ // more details, see [the service tiers
+ // documentation](https://cloud.google.com/monitoring/workspaces/tiers).
+ SERVICE_TIER_PREMIUM = 2;
+}

protos/google/monitoring/v3/dropped_labels.proto

@@ -0,0 +1,42 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.monitoring.v3;
+
+import "google/api/annotations.proto";
+
+option go_package = "google.golang.org/genproto/googleapis/monitoring/v3;monitoring";
+
+// A set of (label, value) pairs which were dropped during aggregation, attached
+// to google.api.Distribution.Exemplars in google.api.Distribution values during
+// aggregation.
+//
+// These values are used in combination with the label values that remain on the
+// aggregated Distribution timeseries to construct the full label set for the
+// exemplar values. The resulting full label set may be used to identify the
+// specific task/job/instance (for example) which may be contributing to a
+// long-tail, while allowing the storage savings of only storing aggregated
+// distribution values for a large group.
+//
+// Note that there are no guarantees on ordering of the labels from
+// exemplar-to-exemplar and from distribution-to-distribution in the same
+// stream, and there may be duplicates. It is up to clients to resolve any
+// ambiguities.
+message DroppedLabels {
+ // Map from label to its value, for all labels dropped in any aggregation.
+ map<string, string> label = 1;
+}

protos/google/monitoring/v3/group.proto

@@ -0,0 +1,76 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.monitoring.v3;
+
+option csharp_namespace = "Google.Cloud.Monitoring.V3";
+option go_package = "google.golang.org/genproto/googleapis/monitoring/v3;monitoring";
+option java_multiple_files = true;
+option java_outer_classname = "GroupProto";
+option java_package = "com.google.monitoring.v3";
+option php_namespace = "Google\\Cloud\\Monitoring\\V3";
+
+// The description of a dynamic collection of monitored resources. Each group
+// has a filter that is matched against monitored resources and their associated
+// metadata. If a group's filter matches an available monitored resource, then
+// that resource is a member of that group. Groups can contain any number of
+// monitored resources, and each monitored resource can be a member of any
+// number of groups.
+//
+// Groups can be nested in parent-child hierarchies. The `parentName` field
+// identifies an optional parent for each group. If a group has a parent, then
+// the only monitored resources available to be matched by the group's filter
+// are the resources contained in the parent group. In other words, a group
+// contains the monitored resources that match its filter and the filters of all
+// the group's ancestors. A group without a parent can contain any monitored
+// resource.
+//
+// For example, consider an infrastructure running a set of instances with two
+// user-defined tags: `"environment"` and `"role"`. A parent group has a filter,
+// `environment="production"`. A child of that parent group has a filter,
+// `role="transcoder"`. The parent group contains all instances in the
+// production environment, regardless of their roles. The child group contains
+// instances that have the transcoder role *and* are in the production
+// environment.
+//
+// The monitored resources contained in a group can change at any moment,
+// depending on what resources exist and what filters are associated with the
+// group and its ancestors.
+message Group {
+ // Output only. The name of this group. The format is
+ // `"projects/{project_id_or_number}/groups/{group_id}"`.
+ // When creating a group, this field is ignored and a new name is created
+ // consisting of the project specified in the call to `CreateGroup`
+ // and a unique `{group_id}` that is generated automatically.
+ string name = 1;
+
+ // A user-assigned name for this group, used only for display purposes.
+ string display_name = 2;
+
+ // The name of the group's parent, if it has one.
+ // The format is `"projects/{project_id_or_number}/groups/{group_id}"`.
+ // For groups with no parent, `parentName` is the empty string, `""`.
+ string parent_name = 3;
+
+ // The filter used to determine which monitored resources belong to this
+ // group.
+ string filter = 5;
+
+ // If true, the members of this group are considered to be a cluster.
+ // The system can perform additional analysis on groups that are clusters.
+ bool is_cluster = 6;
+}

protos/google/monitoring/v3/group_service.proto

@@ -0,0 +1,222 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.monitoring.v3;
+
+import "google/api/annotations.proto";
+import "google/api/monitored_resource.proto";
+import "google/monitoring/v3/common.proto";
+import "google/monitoring/v3/group.proto";
+import "google/protobuf/empty.proto";
+
+option csharp_namespace = "Google.Cloud.Monitoring.V3";
+option go_package = "google.golang.org/genproto/googleapis/monitoring/v3;monitoring";
+option java_multiple_files = true;
+option java_outer_classname = "GroupServiceProto";
+option java_package = "com.google.monitoring.v3";
+option php_namespace = "Google\\Cloud\\Monitoring\\V3";
+
+// The Group API lets you inspect and manage your
+// [groups](#google.monitoring.v3.Group).
+//
+// A group is a named filter that is used to identify
+// a collection of monitored resources. Groups are typically used to
+// mirror the physical and/or logical topology of the environment.
+// Because group membership is computed dynamically, monitored
+// resources that are started in the future are automatically placed
+// in matching groups. By using a group to name monitored resources in,
+// for example, an alert policy, the target of that alert policy is
+// updated automatically as monitored resources are added and removed
+// from the infrastructure.
+service GroupService {
+ // Lists the existing groups.
+ rpc ListGroups(ListGroupsRequest) returns (ListGroupsResponse) {
+ option (google.api.http) = {
+ get: "/v3/{name=projects/*}/groups"
+ };
+ }
+
+ // Gets a single group.
+ rpc GetGroup(GetGroupRequest) returns (Group) {
+ option (google.api.http) = {
+ get: "/v3/{name=projects/*/groups/*}"
+ };
+ }
+
+ // Creates a new group.
+ rpc CreateGroup(CreateGroupRequest) returns (Group) {
+ option (google.api.http) = {
+ post: "/v3/{name=projects/*}/groups"
+ body: "group"
+ };
+ }
+
+ // Updates an existing group.
+ // You can change any group attributes except `name`.
+ rpc UpdateGroup(UpdateGroupRequest) returns (Group) {
+ option (google.api.http) = {
+ put: "/v3/{group.name=projects/*/groups/*}"
+ body: "group"
+ };
+ }
+
+ // Deletes an existing group.
+ rpc DeleteGroup(DeleteGroupRequest) returns (google.protobuf.Empty) {
+ option (google.api.http) = {
+ delete: "/v3/{name=projects/*/groups/*}"
+ };
+ }
+
+ // Lists the monitored resources that are members of a group.
+ rpc ListGroupMembers(ListGroupMembersRequest)
+ returns (ListGroupMembersResponse) {
+ option (google.api.http) = {
+ get: "/v3/{name=projects/*/groups/*}/members"
+ };
+ }
+}
+
+// The `ListGroup` request.
+message ListGroupsRequest {
+ // The project whose groups are to be listed. The format is
+ // `"projects/{project_id_or_number}"`.
+ string name = 7;
+
+ // An optional filter consisting of a single group name. The filters limit
+ // the groups returned based on their parent-child relationship with the
+ // specified group. If no filter is specified, all groups are returned.
+ oneof filter {
+ // A group name: `"projects/{project_id_or_number}/groups/{group_id}"`.
+ // Returns groups whose `parentName` field contains the group
+ // name. If no groups have this parent, the results are empty.
+ string children_of_group = 2;
+
+ // A group name: `"projects/{project_id_or_number}/groups/{group_id}"`.
+ // Returns groups that are ancestors of the specified group.
+ // The groups are returned in order, starting with the immediate parent and
+ // ending with the most distant ancestor. If the specified group has no
+ // immediate parent, the results are empty.
+ string ancestors_of_group = 3;
+
+ // A group name: `"projects/{project_id_or_number}/groups/{group_id}"`.
+ // Returns the descendants of the specified group. This is a superset of
+ // the results returned by the `childrenOfGroup` filter, and includes
+ // children-of-children, and so forth.
+ string descendants_of_group = 4;
+ }
+
+ // A positive number that is the maximum number of results to return.
+ int32 page_size = 5;
+
+ // If this field is not empty then it must contain the `nextPageToken` value
+ // returned by a previous call to this method. Using this field causes the
+ // method to return additional results from the previous method call.
+ string page_token = 6;
+}
+
+// The `ListGroups` response.
+message ListGroupsResponse {
+ // The groups that match the specified filters.
+ repeated Group group = 1;
+
+ // If there are more results than have been returned, then this field is set
+ // to a non-empty value. To see the additional results,
+ // use that value as `pageToken` in the next call to this method.
+ string next_page_token = 2;
+}
+
+// The `GetGroup` request.
+message GetGroupRequest {
+ // The group to retrieve. The format is
+ // `"projects/{project_id_or_number}/groups/{group_id}"`.
+ string name = 3;
+}
+
+// The `CreateGroup` request.
+message CreateGroupRequest {
+ // The project in which to create the group. The format is
+ // `"projects/{project_id_or_number}"`.
+ string name = 4;
+
+ // A group definition. It is an error to define the `name` field because
+ // the system assigns the name.
+ Group group = 2;
+
+ // If true, validate this request but do not create the group.
+ bool validate_only = 3;
+}
+
+// The `UpdateGroup` request.
+message UpdateGroupRequest {
+ // The new definition of the group. All fields of the existing group,
+ // excepting `name`, are replaced with the corresponding fields of this group.
+ Group group = 2;
+
+ // If true, validate this request but do not update the existing group.
+ bool validate_only = 3;
+}
+
+// The `DeleteGroup` request. You can only delete a group if it has no children.
+message DeleteGroupRequest {
+ // The group to delete. The format is
+ // `"projects/{project_id_or_number}/groups/{group_id}"`.
+ string name = 3;
+}
+
+// The `ListGroupMembers` request.
+message ListGroupMembersRequest {
+ // The group whose members are listed. The format is
+ // `"projects/{project_id_or_number}/groups/{group_id}"`.
+ string name = 7;
+
+ // A positive number that is the maximum number of results to return.
+ int32 page_size = 3;
+
+ // If this field is not empty then it must contain the `nextPageToken` value
+ // returned by a previous call to this method. Using this field causes the
+ // method to return additional results from the previous method call.
+ string page_token = 4;
+
+ // An optional [list filter](/monitoring/api/learn_more#filtering) describing
+ // the members to be returned. The filter may reference the type, labels, and
+ // metadata of monitored resources that comprise the group.
+ // For example, to return only resources representing Compute Engine VM
+ // instances, use this filter:
+ //
+ // resource.type = "gce_instance"
+ string filter = 5;
+
+ // An optional time interval for which results should be returned. Only
+ // members that were part of the group during the specified interval are
+ // included in the response. If no interval is provided then the group
+ // membership over the last minute is returned.
+ TimeInterval interval = 6;
+}
+
+// The `ListGroupMembers` response.
+message ListGroupMembersResponse {
+ // A set of monitored resources in the group.
+ repeated google.api.MonitoredResource members = 1;
+
+ // If there are more results than have been returned, then this field is
+ // set to a non-empty value. To see the additional results, use that value as
+ // `pageToken` in the next call to this method.
+ string next_page_token = 2;
+
+ // The total number of elements matching this request.
+ int32 total_size = 3;
+}

protos/google/monitoring/v3/metric.proto

@@ -0,0 +1,95 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.monitoring.v3;
+
+import "google/api/annotations.proto";
+import "google/api/label.proto";
+import "google/api/metric.proto";
+import "google/api/monitored_resource.proto";
+import "google/monitoring/v3/common.proto";
+
+option csharp_namespace = "Google.Cloud.Monitoring.V3";
+option go_package = "google.golang.org/genproto/googleapis/monitoring/v3;monitoring";
+option java_multiple_files = true;
+option java_outer_classname = "MetricProto";
+option java_package = "com.google.monitoring.v3";
+option php_namespace = "Google\\Cloud\\Monitoring\\V3";
+
+// A single data point in a time series.
+message Point {
+ // The time interval to which the data point applies. For `GAUGE` metrics,
+ // only the end time of the interval is used. For `DELTA` metrics, the start
+ // and end time should specify a non-zero interval, with subsequent points
+ // specifying contiguous and non-overlapping intervals. For `CUMULATIVE`
+ // metrics, the start and end time should specify a non-zero interval, with
+ // subsequent points specifying the same start time and increasing end times,
+ // until an event resets the cumulative value to zero and sets a new start
+ // time for the following points.
+ TimeInterval interval = 1;
+
+ // The value of the data point.
+ TypedValue value = 2;
+}
+
+// A collection of data points that describes the time-varying values
+// of a metric. A time series is identified by a combination of a
+// fully-specified monitored resource and a fully-specified metric.
+// This type is used for both listing and creating time series.
+message TimeSeries {
+ // The associated metric. A fully-specified metric used to identify the time
+ // series.
+ google.api.Metric metric = 1;
+
+ // The associated monitored resource. Custom metrics can use only certain
+ // monitored resource types in their time series data.
+ google.api.MonitoredResource resource = 2;
+
+ // Output only. The associated monitored resource metadata. When reading a
+ // a timeseries, this field will include metadata labels that are explicitly
+ // named in the reduction. When creating a timeseries, this field is ignored.
+ google.api.MonitoredResourceMetadata metadata = 7;
+
+ // The metric kind of the time series. When listing time series, this metric
+ // kind might be different from the metric kind of the associated metric if
+ // this time series is an alignment or reduction of other time series.
+ //
+ // When creating a time series, this field is optional. If present, it must be
+ // the same as the metric kind of the associated metric. If the associated
+ // metric's descriptor must be auto-created, then this field specifies the
+ // metric kind of the new descriptor and must be either `GAUGE` (the default)
+ // or `CUMULATIVE`.
+ google.api.MetricDescriptor.MetricKind metric_kind = 3;
+
+ // The value type of the time series. When listing time series, this value
+ // type might be different from the value type of the associated metric if
+ // this time series is an alignment or reduction of other time series.
+ //
+ // When creating a time series, this field is optional. If present, it must be
+ // the same as the type of the data in the `points` field.
+ google.api.MetricDescriptor.ValueType value_type = 4;
+
+ // The data points of this time series. When listing time series, points are
+ // returned in reverse time order.
+ //
+ // When creating a time series, this field must contain exactly one point and
+ // the point's type must be the same as the value type of the associated
+ // metric. If the associated metric's descriptor must be auto-created, then
+ // the value type of the descriptor is determined by the point's type, which
+ // must be `BOOL`, `INT64`, `DOUBLE`, or `DISTRIBUTION`.
+ repeated Point points = 5;
+}

protos/google/monitoring/v3/metric_service.proto

@@ -0,0 +1,322 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.monitoring.v3;
+
+import "google/api/annotations.proto";
+import "google/api/metric.proto";
+import "google/api/monitored_resource.proto";
+import "google/monitoring/v3/common.proto";
+import "google/monitoring/v3/metric.proto";
+import "google/protobuf/duration.proto";
+import "google/protobuf/empty.proto";
+import "google/rpc/status.proto";
+
+option csharp_namespace = "Google.Cloud.Monitoring.V3";
+option go_package = "google.golang.org/genproto/googleapis/monitoring/v3;monitoring";
+option java_multiple_files = true;
+option java_outer_classname = "MetricServiceProto";
+option java_package = "com.google.monitoring.v3";
+option php_namespace = "Google\\Cloud\\Monitoring\\V3";
+
+// Manages metric descriptors, monitored resource descriptors, and
+// time series data.
+service MetricService {
+ // Lists monitored resource descriptors that match a filter. This method does
+ // not require a Stackdriver account.
+ rpc ListMonitoredResourceDescriptors(ListMonitoredResourceDescriptorsRequest)
+ returns (ListMonitoredResourceDescriptorsResponse) {
+ option (google.api.http) = {
+ get: "/v3/{name=projects/*}/monitoredResourceDescriptors"
+ };
+ }
+
+ // Gets a single monitored resource descriptor. This method does not require a
+ // Stackdriver account.
+ rpc GetMonitoredResourceDescriptor(GetMonitoredResourceDescriptorRequest)
+ returns (google.api.MonitoredResourceDescriptor) {
+ option (google.api.http) = {
+ get: "/v3/{name=projects/*/monitoredResourceDescriptors/*}"
+ };
+ }
+
+ // Lists metric descriptors that match a filter. This method does not require
+ // a Stackdriver account.
+ rpc ListMetricDescriptors(ListMetricDescriptorsRequest)
+ returns (ListMetricDescriptorsResponse) {
+ option (google.api.http) = {
+ get: "/v3/{name=projects/*}/metricDescriptors"
+ };
+ }
+
+ // Gets a single metric descriptor. This method does not require a Stackdriver
+ // account.
+ rpc GetMetricDescriptor(GetMetricDescriptorRequest)
+ returns (google.api.MetricDescriptor) {
+ option (google.api.http) = {
+ get: "/v3/{name=projects/*/metricDescriptors/**}"
+ };
+ }
+
+ // Creates a new metric descriptor.
+ // User-created metric descriptors define
+ // [custom metrics](/monitoring/custom-metrics).
+ rpc CreateMetricDescriptor(CreateMetricDescriptorRequest)
+ returns (google.api.MetricDescriptor) {
+ option (google.api.http) = {
+ post: "/v3/{name=projects/*}/metricDescriptors"
+ body: "metric_descriptor"
+ };
+ }
+
+ // Deletes a metric descriptor. Only user-created
+ // [custom metrics](/monitoring/custom-metrics) can be deleted.
+ rpc DeleteMetricDescriptor(DeleteMetricDescriptorRequest)
+ returns (google.protobuf.Empty) {
+ option (google.api.http) = {
+ delete: "/v3/{name=projects/*/metricDescriptors/**}"
+ };
+ }
+
+ // Lists time series that match a filter. This method does not require a
+ // Stackdriver account.
+ rpc ListTimeSeries(ListTimeSeriesRequest) returns (ListTimeSeriesResponse) {
+ option (google.api.http) = {
+ get: "/v3/{name=projects/*}/timeSeries"
+ };
+ }
+
+ // Creates or adds data to one or more time series.
+ // The response is empty if all time series in the request were written.
+ // If any time series could not be written, a corresponding failure message is
+ // included in the error response.
+ rpc CreateTimeSeries(CreateTimeSeriesRequest)
+ returns (google.protobuf.Empty) {
+ option (google.api.http) = {
+ post: "/v3/{name=projects/*}/timeSeries"
+ body: "*"
+ };
+ }
+}
+
+// The `ListMonitoredResourceDescriptors` request.
+message ListMonitoredResourceDescriptorsRequest {
+ // The project on which to execute the request. The format is
+ // `"projects/{project_id_or_number}"`.
+ string name = 5;
+
+ // An optional [filter](/monitoring/api/v3/filters) describing
+ // the descriptors to be returned. The filter can reference
+ // the descriptor's type and labels. For example, the
+ // following filter returns only Google Compute Engine descriptors
+ // that have an `id` label:
+ //
+ // resource.type = starts_with("gce_") AND resource.label:id
+ string filter = 2;
+
+ // A positive number that is the maximum number of results to return.
+ int32 page_size = 3;
+
+ // If this field is not empty then it must contain the `nextPageToken` value
+ // returned by a previous call to this method. Using this field causes the
+ // method to return additional results from the previous method call.
+ string page_token = 4;
+}
+
+// The `ListMonitoredResourceDescriptors` response.
+message ListMonitoredResourceDescriptorsResponse {
+ // The monitored resource descriptors that are available to this project
+ // and that match `filter`, if present.
+ repeated google.api.MonitoredResourceDescriptor resource_descriptors = 1;
+
+ // If there are more results than have been returned, then this field is set
+ // to a non-empty value. To see the additional results,
+ // use that value as `pageToken` in the next call to this method.
+ string next_page_token = 2;
+}
+
+// The `GetMonitoredResourceDescriptor` request.
+message GetMonitoredResourceDescriptorRequest {
+ // The monitored resource descriptor to get. The format is
+ // `"projects/{project_id_or_number}/monitoredResourceDescriptors/{resource_type}"`.
+ // The `{resource_type}` is a predefined type, such as
+ // `cloudsql_database`.
+ string name = 3;
+}
+
+// The `ListMetricDescriptors` request.
+message ListMetricDescriptorsRequest {
+ // The project on which to execute the request. The format is
+ // `"projects/{project_id_or_number}"`.
+ string name = 5;
+
+ // If this field is empty, all custom and
+ // system-defined metric descriptors are returned.
+ // Otherwise, the [filter](/monitoring/api/v3/filters)
+ // specifies which metric descriptors are to be
+ // returned. For example, the following filter matches all
+ // [custom metrics](/monitoring/custom-metrics):
+ //
+ // metric.type = starts_with("custom.googleapis.com/")
+ string filter = 2;
+
+ // A positive number that is the maximum number of results to return.
+ int32 page_size = 3;
+
+ // If this field is not empty then it must contain the `nextPageToken` value
+ // returned by a previous call to this method. Using this field causes the
+ // method to return additional results from the previous method call.
+ string page_token = 4;
+}
+
+// The `ListMetricDescriptors` response.
+message ListMetricDescriptorsResponse {
+ // The metric descriptors that are available to the project
+ // and that match the value of `filter`, if present.
+ repeated google.api.MetricDescriptor metric_descriptors = 1;
+
+ // If there are more results than have been returned, then this field is set
+ // to a non-empty value. To see the additional results,
+ // use that value as `pageToken` in the next call to this method.
+ string next_page_token = 2;
+}
+
+// The `GetMetricDescriptor` request.
+message GetMetricDescriptorRequest {
+ // The metric descriptor on which to execute the request. The format is
+ // `"projects/{project_id_or_number}/metricDescriptors/{metric_id}"`.
+ // An example value of `{metric_id}` is
+ // `"compute.googleapis.com/instance/disk/read_bytes_count"`.
+ string name = 3;
+}
+
+// The `CreateMetricDescriptor` request.
+message CreateMetricDescriptorRequest {
+ // The project on which to execute the request. The format is
+ // `"projects/{project_id_or_number}"`.
+ string name = 3;
+
+ // The new [custom metric](/monitoring/custom-metrics)
+ // descriptor.
+ google.api.MetricDescriptor metric_descriptor = 2;
+}
+
+// The `DeleteMetricDescriptor` request.
+message DeleteMetricDescriptorRequest {
+ // The metric descriptor on which to execute the request. The format is
+ // `"projects/{project_id_or_number}/metricDescriptors/{metric_id}"`.
+ // An example of `{metric_id}` is:
+ // `"custom.googleapis.com/my_test_metric"`.
+ string name = 3;
+}
+
+// The `ListTimeSeries` request.
+message ListTimeSeriesRequest {
+ // Controls which fields are returned by `ListTimeSeries`.
+ enum TimeSeriesView {
+ // Returns the identity of the metric(s), the time series,
+ // and the time series data.
+ FULL = 0;
+
+ // Returns the identity of the metric and the time series resource,
+ // but not the time series data.
+ HEADERS = 1;
+ }
+
+ // The project on which to execute the request. The format is
+ // "projects/{project_id_or_number}".
+ string name = 10;
+
+ // A [monitoring filter](/monitoring/api/v3/filters) that specifies which time
+ // series should be returned. The filter must specify a single metric type,
+ // and can additionally specify metric labels and other information. For
+ // example:
+ //
+ // metric.type = "compute.googleapis.com/instance/cpu/usage_time" AND
+ // metric.label.instance_name = "my-instance-name"
+ string filter = 2;
+
+ // The time interval for which results should be returned. Only time series
+ // that contain data points in the specified interval are included
+ // in the response.
+ TimeInterval interval = 4;
+
+ // By default, the raw time series data is returned.
+ // Use this field to combine multiple time series for different
+ // views of the data.
+ Aggregation aggregation = 5;
+
+ // Unsupported: must be left blank. The points in each time series are
+ // returned in reverse time order.
+ string order_by = 6;
+
+ // Specifies which information is returned about the time series.
+ TimeSeriesView view = 7;
+
+ // A positive number that is the maximum number of results to return. If
+ // `page_size` is empty or more than 100,000 results, the effective
+ // `page_size` is 100,000 results. If `view` is set to `FULL`, this is the
+ // maximum number of `Points` returned. If `view` is set to `HEADERS`, this is
+ // the maximum number of `TimeSeries` returned.
+ int32 page_size = 8;
+
+ // If this field is not empty then it must contain the `nextPageToken` value
+ // returned by a previous call to this method. Using this field causes the
+ // method to return additional results from the previous method call.
+ string page_token = 9;
+}
+
+// The `ListTimeSeries` response.
+message ListTimeSeriesResponse {
+ // One or more time series that match the filter included in the request.
+ repeated TimeSeries time_series = 1;
+
+ // If there are more results than have been returned, then this field is set
+ // to a non-empty value. To see the additional results,
+ // use that value as `pageToken` in the next call to this method.
+ string next_page_token = 2;
+
+ // Query execution errors that may have caused the time series data returned
+ // to be incomplete.
+ repeated google.rpc.Status execution_errors = 3;
+}
+
+// The `CreateTimeSeries` request.
+message CreateTimeSeriesRequest {
+ // The project on which to execute the request. The format is
+ // `"projects/{project_id_or_number}"`.
+ string name = 3;
+
+ // The new data to be added to a list of time series.
+ // Adds at most one data point to each of several time series. The new data
+ // point must be more recent than any other point in its time series. Each
+ // `TimeSeries` value must fully specify a unique time series by supplying
+ // all label values for the metric and the monitored resource.
+ repeated TimeSeries time_series = 2;
+}
+
+// Describes the result of a failed request to write data to a time series.
+message CreateTimeSeriesError {
+ // The time series, including the `Metric`, `MonitoredResource`,
+ // and `Point`s (including timestamp and value) that resulted
+ // in the error. This field provides all of the context that
+ // would be needed to retry the operation.
+ TimeSeries time_series = 1;
+
+ // The status of the requested write operation.
+ google.rpc.Status status = 2;
+}

protos/google/monitoring/v3/mutation_record.proto

@@ -0,0 +1,36 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.monitoring.v3;
+
+import "google/protobuf/timestamp.proto";
+
+option csharp_namespace = "Google.Cloud.Monitoring.V3";
+option go_package = "google.golang.org/genproto/googleapis/monitoring/v3;monitoring";
+option java_multiple_files = true;
+option java_outer_classname = "MutationRecordProto";
+option java_package = "com.google.monitoring.v3";
+option php_namespace = "Google\\Cloud\\Monitoring\\V3";
+
+// Describes a change made to a configuration.
+message MutationRecord {
+ // When the change occurred.
+ google.protobuf.Timestamp mutate_time = 1;
+
+ // The email address of the user making the change.
+ string mutated_by = 2;
+}

protos/google/monitoring/v3/notification.proto

@@ -0,0 +1,165 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.monitoring.v3;
+
+import "google/api/annotations.proto";
+import "google/api/label.proto";
+import "google/monitoring/v3/common.proto";
+import "google/protobuf/wrappers.proto";
+
+option csharp_namespace = "Google.Cloud.Monitoring.V3";
+option go_package = "google.golang.org/genproto/googleapis/monitoring/v3;monitoring";
+option java_multiple_files = true;
+option java_outer_classname = "NotificationProto";
+option java_package = "com.google.monitoring.v3";
+option php_namespace = "Google\\Cloud\\Monitoring\\V3";
+
+// A description of a notification channel. The descriptor includes
+// the properties of the channel and the set of labels or fields that
+// must be specified to configure channels of a given type.
+message NotificationChannelDescriptor {
+ // The full REST resource name for this descriptor. The syntax is:
+ //
+ // projects/[PROJECT_ID]/notificationChannelDescriptors/[TYPE]
+ //
+ // In the above, `[TYPE]` is the value of the `type` field.
+ string name = 6;
+
+ // The type of notification channel, such as "email", "sms", etc.
+ // Notification channel types are globally unique.
+ string type = 1;
+
+ // A human-readable name for the notification channel type. This
+ // form of the name is suitable for a user interface.
+ string display_name = 2;
+
+ // A human-readable description of the notification channel
+ // type. The description may include a description of the properties
+ // of the channel and pointers to external documentation.
+ string description = 3;
+
+ // The set of labels that must be defined to identify a particular
+ // channel of the corresponding type. Each label includes a
+ // description for how that field should be populated.
+ repeated google.api.LabelDescriptor labels = 4;
+
+ // The tiers that support this notification channel; the project service tier
+ // must be one of the supported_tiers.
+ repeated ServiceTier supported_tiers = 5 [deprecated = true];
+}
+
+// A `NotificationChannel` is a medium through which an alert is
+// delivered when a policy violation is detected. Examples of channels
+// include email, SMS, and third-party messaging applications. Fields
+// containing sensitive information like authentication tokens or
+// contact info are only partially populated on retrieval.
+message NotificationChannel {
+ // Indicates whether the channel has been verified or not. It is illegal
+ // to specify this field in a
+ // [`CreateNotificationChannel`][google.monitoring.v3.NotificationChannelService.CreateNotificationChannel]
+ // or an
+ // [`UpdateNotificationChannel`][google.monitoring.v3.NotificationChannelService.UpdateNotificationChannel]
+ // operation.
+ enum VerificationStatus {
+ // Sentinel value used to indicate that the state is unknown, omitted, or
+ // is not applicable (as in the case of channels that neither support
+ // nor require verification in order to function).
+ VERIFICATION_STATUS_UNSPECIFIED = 0;
+
+ // The channel has yet to be verified and requires verification to function.
+ // Note that this state also applies to the case where the verification
+ // process has been initiated by sending a verification code but where
+ // the verification code has not been submitted to complete the process.
+ UNVERIFIED = 1;
+
+ // It has been proven that notifications can be received on this
+ // notification channel and that someone on the project has access
+ // to messages that are delivered to that channel.
+ VERIFIED = 2;
+ }
+
+ // The type of the notification channel. This field matches the
+ // value of the
+ // [NotificationChannelDescriptor.type][google.monitoring.v3.NotificationChannelDescriptor.type]
+ // field.
+ string type = 1;
+
+ // The full REST resource name for this channel. The syntax is:
+ //
+ // projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]
+ //
+ // The `[CHANNEL_ID]` is automatically assigned by the server on creation.
+ string name = 6;
+
+ // An optional human-readable name for this notification channel. It is
+ // recommended that you specify a non-empty and unique name in order to
+ // make it easier to identify the channels in your project, though this is
+ // not enforced. The display name is limited to 512 Unicode characters.
+ string display_name = 3;
+
+ // An optional human-readable description of this notification channel. This
+ // description may provide additional details, beyond the display
+ // name, for the channel. This may not exceeed 1024 Unicode characters.
+ string description = 4;
+
+ // Configuration fields that define the channel and its behavior. The
+ // permissible and required labels are specified in the
+ // [NotificationChannelDescriptor.labels][google.monitoring.v3.NotificationChannelDescriptor.labels]
+ // of the `NotificationChannelDescriptor` corresponding to the `type` field.
+ map<string, string> labels = 5;
+
+ // User-supplied key/value data that does not need to conform to
+ // the corresponding `NotificationChannelDescriptor`'s schema, unlike
+ // the `labels` field. This field is intended to be used for organizing
+ // and identifying the `NotificationChannel` objects.
+ //
+ // The field can contain up to 64 entries. Each key and value is limited to
+ // 63 Unicode characters or 128 bytes, whichever is smaller. Labels and
+ // values can contain only lowercase letters, numerals, underscores, and
+ // dashes. Keys must begin with a letter.
+ map<string, string> user_labels = 8;
+
+ // Indicates whether this channel has been verified or not. On a
+ // [`ListNotificationChannels`][google.monitoring.v3.NotificationChannelService.ListNotificationChannels]
+ // or
+ // [`GetNotificationChannel`][google.monitoring.v3.NotificationChannelService.GetNotificationChannel]
+ // operation, this field is expected to be populated.
+ //
+ // If the value is `UNVERIFIED`, then it indicates that the channel is
+ // non-functioning (it both requires verification and lacks verification);
+ // otherwise, it is assumed that the channel works.
+ //
+ // If the channel is neither `VERIFIED` nor `UNVERIFIED`, it implies that
+ // the channel is of a type that does not require verification or that
+ // this specific channel has been exempted from verification because it was
+ // created prior to verification being required for channels of this type.
+ //
+ // This field cannot be modified using a standard
+ // [`UpdateNotificationChannel`][google.monitoring.v3.NotificationChannelService.UpdateNotificationChannel]
+ // operation. To change the value of this field, you must call
+ // [`VerifyNotificationChannel`][google.monitoring.v3.NotificationChannelService.VerifyNotificationChannel].
+ VerificationStatus verification_status = 9;
+
+ // Whether notifications are forwarded to the described channel. This makes
+ // it possible to disable delivery of notifications to a particular channel
+ // without removing the channel from all alerting policies that reference
+ // the channel. This is a more convenient approach when the change is
+ // temporary and you want to receive notifications from the same set
+ // of alerting policies on the channel at some point in the future.
+ google.protobuf.BoolValue enabled = 11;
+}

protos/google/monitoring/v3/notification_service.proto

@@ -0,0 +1,350 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.monitoring.v3;
+
+import "google/api/annotations.proto";
+import "google/monitoring/v3/notification.proto";
+import "google/protobuf/empty.proto";
+import "google/protobuf/field_mask.proto";
+import "google/protobuf/struct.proto";
+import "google/protobuf/timestamp.proto";
+
+option csharp_namespace = "Google.Cloud.Monitoring.V3";
+option go_package = "google.golang.org/genproto/googleapis/monitoring/v3;monitoring";
+option java_multiple_files = true;
+option java_outer_classname = "NotificationServiceProto";
+option java_package = "com.google.monitoring.v3";
+option php_namespace = "Google\\Cloud\\Monitoring\\V3";
+
+// The Notification Channel API provides access to configuration that
+// controls how messages related to incidents are sent.
+service NotificationChannelService {
+ // Lists the descriptors for supported channel types. The use of descriptors
+ // makes it possible for new channel types to be dynamically added.
+ rpc ListNotificationChannelDescriptors(
+ ListNotificationChannelDescriptorsRequest)
+ returns (ListNotificationChannelDescriptorsResponse) {
+ option (google.api.http) = {
+ get: "/v3/{name=projects/*}/notificationChannelDescriptors"
+ };
+ }
+
+ // Gets a single channel descriptor. The descriptor indicates which fields
+ // are expected / permitted for a notification channel of the given type.
+ rpc GetNotificationChannelDescriptor(GetNotificationChannelDescriptorRequest)
+ returns (NotificationChannelDescriptor) {
+ option (google.api.http) = {
+ get: "/v3/{name=projects/*/notificationChannelDescriptors/*}"
+ };
+ }
+
+ // Lists the notification channels that have been created for the project.
+ rpc ListNotificationChannels(ListNotificationChannelsRequest)
+ returns (ListNotificationChannelsResponse) {
+ option (google.api.http) = {
+ get: "/v3/{name=projects/*}/notificationChannels"
+ };
+ }
+
+ // Gets a single notification channel. The channel includes the relevant
+ // configuration details with which the channel was created. However, the
+ // response may truncate or omit passwords, API keys, or other private key
+ // matter and thus the response may not be 100% identical to the information
+ // that was supplied in the call to the create method.
+ rpc GetNotificationChannel(GetNotificationChannelRequest)
+ returns (NotificationChannel) {
+ option (google.api.http) = {
+ get: "/v3/{name=projects/*/notificationChannels/*}"
+ };
+ }
+
+ // Creates a new notification channel, representing a single notification
+ // endpoint such as an email address, SMS number, or PagerDuty service.
+ rpc CreateNotificationChannel(CreateNotificationChannelRequest)
+ returns (NotificationChannel) {
+ option (google.api.http) = {
+ post: "/v3/{name=projects/*}/notificationChannels"
+ body: "notification_channel"
+ };
+ }
+
+ // Updates a notification channel. Fields not specified in the field mask
+ // remain unchanged.
+ rpc UpdateNotificationChannel(UpdateNotificationChannelRequest)
+ returns (NotificationChannel) {
+ option (google.api.http) = {
+ patch: "/v3/{notification_channel.name=projects/*/notificationChannels/*}"
+ body: "notification_channel"
+ };
+ }
+
+ // Deletes a notification channel.
+ rpc DeleteNotificationChannel(DeleteNotificationChannelRequest)
+ returns (google.protobuf.Empty) {
+ option (google.api.http) = {
+ delete: "/v3/{name=projects/*/notificationChannels/*}"
+ };
+ }
+
+ // Causes a verification code to be delivered to the channel. The code
+ // can then be supplied in `VerifyNotificationChannel` to verify the channel.
+ rpc SendNotificationChannelVerificationCode(
+ SendNotificationChannelVerificationCodeRequest)
+ returns (google.protobuf.Empty) {
+ option (google.api.http) = {
+ post: "/v3/{name=projects/*/notificationChannels/*}:sendVerificationCode"
+ body: "*"
+ };
+ }
+
+ // Requests a verification code for an already verified channel that can then
+ // be used in a call to VerifyNotificationChannel() on a different channel
+ // with an equivalent identity in the same or in a different project. This
+ // makes it possible to copy a channel between projects without requiring
+ // manual reverification of the channel. If the channel is not in the
+ // verified state, this method will fail (in other words, this may only be
+ // used if the SendNotificationChannelVerificationCode and
+ // VerifyNotificationChannel paths have already been used to put the given
+ // channel into the verified state).
+ //
+ // There is no guarantee that the verification codes returned by this method
+ // will be of a similar structure or form as the ones that are delivered
+ // to the channel via SendNotificationChannelVerificationCode; while
+ // VerifyNotificationChannel() will recognize both the codes delivered via
+ // SendNotificationChannelVerificationCode() and returned from
+ // GetNotificationChannelVerificationCode(), it is typically the case that
+ // the verification codes delivered via
+ // SendNotificationChannelVerificationCode() will be shorter and also
+ // have a shorter expiration (e.g. codes such as "G-123456") whereas
+ // GetVerificationCode() will typically return a much longer, websafe base
+ // 64 encoded string that has a longer expiration time.
+ rpc GetNotificationChannelVerificationCode(
+ GetNotificationChannelVerificationCodeRequest)
+ returns (GetNotificationChannelVerificationCodeResponse) {
+ option (google.api.http) = {
+ post: "/v3/{name=projects/*/notificationChannels/*}:getVerificationCode"
+ body: "*"
+ };
+ }
+
+ // Verifies a `NotificationChannel` by proving receipt of the code
+ // delivered to the channel as a result of calling
+ // `SendNotificationChannelVerificationCode`.
+ rpc VerifyNotificationChannel(VerifyNotificationChannelRequest)
+ returns (NotificationChannel) {
+ option (google.api.http) = {
+ post: "/v3/{name=projects/*/notificationChannels/*}:verify"
+ body: "*"
+ };
+ }
+}
+
+// The `ListNotificationChannelDescriptors` request.
+message ListNotificationChannelDescriptorsRequest {
+ // The REST resource name of the parent from which to retrieve
+ // the notification channel descriptors. The expected syntax is:
+ //
+ // projects/[PROJECT_ID]
+ //
+ // Note that this names the parent container in which to look for the
+ // descriptors; to retrieve a single descriptor by name, use the
+ // [GetNotificationChannelDescriptor][google.monitoring.v3.NotificationChannelService.GetNotificationChannelDescriptor]
+ // operation, instead.
+ string name = 4;
+
+ // The maximum number of results to return in a single response. If
+ // not set to a positive number, a reasonable value will be chosen by the
+ // service.
+ int32 page_size = 2;
+
+ // If non-empty, `page_token` must contain a value returned as the
+ // `next_page_token` in a previous response to request the next set
+ // of results.
+ string page_token = 3;
+}
+
+// The `ListNotificationChannelDescriptors` response.
+message ListNotificationChannelDescriptorsResponse {
+ // The monitored resource descriptors supported for the specified
+ // project, optionally filtered.
+ repeated NotificationChannelDescriptor channel_descriptors = 1;
+
+ // If not empty, indicates that there may be more results that match
+ // the request. Use the value in the `page_token` field in a
+ // subsequent request to fetch the next set of results. If empty,
+ // all results have been returned.
+ string next_page_token = 2;
+}
+
+// The `GetNotificationChannelDescriptor` response.
+message GetNotificationChannelDescriptorRequest {
+ // The channel type for which to execute the request. The format is
+ // `projects/[PROJECT_ID]/notificationChannelDescriptors/{channel_type}`.
+ string name = 3;
+}
+
+// The `CreateNotificationChannel` request.
+message CreateNotificationChannelRequest {
+ // The project on which to execute the request. The format is:
+ //
+ // projects/[PROJECT_ID]
+ //
+ // Note that this names the container into which the channel will be
+ // written. This does not name the newly created channel. The resulting
+ // channel's name will have a normalized version of this field as a prefix,
+ // but will add `/notificationChannels/[CHANNEL_ID]` to identify the channel.
+ string name = 3;
+
+ // The definition of the `NotificationChannel` to create.
+ NotificationChannel notification_channel = 2;
+}
+
+// The `ListNotificationChannels` request.
+message ListNotificationChannelsRequest {
+ // The project on which to execute the request. The format is
+ // `projects/[PROJECT_ID]`. That is, this names the container
+ // in which to look for the notification channels; it does not name a
+ // specific channel. To query a specific channel by REST resource name, use
+ // the
+ // [`GetNotificationChannel`][google.monitoring.v3.NotificationChannelService.GetNotificationChannel]
+ // operation.
+ string name = 5;
+
+ // If provided, this field specifies the criteria that must be met by
+ // notification channels to be included in the response.
+ //
+ // For more details, see [sorting and
+ // filtering](/monitoring/api/v3/sorting-and-filtering).
+ string filter = 6;
+
+ // A comma-separated list of fields by which to sort the result. Supports
+ // the same set of fields as in `filter`. Entries can be prefixed with
+ // a minus sign to sort in descending rather than ascending order.
+ //
+ // For more details, see [sorting and
+ // filtering](/monitoring/api/v3/sorting-and-filtering).
+ string order_by = 7;
+
+ // The maximum number of results to return in a single response. If
+ // not set to a positive number, a reasonable value will be chosen by the
+ // service.
+ int32 page_size = 3;
+
+ // If non-empty, `page_token` must contain a value returned as the
+ // `next_page_token` in a previous response to request the next set
+ // of results.
+ string page_token = 4;
+}
+
+// The `ListNotificationChannels` response.
+message ListNotificationChannelsResponse {
+ // The notification channels defined for the specified project.
+ repeated NotificationChannel notification_channels = 3;
+
+ // If not empty, indicates that there may be more results that match
+ // the request. Use the value in the `page_token` field in a
+ // subsequent request to fetch the next set of results. If empty,
+ // all results have been returned.
+ string next_page_token = 2;
+}
+
+// The `GetNotificationChannel` request.
+message GetNotificationChannelRequest {
+ // The channel for which to execute the request. The format is
+ // `projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]`.
+ string name = 3;
+}
+
+// The `UpdateNotificationChannel` request.
+message UpdateNotificationChannelRequest {
+ // The fields to update.
+ google.protobuf.FieldMask update_mask = 2;
+
+ // A description of the changes to be applied to the specified
+ // notification channel. The description must provide a definition for
+ // fields to be updated; the names of these fields should also be
+ // included in the `update_mask`.
+ NotificationChannel notification_channel = 3;
+}
+
+// The `DeleteNotificationChannel` request.
+message DeleteNotificationChannelRequest {
+ // The channel for which to execute the request. The format is
+ // `projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]`.
+ string name = 3;
+
+ // If true, the notification channel will be deleted regardless of its
+ // use in alert policies (the policies will be updated to remove the
+ // channel). If false, channels that are still referenced by an existing
+ // alerting policy will fail to be deleted in a delete operation.
+ bool force = 5;
+}
+
+// The `SendNotificationChannelVerificationCode` request.
+message SendNotificationChannelVerificationCodeRequest {
+ // The notification channel to which to send a verification code.
+ string name = 1;
+}
+
+// The `GetNotificationChannelVerificationCode` request.
+message GetNotificationChannelVerificationCodeRequest {
+ // The notification channel for which a verification code is to be generated
+ // and retrieved. This must name a channel that is already verified; if
+ // the specified channel is not verified, the request will fail.
+ string name = 1;
+
+ // The desired expiration time. If specified, the API will guarantee that
+ // the returned code will not be valid after the specified timestamp;
+ // however, the API cannot guarantee that the returned code will be
+ // valid for at least as long as the requested time (the API puts an upper
+ // bound on the amount of time for which a code may be valid). If omitted,
+ // a default expiration will be used, which may be less than the max
+ // permissible expiration (so specifying an expiration may extend the
+ // code's lifetime over omitting an expiration, even though the API does
+ // impose an upper limit on the maximum expiration that is permitted).
+ google.protobuf.Timestamp expire_time = 2;
+}
+
+// The `GetNotificationChannelVerificationCode` request.
+message GetNotificationChannelVerificationCodeResponse {
+ // The verification code, which may be used to verify other channels
+ // that have an equivalent identity (i.e. other channels of the same
+ // type with the same fingerprint such as other email channels with
+ // the same email address or other sms channels with the same number).
+ string code = 1;
+
+ // The expiration time associated with the code that was returned. If
+ // an expiration was provided in the request, this is the minimum of the
+ // requested expiration in the request and the max permitted expiration.
+ google.protobuf.Timestamp expire_time = 2;
+}
+
+// The `VerifyNotificationChannel` request.
+message VerifyNotificationChannelRequest {
+ // The notification channel to verify.
+ string name = 1;
+
+ // The verification code that was delivered to the channel as
+ // a result of invoking the `SendNotificationChannelVerificationCode` API
+ // method or that was retrieved from a verified channel via
+ // `GetNotificationChannelVerificationCode`. For example, one might have
+ // "G-123456" or "TKNZGhhd2EyN3I1MnRnMjRv" (in general, one is only
+ // guaranteed that the code is valid UTF-8; one should not
+ // make any assumptions regarding the structure or format of the code).
+ string code = 2;
+}

protos/google/monitoring/v3/span_context.proto

@@ -0,0 +1,43 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.monitoring.v3;
+
+option csharp_namespace = "Google.Cloud.Monitoring.V3";
+option go_package = "google.golang.org/genproto/googleapis/monitoring/v3;monitoring";
+option java_multiple_files = true;
+option java_outer_classname = "SpanContextProto";
+option java_package = "com.google.monitoring.v3";
+option php_namespace = "Google\\Cloud\\Monitoring\\V3";
+
+// The context of a span, attached to google.api.Distribution.Exemplars
+// in google.api.Distribution values during aggregation.
+//
+// It contains the name of a span with format:
+// projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID]
+message SpanContext {
+ // The resource name of the span in the following format:
+ //
+ // projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID]
+ //
+ // [TRACE_ID] is a unique identifier for a trace within a project;
+ // it is a 32-character hexadecimal encoding of a 16-byte array.
+ //
+ // [SPAN_ID] is a unique identifier for a span within a trace; it
+ // is a 16-character hexadecimal encoding of an 8-byte array.
+ string span_name = 1;
+}

protos/google/monitoring/v3/uptime.proto

@@ -0,0 +1,271 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.monitoring.v3;
+
+import "google/api/monitored_resource.proto";
+import "google/protobuf/duration.proto";
+
+option csharp_namespace = "Google.Cloud.Monitoring.V3";
+option go_package = "google.golang.org/genproto/googleapis/monitoring/v3;monitoring";
+option java_multiple_files = true;
+option java_outer_classname = "UptimeProto";
+option java_package = "com.google.monitoring.v3";
+option php_namespace = "Google\\Cloud\\Monitoring\\V3";
+
+// An internal checker allows uptime checks to run on private/internal GCP
+// resources.
+message InternalChecker {
+ // A unique resource name for this InternalChecker. The format is:
+ //
+ //
+ // `projects/[PROJECT_ID]/internalCheckers/[INTERNAL_CHECKER_ID]`.
+ //
+ // PROJECT_ID is the stackdriver workspace project for the
+ // uptime check config associated with the internal checker.
+ string name = 1;
+
+ // The checker's human-readable name. The display name
+ // should be unique within a Stackdriver Workspace in order to make it easier
+ // to identify; however, uniqueness is not enforced.
+ string display_name = 2;
+
+ // The [GCP VPC network](https://cloud.google.com/vpc/docs/vpc) where the
+ // internal resource lives (ex: "default").
+ string network = 3;
+
+ // The GCP zone the uptime check should egress from. Only respected for
+ // internal uptime checks, where internal_network is specified.
+ string gcp_zone = 4;
+
+ // The GCP project_id where the internal checker lives. Not necessary
+ // the same as the workspace project.
+ string peer_project_id = 6;
+}
+
+// This message configures which resources and services to monitor for
+// availability.
+message UptimeCheckConfig {
+ // The resource submessage for group checks. It can be used instead of a
+ // monitored resource, when multiple resources are being monitored.
+ message ResourceGroup {
+ // The group of resources being monitored. Should be only the
+ // group_id, not projects/<project_id>/groups/<group_id>.
+ string group_id = 1;
+
+ // The resource type of the group members.
+ GroupResourceType resource_type = 2;
+ }
+
+ // Information involved in an HTTP/HTTPS uptime check request.
+ message HttpCheck {
+ // A type of authentication to perform against the specified resource or URL
+ // that uses username and password.
+ // Currently, only Basic authentication is supported in Uptime Monitoring.
+ message BasicAuthentication {
+ // The username to authenticate.
+ string username = 1;
+
+ // The password to authenticate.
+ string password = 2;
+ }
+
+ // If true, use HTTPS instead of HTTP to run the check.
+ bool use_ssl = 1;
+
+ // The path to the page to run the check against. Will be combined with the
+ // host (specified within the MonitoredResource) and port to construct the
+ // full URL. Optional (defaults to "/").
+ string path = 2;
+
+ // The port to the page to run the check against. Will be combined with host
+ // (specified within the MonitoredResource) and path to construct the full
+ // URL. Optional (defaults to 80 without SSL, or 443 with SSL).
+ int32 port = 3;
+
+ // The authentication information. Optional when creating an HTTP check;
+ // defaults to empty.
+ BasicAuthentication auth_info = 4;
+
+ // Boolean specifiying whether to encrypt the header information.
+ // Encryption should be specified for any headers related to authentication
+ // that you do not wish to be seen when retrieving the configuration. The
+ // server will be responsible for encrypting the headers.
+ // On Get/List calls, if mask_headers is set to True then the headers
+ // will be obscured with ******.
+ bool mask_headers = 5;
+
+ // The list of headers to send as part of the uptime check request.
+ // If two headers have the same key and different values, they should
+ // be entered as a single header, with the value being a comma-separated
+ // list of all the desired values as described at
+ // https://www.w3.org/Protocols/rfc2616/rfc2616.txt (page 31).
+ // Entering two separate headers with the same key in a Create call will
+ // cause the first to be overwritten by the second.
+ // The maximum number of headers allowed is 100.
+ map<string, string> headers = 6;
+ }
+
+ // Information required for a TCP uptime check request.
+ message TcpCheck {
+ // The port to the page to run the check against. Will be combined with host
+ // (specified within the MonitoredResource) to construct the full URL.
+ // Required.
+ int32 port = 1;
+ }
+
+ // Used to perform string matching. It allows substring and regular
+ // expressions, together with their negations.
+ message ContentMatcher {
+ // String or regex content to match (max 1024 bytes)
+ string content = 1;
+ }
+
+ // A unique resource name for this UptimeCheckConfig. The format is:
+ //
+ //
+ // `projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]`.
+ //
+ // This field should be omitted when creating the uptime check configuration;
+ // on create, the resource name is assigned by the server and included in the
+ // response.
+ string name = 1;
+
+ // A human-friendly name for the uptime check configuration. The display name
+ // should be unique within a Stackdriver Workspace in order to make it easier
+ // to identify; however, uniqueness is not enforced. Required.
+ string display_name = 2;
+
+ // The resource the check is checking. Required.
+ oneof resource {
+ // The [monitored
+ // resource](https://cloud.google.com/monitoring/api/resources) associated
+ // with the configuration.
+ // The following monitored resource types are supported for uptime checks:
+ // uptime_url
+ // gce_instance
+ // gae_app
+ // aws_ec2_instance
+ // aws_elb_load_balancer
+ google.api.MonitoredResource monitored_resource = 3;
+
+ // The group resource associated with the configuration.
+ ResourceGroup resource_group = 4;
+ }
+
+ // The type of uptime check request.
+ oneof check_request_type {
+ // Contains information needed to make an HTTP or HTTPS check.
+ HttpCheck http_check = 5;
+
+ // Contains information needed to make a TCP check.
+ TcpCheck tcp_check = 6;
+ }
+
+ // How often, in seconds, the uptime check is performed.
+ // Currently, the only supported values are `60s` (1 minute), `300s`
+ // (5 minutes), `600s` (10 minutes), and `900s` (15 minutes). Optional,
+ // defaults to `300s`.
+ google.protobuf.Duration period = 7;
+
+ // The maximum amount of time to wait for the request to complete (must be
+ // between 1 and 60 seconds). Required.
+ google.protobuf.Duration timeout = 8;
+
+ // The expected content on the page the check is run against.
+ // Currently, only the first entry in the list is supported, and other entries
+ // will be ignored. The server will look for an exact match of the string in
+ // the page response's content. This field is optional and should only be
+ // specified if a content match is required.
+ repeated ContentMatcher content_matchers = 9;
+
+ // The list of regions from which the check will be run.
+ // Some regions contain one location, and others contain more than one.
+ // If this field is specified, enough regions to include a minimum of
+ // 3 locations must be provided, or an error message is returned.
+ // Not specifying this field will result in uptime checks running from all
+ // regions.
+ repeated UptimeCheckRegion selected_regions = 10;
+
+ // If this is true, then checks are made only from the 'internal_checkers'.
+ // If it is false, then checks are made only from the 'selected_regions'.
+ // It is an error to provide 'selected_regions' when is_internal is true,
+ // or to provide 'internal_checkers' when is_internal is false.
+ bool is_internal = 15;
+
+ // The internal checkers that this check will egress from. If `is_internal` is
+ // true and this list is empty, the check will egress from all the
+ // InternalCheckers configured for the project that owns this CheckConfig.
+ repeated InternalChecker internal_checkers = 14;
+}
+
+// Contains the region, location, and list of IP
+// addresses where checkers in the location run from.
+message UptimeCheckIp {
+ // A broad region category in which the IP address is located.
+ UptimeCheckRegion region = 1;
+
+ // A more specific location within the region that typically encodes
+ // a particular city/town/metro (and its containing state/province or country)
+ // within the broader umbrella region category.
+ string location = 2;
+
+ // The IP address from which the uptime check originates. This is a full
+ // IP address (not an IP address range). Most IP addresses, as of this
+ // publication, are in IPv4 format; however, one should not rely on the
+ // IP addresses being in IPv4 format indefinitely and should support
+ // interpreting this field in either IPv4 or IPv6 format.
+ string ip_address = 3;
+}
+
+// The regions from which an uptime check can be run.
+enum UptimeCheckRegion {
+ // Default value if no region is specified. Will result in uptime checks
+ // running from all regions.
+ REGION_UNSPECIFIED = 0;
+
+ // Allows checks to run from locations within the United States of America.
+ USA = 1;
+
+ // Allows checks to run from locations within the continent of Europe.
+ EUROPE = 2;
+
+ // Allows checks to run from locations within the continent of South
+ // America.
+ SOUTH_AMERICA = 3;
+
+ // Allows checks to run from locations within the Asia Pacific area (ex:
+ // Singapore).
+ ASIA_PACIFIC = 4;
+}
+
+// The supported resource types that can be used as values of
+// `group_resource.resource_type`.
+// `INSTANCE` includes `gce_instance` and `aws_ec2_instance` resource types.
+// The resource types `gae_app` and `uptime_url` are not valid here because
+// group checks on App Engine modules and URLs are not allowed.
+enum GroupResourceType {
+ // Default value (not valid).
+ RESOURCE_TYPE_UNSPECIFIED = 0;
+
+ // A group of instances from Google Cloud Platform (GCP) or
+ // Amazon Web Services (AWS).
+ INSTANCE = 1;
+
+ // A group of Amazon ELB load balancers.
+ AWS_ELB_LOAD_BALANCER = 2;
+}

protos/google/monitoring/v3/uptime_service.proto

@@ -0,0 +1,208 @@
+// Copyright 2018 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.monitoring.v3;
+
+import "google/api/annotations.proto";
+import "google/monitoring/v3/uptime.proto";
+import "google/protobuf/empty.proto";
+import "google/protobuf/field_mask.proto";
+
+option csharp_namespace = "Google.Cloud.Monitoring.V3";
+option go_package = "google.golang.org/genproto/googleapis/monitoring/v3;monitoring";
+option java_multiple_files = true;
+option java_outer_classname = "UptimeServiceProto";
+option java_package = "com.google.monitoring.v3";
+option php_namespace = "Google\\Cloud\\Monitoring\\V3";
+
+// The UptimeCheckService API is used to manage (list, create, delete, edit)
+// uptime check configurations in the Stackdriver Monitoring product. An uptime
+// check is a piece of configuration that determines which resources and
+// services to monitor for availability. These configurations can also be
+// configured interactively by navigating to the [Cloud Console]
+// (http://console.cloud.google.com), selecting the appropriate project,
+// clicking on "Monitoring" on the left-hand side to navigate to Stackdriver,
+// and then clicking on "Uptime".
+service UptimeCheckService {
+ // Lists the existing valid uptime check configurations for the project,
+ // leaving out any invalid configurations.
+ rpc ListUptimeCheckConfigs(ListUptimeCheckConfigsRequest)
+ returns (ListUptimeCheckConfigsResponse) {
+ option (google.api.http) = {
+ get: "/v3/{parent=projects/*}/uptimeCheckConfigs"
+ };
+ }
+
+ // Gets a single uptime check configuration.
+ rpc GetUptimeCheckConfig(GetUptimeCheckConfigRequest)
+ returns (UptimeCheckConfig) {
+ option (google.api.http) = {
+ get: "/v3/{name=projects/*/uptimeCheckConfigs/*}"
+ };
+ }
+
+ // Creates a new uptime check configuration.
+ rpc CreateUptimeCheckConfig(CreateUptimeCheckConfigRequest)
+ returns (UptimeCheckConfig) {
+ option (google.api.http) = {
+ post: "/v3/{parent=projects/*}/uptimeCheckConfigs"
+ body: "uptime_check_config"
+ };
+ }
+
+ // Updates an uptime check configuration. You can either replace the entire
+ // configuration with a new one or replace only certain fields in the current
+ // configuration by specifying the fields to be updated via `"updateMask"`.
+ // Returns the updated configuration.
+ rpc UpdateUptimeCheckConfig(UpdateUptimeCheckConfigRequest)
+ returns (UptimeCheckConfig) {
+ option (google.api.http) = {
+ patch: "/v3/{uptime_check_config.name=projects/*/uptimeCheckConfigs/*}"
+ body: "uptime_check_config"
+ };
+ }
+
+ // Deletes an uptime check configuration. Note that this method will fail
+ // if the uptime check configuration is referenced by an alert policy or
+ // other dependent configs that would be rendered invalid by the deletion.
+ rpc DeleteUptimeCheckConfig(DeleteUptimeCheckConfigRequest)
+ returns (google.protobuf.Empty) {
+ option (google.api.http) = {
+ delete: "/v3/{name=projects/*/uptimeCheckConfigs/*}"
+ };
+ }
+
+ // Returns the list of IPs that checkers run from
+ rpc ListUptimeCheckIps(ListUptimeCheckIpsRequest)
+ returns (ListUptimeCheckIpsResponse) {
+ option (google.api.http) = {
+ get: "/v3/uptimeCheckIps"
+ };
+ }
+}
+
+// The protocol for the `ListUptimeCheckConfigs` request.
+message ListUptimeCheckConfigsRequest {
+ // The project whose uptime check configurations are listed. The format
+ // is `projects/[PROJECT_ID]`.
+ string parent = 1;
+
+ // The maximum number of results to return in a single response. The server
+ // may further constrain the maximum number of results returned in a single
+ // page. If the page_size is <=0, the server will decide the number of results
+ // to be returned.
+ int32 page_size = 3;
+
+ // If this field is not empty then it must contain the `nextPageToken` value
+ // returned by a previous call to this method. Using this field causes the
+ // method to return more results from the previous method call.
+ string page_token = 4;
+}
+
+// The protocol for the `ListUptimeCheckConfigs` response.
+message ListUptimeCheckConfigsResponse {
+ // The returned uptime check configurations.
+ repeated UptimeCheckConfig uptime_check_configs = 1;
+
+ // This field represents the pagination token to retrieve the next page of
+ // results. If the value is empty, it means no further results for the
+ // request. To retrieve the next page of results, the value of the
+ // next_page_token is passed to the subsequent List method call (in the
+ // request message's page_token field).
+ string next_page_token = 2;
+
+ // The total number of uptime check configurations for the project,
+ // irrespective of any pagination.
+ int32 total_size = 3;
+}
+
+// The protocol for the `GetUptimeCheckConfig` request.
+message GetUptimeCheckConfigRequest {
+ // The uptime check configuration to retrieve. The format
+ // is `projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]`.
+ string name = 1;
+}
+
+// The protocol for the `CreateUptimeCheckConfig` request.
+message CreateUptimeCheckConfigRequest {
+ // The project in which to create the uptime check. The format
+ // is `projects/[PROJECT_ID]`.
+ string parent = 1;
+
+ // The new uptime check configuration.
+ UptimeCheckConfig uptime_check_config = 2;
+}
+
+// The protocol for the `UpdateUptimeCheckConfig` request.
+message UpdateUptimeCheckConfigRequest {
+ // Optional. If present, only the listed fields in the current uptime check
+ // configuration are updated with values from the new configuration. If this
+ // field is empty, then the current configuration is completely replaced with
+ // the new configuration.
+ google.protobuf.FieldMask update_mask = 2;
+
+ // Required. If an `"updateMask"` has been specified, this field gives
+ // the values for the set of fields mentioned in the `"updateMask"`. If an
+ // `"updateMask"` has not been given, this uptime check configuration replaces
+ // the current configuration. If a field is mentioned in `"updateMask"` but
+ // the corresonding field is omitted in this partial uptime check
+ // configuration, it has the effect of deleting/clearing the field from the
+ // configuration on the server.
+ //
+ // The following fields can be updated: `display_name`,
+ // `http_check`, `tcp_check`, `timeout`, `content_matchers`, and
+ // `selected_regions`.
+ UptimeCheckConfig uptime_check_config = 3;
+}
+
+// The protocol for the `DeleteUptimeCheckConfig` request.
+message DeleteUptimeCheckConfigRequest {
+ // The uptime check configuration to delete. The format
+ // is `projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]`.
+ string name = 1;
+}
+
+// The protocol for the `ListUptimeCheckIps` request.
+message ListUptimeCheckIpsRequest {
+ // The maximum number of results to return in a single response. The server
+ // may further constrain the maximum number of results returned in a single
+ // page. If the page_size is <=0, the server will decide the number of results
+ // to be returned.
+ // NOTE: this field is not yet implemented
+ int32 page_size = 2;
+
+ // If this field is not empty then it must contain the `nextPageToken` value
+ // returned by a previous call to this method. Using this field causes the
+ // method to return more results from the previous method call.
+ // NOTE: this field is not yet implemented
+ string page_token = 3;
+}
+
+// The protocol for the `ListUptimeCheckIps` response.
+message ListUptimeCheckIpsResponse {
+ // The returned list of IP addresses (including region and location) that the
+ // checkers run from.
+ repeated UptimeCheckIp uptime_check_ips = 1;
+
+ // This field represents the pagination token to retrieve the next page of
+ // results. If the value is empty, it means no further results for the
+ // request. To retrieve the next page of results, the value of the
+ // next_page_token is passed to the subsequent List method call (in the
+ // request message's page_token field).
+ // NOTE: this field is not yet implemented
+ string next_page_token = 2;
+}

protos/google/protobuf/any.proto

@@ -0,0 +1,155 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto3";
+
+package google.protobuf;
+
+option csharp_namespace = "Google.Protobuf.WellKnownTypes";
+option go_package = "github.com/golang/protobuf/ptypes/any";
+option java_package = "com.google.protobuf";
+option java_outer_classname = "AnyProto";
+option java_multiple_files = true;
+option objc_class_prefix = "GPB";
+
+// `Any` contains an arbitrary serialized protocol buffer message along with a
+// URL that describes the type of the serialized message.
+//
+// Protobuf library provides support to pack/unpack Any values in the form
+// of utility functions or additional generated methods of the Any type.
+//
+// Example 1: Pack and unpack a message in C++.
+//
+// Foo foo = ...;
+// Any any;
+// any.PackFrom(foo);
+// ...
+// if (any.UnpackTo(&foo)) {
+// ...
+// }
+//
+// Example 2: Pack and unpack a message in Java.
+//
+// Foo foo = ...;
+// Any any = Any.pack(foo);
+// ...
+// if (any.is(Foo.class)) {
+// foo = any.unpack(Foo.class);
+// }
+//
+// Example 3: Pack and unpack a message in Python.
+//
+// foo = Foo(...)
+// any = Any()
+// any.Pack(foo)
+// ...
+// if any.Is(Foo.DESCRIPTOR):
+// any.Unpack(foo)
+// ...
+//
+// Example 4: Pack and unpack a message in Go
+//
+// foo := &pb.Foo{...}
+// any, err := ptypes.MarshalAny(foo)
+// ...
+// foo := &pb.Foo{}
+// if err := ptypes.UnmarshalAny(any, foo); err != nil {
+// ...
+// }
+//
+// The pack methods provided by protobuf library will by default use
+// 'type.googleapis.com/full.type.name' as the type URL and the unpack
+// methods only use the fully qualified type name after the last '/'
+// in the type URL, for example "foo.bar.com/x/y.z" will yield type
+// name "y.z".
+//
+//
+// JSON
+// ====
+// The JSON representation of an `Any` value uses the regular
+// representation of the deserialized, embedded message, with an
+// additional field `@type` which contains the type URL. Example:
+//
+// package google.profile;
+// message Person {
+// string first_name = 1;
+// string last_name = 2;
+// }
+//
+// {
+// "@type": "type.googleapis.com/google.profile.Person",
+// "firstName": <string>,
+// "lastName": <string>
+// }
+//
+// If the embedded message type is well-known and has a custom JSON
+// representation, that representation will be embedded adding a field
+// `value` which holds the custom JSON in addition to the `@type`
+// field. Example (for message [google.protobuf.Duration][]):
+//
+// {
+// "@type": "type.googleapis.com/google.protobuf.Duration",
+// "value": "1.212s"
+// }
+//
+message Any {
+ // A URL/resource name that uniquely identifies the type of the serialized
+ // protocol buffer message. This string must contain at least
+ // one "/" character. The last segment of the URL's path must represent
+ // the fully qualified name of the type (as in
+ // `path/google.protobuf.Duration`). The name should be in a canonical form
+ // (e.g., leading "." is not accepted).
+ //
+ // In practice, teams usually precompile into the binary all types that they
+ // expect it to use in the context of Any. However, for URLs which use the
+ // scheme `http`, `https`, or no scheme, one can optionally set up a type
+ // server that maps type URLs to message definitions as follows:
+ //
+ // * If no scheme is provided, `https` is assumed.
+ // * An HTTP GET on the URL must yield a [google.protobuf.Type][]
+ // value in binary format, or produce an error.
+ // * Applications are allowed to cache lookup results based on the
+ // URL, or have them precompiled into a binary to avoid any
+ // lookup. Therefore, binary compatibility needs to be preserved
+ // on changes to types. (Use versioned type names to manage
+ // breaking changes.)
+ //
+ // Note: this functionality is not currently available in the official
+ // protobuf release, and it is not used for type URLs beginning with
+ // type.googleapis.com.
+ //
+ // Schemes other than `http`, `https` (or the empty scheme) might be
+ // used with implementation specific semantics.
+ //
+ string type_url = 1;
+
+ // Must be a valid serialized protocol buffer of the above specified type.
+ bytes value = 2;
+}

protos/google/protobuf/api.proto

@@ -0,0 +1,210 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto3";
+
+package google.protobuf;
+
+import "google/protobuf/source_context.proto";
+import "google/protobuf/type.proto";
+
+option csharp_namespace = "Google.Protobuf.WellKnownTypes";
+option java_package = "com.google.protobuf";
+option java_outer_classname = "ApiProto";
+option java_multiple_files = true;
+option objc_class_prefix = "GPB";
+option go_package = "google.golang.org/genproto/protobuf/api;api";
+
+// Api is a light-weight descriptor for an API Interface.
+//
+// Interfaces are also described as "protocol buffer services" in some contexts,
+// such as by the "service" keyword in a .proto file, but they are different
+// from API Services, which represent a concrete implementation of an interface
+// as opposed to simply a description of methods and bindings. They are also
+// sometimes simply referred to as "APIs" in other contexts, such as the name of
+// this message itself. See https://cloud.google.com/apis/design/glossary for
+// detailed terminology.
+message Api {
+
+ // The fully qualified name of this interface, including package name
+ // followed by the interface's simple name.
+ string name = 1;
+
+ // The methods of this interface, in unspecified order.
+ repeated Method methods = 2;
+
+ // Any metadata attached to the interface.
+ repeated Option options = 3;
+
+ // A version string for this interface. If specified, must have the form
+ // `major-version.minor-version`, as in `1.10`. If the minor version is
+ // omitted, it defaults to zero. If the entire version field is empty, the
+ // major version is derived from the package name, as outlined below. If the
+ // field is not empty, the version in the package name will be verified to be
+ // consistent with what is provided here.
+ //
+ // The versioning schema uses [semantic
+ // versioning](http://semver.org) where the major version number
+ // indicates a breaking change and the minor version an additive,
+ // non-breaking change. Both version numbers are signals to users
+ // what to expect from different versions, and should be carefully
+ // chosen based on the product plan.
+ //
+ // The major version is also reflected in the package name of the
+ // interface, which must end in `v<major-version>`, as in
+ // `google.feature.v1`. For major versions 0 and 1, the suffix can
+ // be omitted. Zero major versions must only be used for
+ // experimental, non-GA interfaces.
+ //
+ //
+ string version = 4;
+
+ // Source context for the protocol buffer service represented by this
+ // message.
+ SourceContext source_context = 5;
+
+ // Included interfaces. See [Mixin][].
+ repeated Mixin mixins = 6;
+
+ // The source syntax of the service.
+ Syntax syntax = 7;
+}
+
+// Method represents a method of an API interface.
+message Method {
+
+ // The simple name of this method.
+ string name = 1;
+
+ // A URL of the input message type.
+ string request_type_url = 2;
+
+ // If true, the request is streamed.
+ bool request_streaming = 3;
+
+ // The URL of the output message type.
+ string response_type_url = 4;
+
+ // If true, the response is streamed.
+ bool response_streaming = 5;
+
+ // Any metadata attached to the method.
+ repeated Option options = 6;
+
+ // The source syntax of this method.
+ Syntax syntax = 7;
+}
+
+// Declares an API Interface to be included in this interface. The including
+// interface must redeclare all the methods from the included interface, but
+// documentation and options are inherited as follows:
+//
+// - If after comment and whitespace stripping, the documentation
+// string of the redeclared method is empty, it will be inherited
+// from the original method.
+//
+// - Each annotation belonging to the service config (http,
+// visibility) which is not set in the redeclared method will be
+// inherited.
+//
+// - If an http annotation is inherited, the path pattern will be
+// modified as follows. Any version prefix will be replaced by the
+// version of the including interface plus the [root][] path if
+// specified.
+//
+// Example of a simple mixin:
+//
+// package google.acl.v1;
+// service AccessControl {
+// // Get the underlying ACL object.
+// rpc GetAcl(GetAclRequest) returns (Acl) {
+// option (google.api.http).get = "/v1/{resource=**}:getAcl";
+// }
+// }
+//
+// package google.storage.v2;
+// service Storage {
+// rpc GetAcl(GetAclRequest) returns (Acl);
+//
+// // Get a data record.
+// rpc GetData(GetDataRequest) returns (Data) {
+// option (google.api.http).get = "/v2/{resource=**}";
+// }
+// }
+//
+// Example of a mixin configuration:
+//
+// apis:
+// - name: google.storage.v2.Storage
+// mixins:
+// - name: google.acl.v1.AccessControl
+//
+// The mixin construct implies that all methods in `AccessControl` are
+// also declared with same name and request/response types in
+// `Storage`. A documentation generator or annotation processor will
+// see the effective `Storage.GetAcl` method after inherting
+// documentation and annotations as follows:
+//
+// service Storage {
+// // Get the underlying ACL object.
+// rpc GetAcl(GetAclRequest) returns (Acl) {
+// option (google.api.http).get = "/v2/{resource=**}:getAcl";
+// }
+// ...
+// }
+//
+// Note how the version in the path pattern changed from `v1` to `v2`.
+//
+// If the `root` field in the mixin is specified, it should be a
+// relative path under which inherited HTTP paths are placed. Example:
+//
+// apis:
+// - name: google.storage.v2.Storage
+// mixins:
+// - name: google.acl.v1.AccessControl
+// root: acls
+//
+// This implies the following inherited HTTP annotation:
+//
+// service Storage {
+// // Get the underlying ACL object.
+// rpc GetAcl(GetAclRequest) returns (Acl) {
+// option (google.api.http).get = "/v2/acls/{resource=**}:getAcl";
+// }
+// ...
+// }
+message Mixin {
+ // The fully qualified name of the interface which is included.
+ string name = 1;
+
+ // If non-empty specifies a path under which inherited HTTP paths
+ // are rooted.
+ string root = 2;
+}

protos/google/protobuf/descriptor.proto

@@ -0,0 +1,882 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Author: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+//
+// The messages in this file describe the definitions found in .proto files.
+// A valid .proto file can be translated directly to a FileDescriptorProto
+// without any other information (e.g. without reading its imports).
+
+
+syntax = "proto2";
+
+package google.protobuf;
+option go_package = "github.com/golang/protobuf/protoc-gen-go/descriptor;descriptor";
+option java_package = "com.google.protobuf";
+option java_outer_classname = "DescriptorProtos";
+option csharp_namespace = "Google.Protobuf.Reflection";
+option objc_class_prefix = "GPB";
+option cc_enable_arenas = true;
+
+// descriptor.proto must be optimized for speed because reflection-based
+// algorithms don't work during bootstrapping.
+option optimize_for = SPEED;
+
+// The protocol compiler can output a FileDescriptorSet containing the .proto
+// files it parses.
+message FileDescriptorSet {
+ repeated FileDescriptorProto file = 1;
+}
+
+// Describes a complete .proto file.
+message FileDescriptorProto {
+ optional string name = 1; // file name, relative to root of source tree
+ optional string package = 2; // e.g. "foo", "foo.bar", etc.
+
+ // Names of files imported by this file.
+ repeated string dependency = 3;
+ // Indexes of the public imported files in the dependency list above.
+ repeated int32 public_dependency = 10;
+ // Indexes of the weak imported files in the dependency list.
+ // For Google-internal migration only. Do not use.
+ repeated int32 weak_dependency = 11;
+
+ // All top-level definitions in this file.
+ repeated DescriptorProto message_type = 4;
+ repeated EnumDescriptorProto enum_type = 5;
+ repeated ServiceDescriptorProto service = 6;
+ repeated FieldDescriptorProto extension = 7;
+
+ optional FileOptions options = 8;
+
+ // This field contains optional information about the original source code.
+ // You may safely remove this entire field without harming runtime
+ // functionality of the descriptors -- the information is needed only by
+ // development tools.
+ optional SourceCodeInfo source_code_info = 9;
+
+ // The syntax of the proto file.
+ // The supported values are "proto2" and "proto3".
+ optional string syntax = 12;
+}
+
+// Describes a message type.
+message DescriptorProto {
+ optional string name = 1;
+
+ repeated FieldDescriptorProto field = 2;
+ repeated FieldDescriptorProto extension = 6;
+
+ repeated DescriptorProto nested_type = 3;
+ repeated EnumDescriptorProto enum_type = 4;
+
+ message ExtensionRange {
+ optional int32 start = 1;
+ optional int32 end = 2;
+
+ optional ExtensionRangeOptions options = 3;
+ }
+ repeated ExtensionRange extension_range = 5;
+
+ repeated OneofDescriptorProto oneof_decl = 8;
+
+ optional MessageOptions options = 7;
+
+ // Range of reserved tag numbers. Reserved tag numbers may not be used by
+ // fields or extension ranges in the same message. Reserved ranges may
+ // not overlap.
+ message ReservedRange {
+ optional int32 start = 1; // Inclusive.
+ optional int32 end = 2; // Exclusive.
+ }
+ repeated ReservedRange reserved_range = 9;
+ // Reserved field names, which may not be used by fields in the same message.
+ // A given name may only be reserved once.
+ repeated string reserved_name = 10;
+}
+
+message ExtensionRangeOptions {
+ // The parser stores options it doesn't recognize here. See above.
+ repeated UninterpretedOption uninterpreted_option = 999;
+
+ // Clients can define custom options in extensions of this message. See above.
+ extensions 1000 to max;
+}
+
+// Describes a field within a message.
+message FieldDescriptorProto {
+ enum Type {
+ // 0 is reserved for errors.
+ // Order is weird for historical reasons.
+ TYPE_DOUBLE = 1;
+ TYPE_FLOAT = 2;
+ // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
+ // negative values are likely.
+ TYPE_INT64 = 3;
+ TYPE_UINT64 = 4;
+ // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
+ // negative values are likely.
+ TYPE_INT32 = 5;
+ TYPE_FIXED64 = 6;
+ TYPE_FIXED32 = 7;
+ TYPE_BOOL = 8;
+ TYPE_STRING = 9;
+ // Tag-delimited aggregate.
+ // Group type is deprecated and not supported in proto3. However, Proto3
+ // implementations should still be able to parse the group wire format and
+ // treat group fields as unknown fields.
+ TYPE_GROUP = 10;
+ TYPE_MESSAGE = 11; // Length-delimited aggregate.
+
+ // New in version 2.
+ TYPE_BYTES = 12;
+ TYPE_UINT32 = 13;
+ TYPE_ENUM = 14;
+ TYPE_SFIXED32 = 15;
+ TYPE_SFIXED64 = 16;
+ TYPE_SINT32 = 17; // Uses ZigZag encoding.
+ TYPE_SINT64 = 18; // Uses ZigZag encoding.
+ };
+
+ enum Label {
+ // 0 is reserved for errors
+ LABEL_OPTIONAL = 1;
+ LABEL_REQUIRED = 2;
+ LABEL_REPEATED = 3;
+ };
+
+ optional string name = 1;
+ optional int32 number = 3;
+ optional Label label = 4;
+
+ // If type_name is set, this need not be set. If both this and type_name
+ // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
+ optional Type type = 5;
+
+ // For message and enum types, this is the name of the type. If the name
+ // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
+ // rules are used to find the type (i.e. first the nested types within this
+ // message are searched, then within the parent, on up to the root
+ // namespace).
+ optional string type_name = 6;
+
+ // For extensions, this is the name of the type being extended. It is
+ // resolved in the same manner as type_name.
+ optional string extendee = 2;
+
+ // For numeric types, contains the original text representation of the value.
+ // For booleans, "true" or "false".
+ // For strings, contains the default text contents (not escaped in any way).
+ // For bytes, contains the C escaped value. All bytes >= 128 are escaped.
+ // TODO(kenton): Base-64 encode?
+ optional string default_value = 7;
+
+ // If set, gives the index of a oneof in the containing type's oneof_decl
+ // list. This field is a member of that oneof.
+ optional int32 oneof_index = 9;
+
+ // JSON name of this field. The value is set by protocol compiler. If the
+ // user has set a "json_name" option on this field, that option's value
+ // will be used. Otherwise, it's deduced from the field's name by converting
+ // it to camelCase.
+ optional string json_name = 10;
+
+ optional FieldOptions options = 8;
+}
+
+// Describes a oneof.
+message OneofDescriptorProto {
+ optional string name = 1;
+ optional OneofOptions options = 2;
+}
+
+// Describes an enum type.
+message EnumDescriptorProto {
+ optional string name = 1;
+
+ repeated EnumValueDescriptorProto value = 2;
+
+ optional EnumOptions options = 3;
+
+ // Range of reserved numeric values. Reserved values may not be used by
+ // entries in the same enum. Reserved ranges may not overlap.
+ //
+ // Note that this is distinct from DescriptorProto.ReservedRange in that it
+ // is inclusive such that it can appropriately represent the entire int32
+ // domain.
+ message EnumReservedRange {
+ optional int32 start = 1; // Inclusive.
+ optional int32 end = 2; // Inclusive.
+ }
+
+ // Range of reserved numeric values. Reserved numeric values may not be used
+ // by enum values in the same enum declaration. Reserved ranges may not
+ // overlap.
+ repeated EnumReservedRange reserved_range = 4;
+
+ // Reserved enum value names, which may not be reused. A given name may only
+ // be reserved once.
+ repeated string reserved_name = 5;
+}
+
+// Describes a value within an enum.
+message EnumValueDescriptorProto {
+ optional string name = 1;
+ optional int32 number = 2;
+
+ optional EnumValueOptions options = 3;
+}
+
+// Describes a service.
+message ServiceDescriptorProto {
+ optional string name = 1;
+ repeated MethodDescriptorProto method = 2;
+
+ optional ServiceOptions options = 3;
+}
+
+// Describes a method of a service.
+message MethodDescriptorProto {
+ optional string name = 1;
+
+ // Input and output type names. These are resolved in the same way as
+ // FieldDescriptorProto.type_name, but must refer to a message type.
+ optional string input_type = 2;
+ optional string output_type = 3;
+
+ optional MethodOptions options = 4;
+
+ // Identifies if client streams multiple client messages
+ optional bool client_streaming = 5 [default=false];
+ // Identifies if server streams multiple server messages
+ optional bool server_streaming = 6 [default=false];
+}
+
+
+// ===================================================================
+// Options
+
+// Each of the definitions above may have "options" attached. These are
+// just annotations which may cause code to be generated slightly differently
+// or may contain hints for code that manipulates protocol messages.
+//
+// Clients may define custom options as extensions of the *Options messages.
+// These extensions may not yet be known at parsing time, so the parser cannot
+// store the values in them. Instead it stores them in a field in the *Options
+// message called uninterpreted_option. This field must have the same name
+// across all *Options messages. We then use this field to populate the
+// extensions when we build a descriptor, at which point all protos have been
+// parsed and so all extensions are known.
+//
+// Extension numbers for custom options may be chosen as follows:
+// * For options which will only be used within a single application or
+// organization, or for experimental options, use field numbers 50000
+// through 99999. It is up to you to ensure that you do not use the
+// same number for multiple options.
+// * For options which will be published and used publicly by multiple
+// independent entities, e-mail protobuf-global-extension-registry@google.com
+// to reserve extension numbers. Simply provide your project name (e.g.
+// Objective-C plugin) and your project website (if available) -- there's no
+// need to explain how you intend to use them. Usually you only need one
+// extension number. You can declare multiple options with only one extension
+// number by putting them in a sub-message. See the Custom Options section of
+// the docs for examples:
+// https://developers.google.com/protocol-buffers/docs/proto#options
+// If this turns out to be popular, a web service will be set up
+// to automatically assign option numbers.
+
+
+message FileOptions {
+
+ // Sets the Java package where classes generated from this .proto will be
+ // placed. By default, the proto package is used, but this is often
+ // inappropriate because proto packages do not normally start with backwards
+ // domain names.
+ optional string java_package = 1;
+
+
+ // If set, all the classes from the .proto file are wrapped in a single
+ // outer class with the given name. This applies to both Proto1
+ // (equivalent to the old "--one_java_file" option) and Proto2 (where
+ // a .proto always translates to a single class, but you may want to
+ // explicitly choose the class name).
+ optional string java_outer_classname = 8;
+
+ // If set true, then the Java code generator will generate a separate .java
+ // file for each top-level message, enum, and service defined in the .proto
+ // file. Thus, these types will *not* be nested inside the outer class
+ // named by java_outer_classname. However, the outer class will still be
+ // generated to contain the file's getDescriptor() method as well as any
+ // top-level extensions defined in the file.
+ optional bool java_multiple_files = 10 [default=false];
+
+ // This option does nothing.
+ optional bool java_generate_equals_and_hash = 20 [deprecated=true];
+
+ // If set true, then the Java2 code generator will generate code that
+ // throws an exception whenever an attempt is made to assign a non-UTF-8
+ // byte sequence to a string field.
+ // Message reflection will do the same.
+ // However, an extension field still accepts non-UTF-8 byte sequences.
+ // This option has no effect on when used with the lite runtime.
+ optional bool java_string_check_utf8 = 27 [default=false];
+
+
+ // Generated classes can be optimized for speed or code size.
+ enum OptimizeMode {
+ SPEED = 1; // Generate complete code for parsing, serialization,
+ // etc.
+ CODE_SIZE = 2; // Use ReflectionOps to implement these methods.
+ LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime.
+ }
+ optional OptimizeMode optimize_for = 9 [default=SPEED];
+
+ // Sets the Go package where structs generated from this .proto will be
+ // placed. If omitted, the Go package will be derived from the following:
+ // - The basename of the package import path, if provided.
+ // - Otherwise, the package statement in the .proto file, if present.
+ // - Otherwise, the basename of the .proto file, without extension.
+ optional string go_package = 11;
+
+
+
+ // Should generic services be generated in each language? "Generic" services
+ // are not specific to any particular RPC system. They are generated by the
+ // main code generators in each language (without additional plugins).
+ // Generic services were the only kind of service generation supported by
+ // early versions of google.protobuf.
+ //
+ // Generic services are now considered deprecated in favor of using plugins
+ // that generate code specific to your particular RPC system. Therefore,
+ // these default to false. Old code which depends on generic services should
+ // explicitly set them to true.
+ optional bool cc_generic_services = 16 [default=false];
+ optional bool java_generic_services = 17 [default=false];
+ optional bool py_generic_services = 18 [default=false];
+ optional bool php_generic_services = 42 [default=false];
+
+ // Is this file deprecated?
+ // Depending on the target platform, this can emit Deprecated annotations
+ // for everything in the file, or it will be completely ignored; in the very
+ // least, this is a formalization for deprecating files.
+ optional bool deprecated = 23 [default=false];
+
+ // Enables the use of arenas for the proto messages in this file. This applies
+ // only to generated classes for C++.
+ optional bool cc_enable_arenas = 31 [default=false];
+
+
+ // Sets the objective c class prefix which is prepended to all objective c
+ // generated classes from this .proto. There is no default.
+ optional string objc_class_prefix = 36;
+
+ // Namespace for generated classes; defaults to the package.
+ optional string csharp_namespace = 37;
+
+ // By default Swift generators will take the proto package and CamelCase it
+ // replacing '.' with underscore and use that to prefix the types/symbols
+ // defined. When this options is provided, they will use this value instead
+ // to prefix the types/symbols defined.
+ optional string swift_prefix = 39;
+
+ // Sets the php class prefix which is prepended to all php generated classes
+ // from this .proto. Default is empty.
+ optional string php_class_prefix = 40;
+
+ // Use this option to change the namespace of php generated classes. Default
+ // is empty. When this option is empty, the package name will be used for
+ // determining the namespace.
+ optional string php_namespace = 41;
+
+ // Use this option to change the namespace of php generated metadata classes.
+ // Default is empty. When this option is empty, the proto file name will be used
+ // for determining the namespace.
+ optional string php_metadata_namespace = 44;
+
+ // Use this option to change the package of ruby generated classes. Default
+ // is empty. When this option is not set, the package name will be used for
+ // determining the ruby package.
+ optional string ruby_package = 45;
+
+ // The parser stores options it doesn't recognize here.
+ // See the documentation for the "Options" section above.
+ repeated UninterpretedOption uninterpreted_option = 999;
+
+ // Clients can define custom options in extensions of this message.
+ // See the documentation for the "Options" section above.
+ extensions 1000 to max;
+
+ reserved 38;
+}
+
+message MessageOptions {
+ // Set true to use the old proto1 MessageSet wire format for extensions.
+ // This is provided for backwards-compatibility with the MessageSet wire
+ // format. You should not use this for any other reason: It's less
+ // efficient, has fewer features, and is more complicated.
+ //
+ // The message must be defined exactly as follows:
+ // message Foo {
+ // option message_set_wire_format = true;
+ // extensions 4 to max;
+ // }
+ // Note that the message cannot have any defined fields; MessageSets only
+ // have extensions.
+ //
+ // All extensions of your type must be singular messages; e.g. they cannot
+ // be int32s, enums, or repeated messages.
+ //
+ // Because this is an option, the above two restrictions are not enforced by
+ // the protocol compiler.
+ optional bool message_set_wire_format = 1 [default=false];
+
+ // Disables the generation of the standard "descriptor()" accessor, which can
+ // conflict with a field of the same name. This is meant to make migration
+ // from proto1 easier; new code should avoid fields named "descriptor".
+ optional bool no_standard_descriptor_accessor = 2 [default=false];
+
+ // Is this message deprecated?
+ // Depending on the target platform, this can emit Deprecated annotations
+ // for the message, or it will be completely ignored; in the very least,
+ // this is a formalization for deprecating messages.
+ optional bool deprecated = 3 [default=false];
+
+ // Whether the message is an automatically generated map entry type for the
+ // maps field.
+ //
+ // For maps fields:
+ // map<KeyType, ValueType> map_field = 1;
+ // The parsed descriptor looks like:
+ // message MapFieldEntry {
+ // option map_entry = true;
+ // optional KeyType key = 1;
+ // optional ValueType value = 2;
+ // }
+ // repeated MapFieldEntry map_field = 1;
+ //
+ // Implementations may choose not to generate the map_entry=true message, but
+ // use a native map in the target language to hold the keys and values.
+ // The reflection APIs in such implementations still need to work as
+ // if the field is a repeated message field.
+ //
+ // NOTE: Do not set the option in .proto files. Always use the maps syntax
+ // instead. The option should only be implicitly set by the proto compiler
+ // parser.
+ optional bool map_entry = 7;
+
+ reserved 8; // javalite_serializable
+ reserved 9; // javanano_as_lite
+
+ // The parser stores options it doesn't recognize here. See above.
+ repeated UninterpretedOption uninterpreted_option = 999;
+
+ // Clients can define custom options in extensions of this message. See above.
+ extensions 1000 to max;
+}
+
+message FieldOptions {
+ // The ctype option instructs the C++ code generator to use a different
+ // representation of the field than it normally would. See the specific
+ // options below. This option is not yet implemented in the open source
+ // release -- sorry, we'll try to include it in a future version!
+ optional CType ctype = 1 [default = STRING];
+ enum CType {
+ // Default mode.
+ STRING = 0;
+
+ CORD = 1;
+
+ STRING_PIECE = 2;
+ }
+ // The packed option can be enabled for repeated primitive fields to enable
+ // a more efficient representation on the wire. Rather than repeatedly
+ // writing the tag and type for each element, the entire array is encoded as
+ // a single length-delimited blob. In proto3, only explicit setting it to
+ // false will avoid using packed encoding.
+ optional bool packed = 2;
+
+ // The jstype option determines the JavaScript type used for values of the
+ // field. The option is permitted only for 64 bit integral and fixed types
+ // (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING
+ // is represented as JavaScript string, which avoids loss of precision that
+ // can happen when a large value is converted to a floating point JavaScript.
+ // Specifying JS_NUMBER for the jstype causes the generated JavaScript code to
+ // use the JavaScript "number" type. The behavior of the default option
+ // JS_NORMAL is implementation dependent.
+ //
+ // This option is an enum to permit additional types to be added, e.g.
+ // goog.math.Integer.
+ optional JSType jstype = 6 [default = JS_NORMAL];
+ enum JSType {
+ // Use the default type.
+ JS_NORMAL = 0;
+
+ // Use JavaScript strings.
+ JS_STRING = 1;
+
+ // Use JavaScript numbers.
+ JS_NUMBER = 2;
+ }
+
+ // Should this field be parsed lazily? Lazy applies only to message-type
+ // fields. It means that when the outer message is initially parsed, the
+ // inner message's contents will not be parsed but instead stored in encoded
+ // form. The inner message will actually be parsed when it is first accessed.
+ //
+ // This is only a hint. Implementations are free to choose whether to use
+ // eager or lazy parsing regardless of the value of this option. However,
+ // setting this option true suggests that the protocol author believes that
+ // using lazy parsing on this field is worth the additional bookkeeping
+ // overhead typically needed to implement it.
+ //
+ // This option does not affect the public interface of any generated code;
+ // all method signatures remain the same. Furthermore, thread-safety of the
+ // interface is not affected by this option; const methods remain safe to
+ // call from multiple threads concurrently, while non-const methods continue
+ // to require exclusive access.
+ //
+ //
+ // Note that implementations may choose not to check required fields within
+ // a lazy sub-message. That is, calling IsInitialized() on the outer message
+ // may return true even if the inner message has missing required fields.
+ // This is necessary because otherwise the inner message would have to be
+ // parsed in order to perform the check, defeating the purpose of lazy
+ // parsing. An implementation which chooses not to check required fields
+ // must be consistent about it. That is, for any particular sub-message, the
+ // implementation must either *always* check its required fields, or *never*
+ // check its required fields, regardless of whether or not the message has
+ // been parsed.
+ optional bool lazy = 5 [default=false];
+
+ // Is this field deprecated?
+ // Depending on the target platform, this can emit Deprecated annotations
+ // for accessors, or it will be completely ignored; in the very least, this
+ // is a formalization for deprecating fields.
+ optional bool deprecated = 3 [default=false];
+
+ // For Google-internal migration only. Do not use.
+ optional bool weak = 10 [default=false];
+
+
+ // The parser stores options it doesn't recognize here. See above.
+ repeated UninterpretedOption uninterpreted_option = 999;
+
+ // Clients can define custom options in extensions of this message. See above.
+ extensions 1000 to max;
+
+ reserved 4; // removed jtype
+}
+
+message OneofOptions {
+ // The parser stores options it doesn't recognize here. See above.
+ repeated UninterpretedOption uninterpreted_option = 999;
+
+ // Clients can define custom options in extensions of this message. See above.
+ extensions 1000 to max;
+}
+
+message EnumOptions {
+
+ // Set this option to true to allow mapping different tag names to the same
+ // value.
+ optional bool allow_alias = 2;
+
+ // Is this enum deprecated?
+ // Depending on the target platform, this can emit Deprecated annotations
+ // for the enum, or it will be completely ignored; in the very least, this
+ // is a formalization for deprecating enums.
+ optional bool deprecated = 3 [default=false];
+
+ reserved 5; // javanano_as_lite
+
+ // The parser stores options it doesn't recognize here. See above.
+ repeated UninterpretedOption uninterpreted_option = 999;
+
+ // Clients can define custom options in extensions of this message. See above.
+ extensions 1000 to max;
+}
+
+message EnumValueOptions {
+ // Is this enum value deprecated?
+ // Depending on the target platform, this can emit Deprecated annotations
+ // for the enum value, or it will be completely ignored; in the very least,
+ // this is a formalization for deprecating enum values.
+ optional bool deprecated = 1 [default=false];
+
+ // The parser stores options it doesn't recognize here. See above.
+ repeated UninterpretedOption uninterpreted_option = 999;
+
+ // Clients can define custom options in extensions of this message. See above.
+ extensions 1000 to max;
+}
+
+message ServiceOptions {
+
+ // Note: Field numbers 1 through 32 are reserved for Google's internal RPC
+ // framework. We apologize for hoarding these numbers to ourselves, but
+ // we were already using them long before we decided to release Protocol
+ // Buffers.
+
+ // Is this service deprecated?
+ // Depending on the target platform, this can emit Deprecated annotations
+ // for the service, or it will be completely ignored; in the very least,
+ // this is a formalization for deprecating services.
+ optional bool deprecated = 33 [default=false];
+
+ // The parser stores options it doesn't recognize here. See above.
+ repeated UninterpretedOption uninterpreted_option = 999;
+
+ // Clients can define custom options in extensions of this message. See above.
+ extensions 1000 to max;
+}
+
+message MethodOptions {
+
+ // Note: Field numbers 1 through 32 are reserved for Google's internal RPC
+ // framework. We apologize for hoarding these numbers to ourselves, but
+ // we were already using them long before we decided to release Protocol
+ // Buffers.
+
+ // Is this method deprecated?
+ // Depending on the target platform, this can emit Deprecated annotations
+ // for the method, or it will be completely ignored; in the very least,
+ // this is a formalization for deprecating methods.
+ optional bool deprecated = 33 [default=false];
+
+ // Is this method side-effect-free (or safe in HTTP parlance), or idempotent,
+ // or neither? HTTP based RPC implementation may choose GET verb for safe
+ // methods, and PUT verb for idempotent methods instead of the default POST.
+ enum IdempotencyLevel {
+ IDEMPOTENCY_UNKNOWN = 0;
+ NO_SIDE_EFFECTS = 1; // implies idempotent
+ IDEMPOTENT = 2; // idempotent, but may have side effects
+ }
+ optional IdempotencyLevel idempotency_level =
+ 34 [default=IDEMPOTENCY_UNKNOWN];
+
+ // The parser stores options it doesn't recognize here. See above.
+ repeated UninterpretedOption uninterpreted_option = 999;
+
+ // Clients can define custom options in extensions of this message. See above.
+ extensions 1000 to max;
+}
+
+
+// A message representing a option the parser does not recognize. This only
+// appears in options protos created by the compiler::Parser class.
+// DescriptorPool resolves these when building Descriptor objects. Therefore,
+// options protos in descriptor objects (e.g. returned by Descriptor::options(),
+// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
+// in them.
+message UninterpretedOption {
+ // The name of the uninterpreted option. Each string represents a segment in
+ // a dot-separated name. is_extension is true iff a segment represents an
+ // extension (denoted with parentheses in options specs in .proto files).
+ // E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents
+ // "foo.(bar.baz).qux".
+ message NamePart {
+ required string name_part = 1;
+ required bool is_extension = 2;
+ }
+ repeated NamePart name = 2;
+
+ // The value of the uninterpreted option, in whatever type the tokenizer
+ // identified it as during parsing. Exactly one of these should be set.
+ optional string identifier_value = 3;
+ optional uint64 positive_int_value = 4;
+ optional int64 negative_int_value = 5;
+ optional double double_value = 6;
+ optional bytes string_value = 7;
+ optional string aggregate_value = 8;
+}
+
+// ===================================================================
+// Optional source code info
+
+// Encapsulates information about the original source file from which a
+// FileDescriptorProto was generated.
+message SourceCodeInfo {
+ // A Location identifies a piece of source code in a .proto file which
+ // corresponds to a particular definition. This information is intended
+ // to be useful to IDEs, code indexers, documentation generators, and similar
+ // tools.
+ //
+ // For example, say we have a file like:
+ // message Foo {
+ // optional string foo = 1;
+ // }
+ // Let's look at just the field definition:
+ // optional string foo = 1;
+ // ^ ^^ ^^ ^ ^^^
+ // a bc de f ghi
+ // We have the following locations:
+ // span path represents
+ // [a,i) [ 4, 0, 2, 0 ] The whole field definition.
+ // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
+ // [c,d) [ 4, 0, 2, 0, 5 ] The type (string).
+ // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
+ // [g,h) [ 4, 0, 2, 0, 3 ] The number (1).
+ //
+ // Notes:
+ // - A location may refer to a repeated field itself (i.e. not to any
+ // particular index within it). This is used whenever a set of elements are
+ // logically enclosed in a single code segment. For example, an entire
+ // extend block (possibly containing multiple extension definitions) will
+ // have an outer location whose path refers to the "extensions" repeated
+ // field without an index.
+ // - Multiple locations may have the same path. This happens when a single
+ // logical declaration is spread out across multiple places. The most
+ // obvious example is the "extend" block again -- there may be multiple
+ // extend blocks in the same scope, each of which will have the same path.
+ // - A location's span is not always a subset of its parent's span. For
+ // example, the "extendee" of an extension declaration appears at the
+ // beginning of the "extend" block and is shared by all extensions within
+ // the block.
+ // - Just because a location's span is a subset of some other location's span
+ // does not mean that it is a descendant. For example, a "group" defines
+ // both a type and a field in a single declaration. Thus, the locations
+ // corresponding to the type and field and their components will overlap.
+ // - Code which tries to interpret locations should probably be designed to
+ // ignore those that it doesn't understand, as more types of locations could
+ // be recorded in the future.
+ repeated Location location = 1;
+ message Location {
+ // Identifies which part of the FileDescriptorProto was defined at this
+ // location.
+ //
+ // Each element is a field number or an index. They form a path from
+ // the root FileDescriptorProto to the place where the definition. For
+ // example, this path:
+ // [ 4, 3, 2, 7, 1 ]
+ // refers to:
+ // file.message_type(3) // 4, 3
+ // .field(7) // 2, 7
+ // .name() // 1
+ // This is because FileDescriptorProto.message_type has field number 4:
+ // repeated DescriptorProto message_type = 4;
+ // and DescriptorProto.field has field number 2:
+ // repeated FieldDescriptorProto field = 2;
+ // and FieldDescriptorProto.name has field number 1:
+ // optional string name = 1;
+ //
+ // Thus, the above path gives the location of a field name. If we removed
+ // the last element:
+ // [ 4, 3, 2, 7 ]
+ // this path refers to the whole field declaration (from the beginning
+ // of the label to the terminating semicolon).
+ repeated int32 path = 1 [packed=true];
+
+ // Always has exactly three or four elements: start line, start column,
+ // end line (optional, otherwise assumed same as start line), end column.
+ // These are packed into a single field for efficiency. Note that line
+ // and column numbers are zero-based -- typically you will want to add
+ // 1 to each before displaying to a user.
+ repeated int32 span = 2 [packed=true];
+
+ // If this SourceCodeInfo represents a complete declaration, these are any
+ // comments appearing before and after the declaration which appear to be
+ // attached to the declaration.
+ //
+ // A series of line comments appearing on consecutive lines, with no other
+ // tokens appearing on those lines, will be treated as a single comment.
+ //
+ // leading_detached_comments will keep paragraphs of comments that appear
+ // before (but not connected to) the current element. Each paragraph,
+ // separated by empty lines, will be one comment element in the repeated
+ // field.
+ //
+ // Only the comment content is provided; comment markers (e.g. //) are
+ // stripped out. For block comments, leading whitespace and an asterisk
+ // will be stripped from the beginning of each line other than the first.
+ // Newlines are included in the output.
+ //
+ // Examples:
+ //
+ // optional int32 foo = 1; // Comment attached to foo.
+ // // Comment attached to bar.
+ // optional int32 bar = 2;
+ //
+ // optional string baz = 3;
+ // // Comment attached to baz.
+ // // Another line attached to baz.
+ //
+ // // Comment attached to qux.
+ // //
+ // // Another line attached to qux.
+ // optional double qux = 4;
+ //
+ // // Detached comment for corge. This is not leading or trailing comments
+ // // to qux or corge because there are blank lines separating it from
+ // // both.
+ //
+ // // Detached comment for corge paragraph 2.
+ //
+ // optional string corge = 5;
+ // /* Block comment attached
+ // * to corge. Leading asterisks
+ // * will be removed. */
+ // /* Block comment attached to
+ // * grault. */
+ // optional int32 grault = 6;
+ //
+ // // ignored detached comments.
+ optional string leading_comments = 3;
+ optional string trailing_comments = 4;
+ repeated string leading_detached_comments = 6;
+ }
+}
+
+// Describes the relationship between generated code and its original source
+// file. A GeneratedCodeInfo message is associated with only one generated
+// source file, but may contain references to different source .proto files.
+message GeneratedCodeInfo {
+ // An Annotation connects some span of text in generated code to an element
+ // of its generating .proto file.
+ repeated Annotation annotation = 1;
+ message Annotation {
+ // Identifies the element in the original source .proto file. This field
+ // is formatted the same as SourceCodeInfo.Location.path.
+ repeated int32 path = 1 [packed=true];
+
+ // Identifies the filesystem path to the original source .proto.
+ optional string source_file = 2;
+
+ // Identifies the starting offset in bytes in the generated code
+ // that relates to the identified object.
+ optional int32 begin = 3;
+
+ // Identifies the ending offset in bytes in the generated code that
+ // relates to the identified offset. The end offset should be one past
+ // the last relevant byte (so the length of the text = end - begin).
+ optional int32 end = 4;
+ }
+}

protos/google/protobuf/duration.proto

@@ -0,0 +1,117 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto3";
+
+package google.protobuf;
+
+option csharp_namespace = "Google.Protobuf.WellKnownTypes";
+option cc_enable_arenas = true;
+option go_package = "github.com/golang/protobuf/ptypes/duration";
+option java_package = "com.google.protobuf";
+option java_outer_classname = "DurationProto";
+option java_multiple_files = true;
+option objc_class_prefix = "GPB";
+
+// A Duration represents a signed, fixed-length span of time represented
+// as a count of seconds and fractions of seconds at nanosecond
+// resolution. It is independent of any calendar and concepts like "day"
+// or "month". It is related to Timestamp in that the difference between
+// two Timestamp values is a Duration and it can be added or subtracted
+// from a Timestamp. Range is approximately +-10,000 years.
+//
+// # Examples
+//
+// Example 1: Compute Duration from two Timestamps in pseudo code.
+//
+// Timestamp start = ...;
+// Timestamp end = ...;
+// Duration duration = ...;
+//
+// duration.seconds = end.seconds - start.seconds;
+// duration.nanos = end.nanos - start.nanos;
+//
+// if (duration.seconds < 0 && duration.nanos > 0) {
+// duration.seconds += 1;
+// duration.nanos -= 1000000000;
+// } else if (durations.seconds > 0 && duration.nanos < 0) {
+// duration.seconds -= 1;
+// duration.nanos += 1000000000;
+// }
+//
+// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
+//
+// Timestamp start = ...;
+// Duration duration = ...;
+// Timestamp end = ...;
+//
+// end.seconds = start.seconds + duration.seconds;
+// end.nanos = start.nanos + duration.nanos;
+//
+// if (end.nanos < 0) {
+// end.seconds -= 1;
+// end.nanos += 1000000000;
+// } else if (end.nanos >= 1000000000) {
+// end.seconds += 1;
+// end.nanos -= 1000000000;
+// }
+//
+// Example 3: Compute Duration from datetime.timedelta in Python.
+//
+// td = datetime.timedelta(days=3, minutes=10)
+// duration = Duration()
+// duration.FromTimedelta(td)
+//
+// # JSON Mapping
+//
+// In JSON format, the Duration type is encoded as a string rather than an
+// object, where the string ends in the suffix "s" (indicating seconds) and
+// is preceded by the number of seconds, with nanoseconds expressed as
+// fractional seconds. For example, 3 seconds with 0 nanoseconds should be
+// encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
+// be expressed in JSON format as "3.000000001s", and 3 seconds and 1
+// microsecond should be expressed in JSON format as "3.000001s".
+//
+//
+message Duration {
+
+ // Signed seconds of the span of time. Must be from -315,576,000,000
+ // to +315,576,000,000 inclusive. Note: these bounds are computed from:
+ // 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
+ int64 seconds = 1;
+
+ // Signed fractions of a second at nanosecond resolution of the span
+ // of time. Durations less than one second are represented with a 0
+ // `seconds` field and a positive or negative `nanos` field. For durations
+ // of one second or more, a non-zero value for the `nanos` field must be
+ // of the same sign as the `seconds` field. Must be from -999,999,999
+ // to +999,999,999 inclusive.
+ int32 nanos = 2;
+}

protos/google/protobuf/empty.proto

@@ -0,0 +1,52 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto3";
+
+package google.protobuf;
+
+option csharp_namespace = "Google.Protobuf.WellKnownTypes";
+option go_package = "github.com/golang/protobuf/ptypes/empty";
+option java_package = "com.google.protobuf";
+option java_outer_classname = "EmptyProto";
+option java_multiple_files = true;
+option objc_class_prefix = "GPB";
+option cc_enable_arenas = true;
+
+// A generic empty message that you can re-use to avoid defining duplicated
+// empty messages in your APIs. A typical example is to use it as the request
+// or the response type of an API method. For instance:
+//
+// service Foo {
+// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
+// }
+//
+// The JSON representation for `Empty` is empty JSON object `{}`.
+message Empty {}

protos/google/protobuf/field_mask.proto

@@ -0,0 +1,245 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto3";
+
+package google.protobuf;
+
+option csharp_namespace = "Google.Protobuf.WellKnownTypes";
+option java_package = "com.google.protobuf";
+option java_outer_classname = "FieldMaskProto";
+option java_multiple_files = true;
+option objc_class_prefix = "GPB";
+option go_package = "google.golang.org/genproto/protobuf/field_mask;field_mask";
+option cc_enable_arenas = true;
+
+// `FieldMask` represents a set of symbolic field paths, for example:
+//
+// paths: "f.a"
+// paths: "f.b.d"
+//
+// Here `f` represents a field in some root message, `a` and `b`
+// fields in the message found in `f`, and `d` a field found in the
+// message in `f.b`.
+//
+// Field masks are used to specify a subset of fields that should be
+// returned by a get operation or modified by an update operation.
+// Field masks also have a custom JSON encoding (see below).
+//
+// # Field Masks in Projections
+//
+// When used in the context of a projection, a response message or
+// sub-message is filtered by the API to only contain those fields as
+// specified in the mask. For example, if the mask in the previous
+// example is applied to a response message as follows:
+//
+// f {
+// a : 22
+// b {
+// d : 1
+// x : 2
+// }
+// y : 13
+// }
+// z: 8
+//
+// The result will not contain specific values for fields x,y and z
+// (their value will be set to the default, and omitted in proto text
+// output):
+//
+//
+// f {
+// a : 22
+// b {
+// d : 1
+// }
+// }
+//
+// A repeated field is not allowed except at the last position of a
+// paths string.
+//
+// If a FieldMask object is not present in a get operation, the
+// operation applies to all fields (as if a FieldMask of all fields
+// had been specified).
+//
+// Note that a field mask does not necessarily apply to the
+// top-level response message. In case of a REST get operation, the
+// field mask applies directly to the response, but in case of a REST
+// list operation, the mask instead applies to each individual message
+// in the returned resource list. In case of a REST custom method,
+// other definitions may be used. Where the mask applies will be
+// clearly documented together with its declaration in the API. In
+// any case, the effect on the returned resource/resources is required
+// behavior for APIs.
+//
+// # Field Masks in Update Operations
+//
+// A field mask in update operations specifies which fields of the
+// targeted resource are going to be updated. The API is required
+// to only change the values of the fields as specified in the mask
+// and leave the others untouched. If a resource is passed in to
+// describe the updated values, the API ignores the values of all
+// fields not covered by the mask.
+//
+// If a repeated field is specified for an update operation, new values will
+// be appended to the existing repeated field in the target resource. Note that
+// a repeated field is only allowed in the last position of a `paths` string.
+//
+// If a sub-message is specified in the last position of the field mask for an
+// update operation, then new value will be merged into the existing sub-message
+// in the target resource.
+//
+// For example, given the target message:
+//
+// f {
+// b {
+// d: 1
+// x: 2
+// }
+// c: [1]
+// }
+//
+// And an update message:
+//
+// f {
+// b {
+// d: 10
+// }
+// c: [2]
+// }
+//
+// then if the field mask is:
+//
+// paths: ["f.b", "f.c"]
+//
+// then the result will be:
+//
+// f {
+// b {
+// d: 10
+// x: 2
+// }
+// c: [1, 2]
+// }
+//
+// An implementation may provide options to override this default behavior for
+// repeated and message fields.
+//
+// In order to reset a field's value to the default, the field must
+// be in the mask and set to the default value in the provided resource.
+// Hence, in order to reset all fields of a resource, provide a default
+// instance of the resource and set all fields in the mask, or do
+// not provide a mask as described below.
+//
+// If a field mask is not present on update, the operation applies to
+// all fields (as if a field mask of all fields has been specified).
+// Note that in the presence of schema evolution, this may mean that
+// fields the client does not know and has therefore not filled into
+// the request will be reset to their default. If this is unwanted
+// behavior, a specific service may require a client to always specify
+// a field mask, producing an error if not.
+//
+// As with get operations, the location of the resource which
+// describes the updated values in the request message depends on the
+// operation kind. In any case, the effect of the field mask is
+// required to be honored by the API.
+//
+// ## Considerations for HTTP REST
+//
+// The HTTP kind of an update operation which uses a field mask must
+// be set to PATCH instead of PUT in order to satisfy HTTP semantics
+// (PUT must only be used for full updates).
+//
+// # JSON Encoding of Field Masks
+//
+// In JSON, a field mask is encoded as a single string where paths are
+// separated by a comma. Fields name in each path are converted
+// to/from lower-camel naming conventions.
+//
+// As an example, consider the following message declarations:
+//
+// message Profile {
+// User user = 1;
+// Photo photo = 2;
+// }
+// message User {
+// string display_name = 1;
+// string address = 2;
+// }
+//
+// In proto a field mask for `Profile` may look as such:
+//
+// mask {
+// paths: "user.display_name"
+// paths: "photo"
+// }
+//
+// In JSON, the same mask is represented as below:
+//
+// {
+// mask: "user.displayName,photo"
+// }
+//
+// # Field Masks and Oneof Fields
+//
+// Field masks treat fields in oneofs just as regular fields. Consider the
+// following message:
+//
+// message SampleMessage {
+// oneof test_oneof {
+// string name = 4;
+// SubMessage sub_message = 9;
+// }
+// }
+//
+// The field mask can be:
+//
+// mask {
+// paths: "name"
+// }
+//
+// Or:
+//
+// mask {
+// paths: "sub_message"
+// }
+//
+// Note that oneof type names ("test_oneof" in this case) cannot be used in
+// paths.
+//
+// ## Field Mask Verification
+//
+// The implementation of any API method which has a FieldMask type field in the
+// request should verify the included field paths, and return an
+// `INVALID_ARGUMENT` error if any path is duplicated or unmappable.
+message FieldMask {
+ // The set of field mask paths.
+ repeated string paths = 1;
+}

protos/google/protobuf/source_context.proto

@@ -0,0 +1,48 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto3";
+
+package google.protobuf;
+
+option csharp_namespace = "Google.Protobuf.WellKnownTypes";
+option java_package = "com.google.protobuf";
+option java_outer_classname = "SourceContextProto";
+option java_multiple_files = true;
+option objc_class_prefix = "GPB";
+option go_package = "google.golang.org/genproto/protobuf/source_context;source_context";
+
+// `SourceContext` represents information about the source of a
+// protobuf element, like the file in which it is defined.
+message SourceContext {
+ // The path-qualified name of the .proto file that contained the associated
+ // protobuf element. For example: `"google/protobuf/source_context.proto"`.
+ string file_name = 1;
+}

protos/google/protobuf/struct.proto

@@ -0,0 +1,96 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto3";
+
+package google.protobuf;
+
+option csharp_namespace = "Google.Protobuf.WellKnownTypes";
+option cc_enable_arenas = true;
+option go_package = "github.com/golang/protobuf/ptypes/struct;structpb";
+option java_package = "com.google.protobuf";
+option java_outer_classname = "StructProto";
+option java_multiple_files = true;
+option objc_class_prefix = "GPB";
+
+
+// `Struct` represents a structured data value, consisting of fields
+// which map to dynamically typed values. In some languages, `Struct`
+// might be supported by a native representation. For example, in
+// scripting languages like JS a struct is represented as an
+// object. The details of that representation are described together
+// with the proto support for the language.
+//
+// The JSON representation for `Struct` is JSON object.
+message Struct {
+ // Unordered map of dynamically typed values.
+ map<string, Value> fields = 1;
+}
+
+// `Value` represents a dynamically typed value which can be either
+// null, a number, a string, a boolean, a recursive struct value, or a
+// list of values. A producer of value is expected to set one of that
+// variants, absence of any variant indicates an error.
+//
+// The JSON representation for `Value` is JSON value.
+message Value {
+ // The kind of value.
+ oneof kind {
+ // Represents a null value.
+ NullValue null_value = 1;
+ // Represents a double value.
+ double number_value = 2;
+ // Represents a string value.
+ string string_value = 3;
+ // Represents a boolean value.
+ bool bool_value = 4;
+ // Represents a structured value.
+ Struct struct_value = 5;
+ // Represents a repeated `Value`.
+ ListValue list_value = 6;
+ }
+}
+
+// `NullValue` is a singleton enumeration to represent the null value for the
+// `Value` type union.
+//
+// The JSON representation for `NullValue` is JSON `null`.
+enum NullValue {
+ // Null value.
+ NULL_VALUE = 0;
+}
+
+// `ListValue` is a wrapper around a repeated field of values.
+//
+// The JSON representation for `ListValue` is JSON array.
+message ListValue {
+ // Repeated field of dynamically typed values.
+ repeated Value values = 1;
+}

protos/google/protobuf/timestamp.proto

@@ -0,0 +1,137 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto3";
+
+package google.protobuf;
+
+option csharp_namespace = "Google.Protobuf.WellKnownTypes";
+option cc_enable_arenas = true;
+option go_package = "github.com/golang/protobuf/ptypes/timestamp";
+option java_package = "com.google.protobuf";
+option java_outer_classname = "TimestampProto";
+option java_multiple_files = true;
+option objc_class_prefix = "GPB";
+
+// A Timestamp represents a point in time independent of any time zone or local
+// calendar, encoded as a count of seconds and fractions of seconds at
+// nanosecond resolution. The count is relative to an epoch at UTC midnight on
+// January 1, 1970, in the proleptic Gregorian calendar which extends the
+// Gregorian calendar backwards to year one.
+//
+// All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
+// second table is needed for interpretation, using a [24-hour linear
+// smear](https://developers.google.com/time/smear).
+//
+// The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
+// restricting to that range, we ensure that we can convert to and from [RFC
+// 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
+//
+// # Examples
+//
+// Example 1: Compute Timestamp from POSIX `time()`.
+//
+// Timestamp timestamp;
+// timestamp.set_seconds(time(NULL));
+// timestamp.set_nanos(0);
+//
+// Example 2: Compute Timestamp from POSIX `gettimeofday()`.
+//
+// struct timeval tv;
+// gettimeofday(&tv, NULL);
+//
+// Timestamp timestamp;
+// timestamp.set_seconds(tv.tv_sec);
+// timestamp.set_nanos(tv.tv_usec * 1000);
+//
+// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
+//
+// FILETIME ft;
+// GetSystemTimeAsFileTime(&ft);
+// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
+//
+// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
+// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
+// Timestamp timestamp;
+// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
+// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
+//
+// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
+//
+// long millis = System.currentTimeMillis();
+//
+// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
+// .setNanos((int) ((millis % 1000) * 1000000)).build();
+//
+//
+// Example 5: Compute Timestamp from current time in Python.
+//
+// timestamp = Timestamp()
+// timestamp.GetCurrentTime()
+//
+// # JSON Mapping
+//
+// In JSON format, the Timestamp type is encoded as a string in the
+// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
+// format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
+// where {year} is always expressed using four digits while {month}, {day},
+// {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
+// seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
+// are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
+// is required. A proto3 JSON serializer should always use UTC (as indicated by
+// "Z") when printing the Timestamp type and a proto3 JSON parser should be
+// able to accept both UTC and other timezones (as indicated by an offset).
+//
+// For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
+// 01:30 UTC on January 15, 2017.
+//
+// In JavaScript, one can convert a Date object to this format using the
+// standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
+// method. In Python, a standard `datetime.datetime` object can be converted
+// to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime)
+// with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
+// can use the Joda Time's [`ISODateTimeFormat.dateTime()`](
+// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
+// ) to obtain a formatter capable of generating timestamps in this format.
+//
+//
+message Timestamp {
+
+ // Represents seconds of UTC time since Unix epoch
+ // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
+ // 9999-12-31T23:59:59Z inclusive.
+ int64 seconds = 1;
+
+ // Non-negative fractions of a second at nanosecond resolution. Negative
+ // second values with fractions must still have non-negative nanos values
+ // that count forward in time. Must be from 0 to 999,999,999
+ // inclusive.
+ int32 nanos = 2;
+}

protos/google/protobuf/type.proto

@@ -0,0 +1,187 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto3";
+
+package google.protobuf;
+
+import "google/protobuf/any.proto";
+import "google/protobuf/source_context.proto";
+
+option csharp_namespace = "Google.Protobuf.WellKnownTypes";
+option cc_enable_arenas = true;
+option java_package = "com.google.protobuf";
+option java_outer_classname = "TypeProto";
+option java_multiple_files = true;
+option objc_class_prefix = "GPB";
+option go_package = "google.golang.org/genproto/protobuf/ptype;ptype";
+
+// A protocol buffer message type.
+message Type {
+ // The fully qualified message name.
+ string name = 1;
+ // The list of fields.
+ repeated Field fields = 2;
+ // The list of types appearing in `oneof` definitions in this type.
+ repeated string oneofs = 3;
+ // The protocol buffer options.
+ repeated Option options = 4;
+ // The source context.
+ SourceContext source_context = 5;
+ // The source syntax.
+ Syntax syntax = 6;
+}
+
+// A single field of a message type.
+message Field {
+ // Basic field types.
+ enum Kind {
+ // Field type unknown.
+ TYPE_UNKNOWN = 0;
+ // Field type double.
+ TYPE_DOUBLE = 1;
+ // Field type float.
+ TYPE_FLOAT = 2;
+ // Field type int64.
+ TYPE_INT64 = 3;
+ // Field type uint64.
+ TYPE_UINT64 = 4;
+ // Field type int32.
+ TYPE_INT32 = 5;
+ // Field type fixed64.
+ TYPE_FIXED64 = 6;
+ // Field type fixed32.
+ TYPE_FIXED32 = 7;
+ // Field type bool.
+ TYPE_BOOL = 8;
+ // Field type string.
+ TYPE_STRING = 9;
+ // Field type group. Proto2 syntax only, and deprecated.
+ TYPE_GROUP = 10;
+ // Field type message.
+ TYPE_MESSAGE = 11;
+ // Field type bytes.
+ TYPE_BYTES = 12;
+ // Field type uint32.
+ TYPE_UINT32 = 13;
+ // Field type enum.
+ TYPE_ENUM = 14;
+ // Field type sfixed32.
+ TYPE_SFIXED32 = 15;
+ // Field type sfixed64.
+ TYPE_SFIXED64 = 16;
+ // Field type sint32.
+ TYPE_SINT32 = 17;
+ // Field type sint64.
+ TYPE_SINT64 = 18;
+ };
+
+ // Whether a field is optional, required, or repeated.
+ enum Cardinality {
+ // For fields with unknown cardinality.
+ CARDINALITY_UNKNOWN = 0;
+ // For optional fields.
+ CARDINALITY_OPTIONAL = 1;
+ // For required fields. Proto2 syntax only.
+ CARDINALITY_REQUIRED = 2;
+ // For repeated fields.
+ CARDINALITY_REPEATED = 3;
+ };
+
+ // The field type.
+ Kind kind = 1;
+ // The field cardinality.
+ Cardinality cardinality = 2;
+ // The field number.
+ int32 number = 3;
+ // The field name.
+ string name = 4;
+ // The field type URL, without the scheme, for message or enumeration
+ // types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
+ string type_url = 6;
+ // The index of the field type in `Type.oneofs`, for message or enumeration
+ // types. The first type has index 1; zero means the type is not in the list.
+ int32 oneof_index = 7;
+ // Whether to use alternative packed wire representation.
+ bool packed = 8;
+ // The protocol buffer options.
+ repeated Option options = 9;
+ // The field JSON name.
+ string json_name = 10;
+ // The string value of the default value of this field. Proto2 syntax only.
+ string default_value = 11;
+}
+
+// Enum type definition.
+message Enum {
+ // Enum type name.
+ string name = 1;
+ // Enum value definitions.
+ repeated EnumValue enumvalue = 2;
+ // Protocol buffer options.
+ repeated Option options = 3;
+ // The source context.
+ SourceContext source_context = 4;
+ // The source syntax.
+ Syntax syntax = 5;
+}
+
+// Enum value definition.
+message EnumValue {
+ // Enum value name.
+ string name = 1;
+ // Enum value number.
+ int32 number = 2;
+ // Protocol buffer options.
+ repeated Option options = 3;
+}
+
+// A protocol buffer option, which can be attached to a message, field,
+// enumeration, etc.
+message Option {
+ // The option's name. For protobuf built-in options (options defined in
+ // descriptor.proto), this is the short name. For example, `"map_entry"`.
+ // For custom options, it should be the fully-qualified name. For example,
+ // `"google.api.http"`.
+ string name = 1;
+ // The option's value packed in an Any message. If the value is a primitive,
+ // the corresponding wrapper type defined in google/protobuf/wrappers.proto
+ // should be used. If the value is an enum, it should be stored as an int32
+ // value using the google.protobuf.Int32Value type.
+ Any value = 2;
+}
+
+// The syntax in which a protocol buffer element is defined.
+enum Syntax {
+ // Syntax `proto2`.
+ SYNTAX_PROTO2 = 0;
+ // Syntax `proto3`.
+ SYNTAX_PROTO3 = 1;
+}

protos/google/protobuf/util/json_format.proto

@@ -0,0 +1,119 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Author: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+//
+// A proto file we will use for unit testing.
+
+syntax = "proto2";
+package protobuf_unittest;
+
+
+message TestFlagsAndStrings {
+ required int32 A = 1;
+ repeated group RepeatedGroup = 2 {
+ required string f = 3;
+ }
+}
+
+message TestBase64ByteArrays {
+ required bytes a = 1;
+}
+
+message TestJavaScriptJSON {
+ optional int32 a = 1;
+ optional float final = 2;
+ optional string in = 3;
+ optional string Var = 4;
+}
+
+message TestJavaScriptOrderJSON1 {
+ optional int32 d = 1;
+ optional int32 c = 2;
+ optional bool x = 3;
+ optional int32 b = 4;
+ optional int32 a = 5;
+}
+
+message TestJavaScriptOrderJSON2 {
+ optional int32 d = 1;
+ optional int32 c = 2;
+ optional bool x = 3;
+ optional int32 b = 4;
+ optional int32 a = 5;
+ repeated TestJavaScriptOrderJSON1 z = 6;
+}
+
+message TestLargeInt {
+ required int64 a = 1;
+ required uint64 b = 2;
+}
+
+message TestNumbers {
+ enum MyType {
+ OK = 0;
+ WARNING = 1;
+ ERROR = 2;
+ }
+ optional MyType a = 1;
+ optional int32 b = 2;
+ optional float c = 3;
+ optional bool d = 4;
+ optional double e = 5;
+ optional uint32 f = 6;
+}
+
+
+message TestCamelCase {
+ optional string normal_field = 1;
+ optional int32 CAPITAL_FIELD = 2;
+ optional int32 CamelCaseField = 3;
+}
+
+message TestBoolMap {
+ map<bool, int32> bool_map = 1;
+}
+
+message TestRecursion {
+ optional int32 value = 1;
+ optional TestRecursion child = 2;
+}
+
+message TestStringMap {
+ map<string, string> string_map = 1;
+}
+
+message TestStringSerializer {
+ optional string scalar_string = 1;
+ repeated string repeated_string = 2;
+ map<string, string> string_map = 3;
+}

protos/google/protobuf/util/json_format_proto3.proto

@@ -0,0 +1,189 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto3";
+
+package proto3;
+
+option java_package = "com.google.protobuf.util";
+option java_outer_classname = "JsonFormatProto3";
+
+import "google/protobuf/duration.proto";
+import "google/protobuf/timestamp.proto";
+import "google/protobuf/wrappers.proto";
+import "google/protobuf/struct.proto";
+import "google/protobuf/any.proto";
+import "google/protobuf/field_mask.proto";
+import "google/protobuf/unittest.proto";
+
+enum EnumType {
+ FOO = 0;
+ BAR = 1;
+}
+
+message MessageType {
+ int32 value = 1;
+}
+
+message TestMessage {
+ bool bool_value = 1;
+ int32 int32_value = 2;
+ int64 int64_value = 3;
+ uint32 uint32_value = 4;
+ uint64 uint64_value = 5;
+ float float_value = 6;
+ double double_value = 7;
+ string string_value = 8;
+ bytes bytes_value = 9;
+ EnumType enum_value = 10;
+ MessageType message_value = 11;
+
+ repeated bool repeated_bool_value = 21;
+ repeated int32 repeated_int32_value = 22;
+ repeated int64 repeated_int64_value = 23;
+ repeated uint32 repeated_uint32_value = 24;
+ repeated uint64 repeated_uint64_value = 25;
+ repeated float repeated_float_value = 26;
+ repeated double repeated_double_value = 27;
+ repeated string repeated_string_value = 28;
+ repeated bytes repeated_bytes_value = 29;
+ repeated EnumType repeated_enum_value = 30;
+ repeated MessageType repeated_message_value = 31;
+}
+
+message TestOneof {
+ // In JSON format oneof fields behave mostly the same as optional
+ // fields except that:
+ // 1. Oneof fields have field presence information and will be
+ // printed if it's set no matter whether it's the default value.
+ // 2. Multiple oneof fields in the same oneof cannot appear at the
+ // same time in the input.
+ oneof oneof_value {
+ int32 oneof_int32_value = 1;
+ string oneof_string_value = 2;
+ bytes oneof_bytes_value = 3;
+ EnumType oneof_enum_value = 4;
+ MessageType oneof_message_value = 5;
+ }
+}
+
+message TestMap {
+ map<bool, int32> bool_map = 1;
+ map<int32, int32> int32_map = 2;
+ map<int64, int32> int64_map = 3;
+ map<uint32, int32> uint32_map = 4;
+ map<uint64, int32> uint64_map = 5;
+ map<string, int32> string_map = 6;
+}
+
+message TestNestedMap {
+ map<bool, int32> bool_map = 1;
+ map<int32, int32> int32_map = 2;
+ map<int64, int32> int64_map = 3;
+ map<uint32, int32> uint32_map = 4;
+ map<uint64, int32> uint64_map = 5;
+ map<string, int32> string_map = 6;
+ map<string, TestNestedMap> map_map = 7;
+}
+
+message TestWrapper {
+ google.protobuf.BoolValue bool_value = 1;
+ google.protobuf.Int32Value int32_value = 2;
+ google.protobuf.Int64Value int64_value = 3;
+ google.protobuf.UInt32Value uint32_value = 4;
+ google.protobuf.UInt64Value uint64_value = 5;
+ google.protobuf.FloatValue float_value = 6;
+ google.protobuf.DoubleValue double_value = 7;
+ google.protobuf.StringValue string_value = 8;
+ google.protobuf.BytesValue bytes_value = 9;
+
+ repeated google.protobuf.BoolValue repeated_bool_value = 11;
+ repeated google.protobuf.Int32Value repeated_int32_value = 12;
+ repeated google.protobuf.Int64Value repeated_int64_value = 13;
+ repeated google.protobuf.UInt32Value repeated_uint32_value = 14;
+ repeated google.protobuf.UInt64Value repeated_uint64_value = 15;
+ repeated google.protobuf.FloatValue repeated_float_value = 16;
+ repeated google.protobuf.DoubleValue repeated_double_value = 17;
+ repeated google.protobuf.StringValue repeated_string_value = 18;
+ repeated google.protobuf.BytesValue repeated_bytes_value = 19;
+}
+
+message TestTimestamp {
+ google.protobuf.Timestamp value = 1;
+ repeated google.protobuf.Timestamp repeated_value = 2;
+}
+
+message TestDuration {
+ google.protobuf.Duration value = 1;
+ repeated google.protobuf.Duration repeated_value = 2;
+}
+
+message TestFieldMask {
+ google.protobuf.FieldMask value = 1;
+}
+
+message TestStruct {
+ google.protobuf.Struct value = 1;
+ repeated google.protobuf.Struct repeated_value = 2;
+}
+
+message TestAny {
+ google.protobuf.Any value = 1;
+ repeated google.protobuf.Any repeated_value = 2;
+}
+
+message TestValue {
+ google.protobuf.Value value = 1;
+ repeated google.protobuf.Value repeated_value = 2;
+}
+
+message TestListValue {
+ google.protobuf.ListValue value = 1;
+ repeated google.protobuf.ListValue repeated_value = 2;
+}
+
+message TestBoolValue {
+ bool bool_value = 1;
+ map<bool, int32> bool_map = 2;
+}
+
+message TestCustomJsonName {
+ int32 value = 1 [json_name = "@value"];
+}
+
+message TestExtensions {
+ .protobuf_unittest.TestAllExtensions extensions = 1;
+}
+
+message TestEnumValue {
+ EnumType enum_value1 = 1;
+ EnumType enum_value2 = 2;
+ EnumType enum_value3 = 3;
+}

protos/google/protobuf/wrappers.proto

@@ -0,0 +1,123 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Wrappers for primitive (non-message) types. These types are useful
+// for embedding primitives in the `google.protobuf.Any` type and for places
+// where we need to distinguish between the absence of a primitive
+// typed field and its default value.
+//
+// These wrappers have no meaningful use within repeated fields as they lack
+// the ability to detect presence on individual elements.
+// These wrappers have no meaningful use within a map or a oneof since
+// individual entries of a map or fields of a oneof can already detect presence.
+
+syntax = "proto3";
+
+package google.protobuf;
+
+option csharp_namespace = "Google.Protobuf.WellKnownTypes";
+option cc_enable_arenas = true;
+option go_package = "github.com/golang/protobuf/ptypes/wrappers";
+option java_package = "com.google.protobuf";
+option java_outer_classname = "WrappersProto";
+option java_multiple_files = true;
+option objc_class_prefix = "GPB";
+
+// Wrapper message for `double`.
+//
+// The JSON representation for `DoubleValue` is JSON number.
+message DoubleValue {
+ // The double value.
+ double value = 1;
+}
+
+// Wrapper message for `float`.
+//
+// The JSON representation for `FloatValue` is JSON number.
+message FloatValue {
+ // The float value.
+ float value = 1;
+}
+
+// Wrapper message for `int64`.
+//
+// The JSON representation for `Int64Value` is JSON string.
+message Int64Value {
+ // The int64 value.
+ int64 value = 1;
+}
+
+// Wrapper message for `uint64`.
+//
+// The JSON representation for `UInt64Value` is JSON string.
+message UInt64Value {
+ // The uint64 value.
+ uint64 value = 1;
+}
+
+// Wrapper message for `int32`.
+//
+// The JSON representation for `Int32Value` is JSON number.
+message Int32Value {
+ // The int32 value.
+ int32 value = 1;
+}
+
+// Wrapper message for `uint32`.
+//
+// The JSON representation for `UInt32Value` is JSON number.
+message UInt32Value {
+ // The uint32 value.
+ uint32 value = 1;
+}
+
+// Wrapper message for `bool`.
+//
+// The JSON representation for `BoolValue` is JSON `true` and `false`.
+message BoolValue {
+ // The bool value.
+ bool value = 1;
+}
+
+// Wrapper message for `string`.
+//
+// The JSON representation for `StringValue` is JSON string.
+message StringValue {
+ // The string value.
+ string value = 1;
+}
+
+// Wrapper message for `bytes`.
+//
+// The JSON representation for `BytesValue` is JSON string.
+message BytesValue {
+ // The bytes value.
+ bytes value = 1;
+}

protos/google/rpc/code.proto

@@ -0,0 +1,185 @@
+// Copyright 2017 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.rpc;
+
+option go_package = "google.golang.org/genproto/googleapis/rpc/code;code";
+option java_multiple_files = true;
+option java_outer_classname = "CodeProto";
+option java_package = "com.google.rpc";
+option objc_class_prefix = "RPC";
+
+// The canonical error codes for Google APIs.
+//
+//
+// Sometimes multiple error codes may apply. Services should return
+// the most specific error code that applies. For example, prefer
+// `OUT_OF_RANGE` over `FAILED_PRECONDITION` if both codes apply.
+// Similarly prefer `NOT_FOUND` or `ALREADY_EXISTS` over `FAILED_PRECONDITION`.
+enum Code {
+ // Not an error; returned on success
+ //
+ // HTTP Mapping: 200 OK
+ OK = 0;
+
+ // The operation was cancelled, typically by the caller.
+ //
+ // HTTP Mapping: 499 Client Closed Request
+ CANCELLED = 1;
+
+ // Unknown error. For example, this error may be returned when
+ // a `Status` value received from another address space belongs to
+ // an error space that is not known in this address space. Also
+ // errors raised by APIs that do not return enough error information
+ // may be converted to this error.
+ //
+ // HTTP Mapping: 500 Internal Server Error
+ UNKNOWN = 2;
+
+ // The client specified an invalid argument. Note that this differs
+ // from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments
+ // that are problematic regardless of the state of the system
+ // (e.g., a malformed file name).
+ //
+ // HTTP Mapping: 400 Bad Request
+ INVALID_ARGUMENT = 3;
+
+ // The deadline expired before the operation could complete. For operations
+ // that change the state of the system, this error may be returned
+ // even if the operation has completed successfully. For example, a
+ // successful response from a server could have been delayed long
+ // enough for the deadline to expire.
+ //
+ // HTTP Mapping: 504 Gateway Timeout
+ DEADLINE_EXCEEDED = 4;
+
+ // Some requested entity (e.g., file or directory) was not found.
+ //
+ // Note to server developers: if a request is denied for an entire class
+ // of users, such as gradual feature rollout or undocumented whitelist,
+ // `NOT_FOUND` may be used. If a request is denied for some users within
+ // a class of users, such as user-based access control, `PERMISSION_DENIED`
+ // must be used.
+ //
+ // HTTP Mapping: 404 Not Found
+ NOT_FOUND = 5;
+
+ // The entity that a client attempted to create (e.g., file or directory)
+ // already exists.
+ //
+ // HTTP Mapping: 409 Conflict
+ ALREADY_EXISTS = 6;
+
+ // The caller does not have permission to execute the specified
+ // operation. `PERMISSION_DENIED` must not be used for rejections
+ // caused by exhausting some resource (use `RESOURCE_EXHAUSTED`
+ // instead for those errors). `PERMISSION_DENIED` must not be
+ // used if the caller can not be identified (use `UNAUTHENTICATED`
+ // instead for those errors). This error code does not imply the
+ // request is valid or the requested entity exists or satisfies
+ // other pre-conditions.
+ //
+ // HTTP Mapping: 403 Forbidden
+ PERMISSION_DENIED = 7;
+
+ // The request does not have valid authentication credentials for the
+ // operation.
+ //
+ // HTTP Mapping: 401 Unauthorized
+ UNAUTHENTICATED = 16;
+
+ // Some resource has been exhausted, perhaps a per-user quota, or
+ // perhaps the entire file system is out of space.
+ //
+ // HTTP Mapping: 429 Too Many Requests
+ RESOURCE_EXHAUSTED = 8;
+
+ // The operation was rejected because the system is not in a state
+ // required for the operation's execution. For example, the directory
+ // to be deleted is non-empty, an rmdir operation is applied to
+ // a non-directory, etc.
+ //
+ // Service implementors can use the following guidelines to decide
+ // between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`:
+ // (a) Use `UNAVAILABLE` if the client can retry just the failing call.
+ // (b) Use `ABORTED` if the client should retry at a higher level
+ // (e.g., when a client-specified test-and-set fails, indicating the
+ // client should restart a read-modify-write sequence).
+ // (c) Use `FAILED_PRECONDITION` if the client should not retry until
+ // the system state has been explicitly fixed. E.g., if an "rmdir"
+ // fails because the directory is non-empty, `FAILED_PRECONDITION`
+ // should be returned since the client should not retry unless
+ // the files are deleted from the directory.
+ //
+ // HTTP Mapping: 400 Bad Request
+ FAILED_PRECONDITION = 9;
+
+ // The operation was aborted, typically due to a concurrency issue such as
+ // a sequencer check failure or transaction abort.
+ //
+ // See the guidelines above for deciding between `FAILED_PRECONDITION`,
+ // `ABORTED`, and `UNAVAILABLE`.
+ //
+ // HTTP Mapping: 409 Conflict
+ ABORTED = 10;
+
+ // The operation was attempted past the valid range. E.g., seeking or
+ // reading past end-of-file.
+ //
+ // Unlike `INVALID_ARGUMENT`, this error indicates a problem that may
+ // be fixed if the system state changes. For example, a 32-bit file
+ // system will generate `INVALID_ARGUMENT` if asked to read at an
+ // offset that is not in the range [0,2^32-1], but it will generate
+ // `OUT_OF_RANGE` if asked to read from an offset past the current
+ // file size.
+ //
+ // There is a fair bit of overlap between `FAILED_PRECONDITION` and
+ // `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific
+ // error) when it applies so that callers who are iterating through
+ // a space can easily look for an `OUT_OF_RANGE` error to detect when
+ // they are done.
+ //
+ // HTTP Mapping: 400 Bad Request
+ OUT_OF_RANGE = 11;
+
+ // The operation is not implemented or is not supported/enabled in this
+ // service.
+ //
+ // HTTP Mapping: 501 Not Implemented
+ UNIMPLEMENTED = 12;
+
+ // Internal errors. This means that some invariants expected by the
+ // underlying system have been broken. This error code is reserved
+ // for serious errors.
+ //
+ // HTTP Mapping: 500 Internal Server Error
+ INTERNAL = 13;
+
+ // The service is currently unavailable. This is most likely a
+ // transient condition, which can be corrected by retrying with
+ // a backoff.
+ //
+ // See the guidelines above for deciding between `FAILED_PRECONDITION`,
+ // `ABORTED`, and `UNAVAILABLE`.
+ //
+ // HTTP Mapping: 503 Service Unavailable
+ UNAVAILABLE = 14;
+
+ // Unrecoverable data loss or corruption.
+ //
+ // HTTP Mapping: 500 Internal Server Error
+ DATA_LOSS = 15;
+}

protos/google/rpc/error_details.proto

@@ -0,0 +1,200 @@
+// Copyright 2017 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.rpc;
+
+import "google/protobuf/duration.proto";
+
+option go_package = "google.golang.org/genproto/googleapis/rpc/errdetails;errdetails";
+option java_multiple_files = true;
+option java_outer_classname = "ErrorDetailsProto";
+option java_package = "com.google.rpc";
+option objc_class_prefix = "RPC";
+
+// Describes when the clients can retry a failed request. Clients could ignore
+// the recommendation here or retry when this information is missing from error
+// responses.
+//
+// It's always recommended that clients should use exponential backoff when
+// retrying.
+//
+// Clients should wait until `retry_delay` amount of time has passed since
+// receiving the error response before retrying. If retrying requests also
+// fail, clients should use an exponential backoff scheme to gradually increase
+// the delay between retries based on `retry_delay`, until either a maximum
+// number of retires have been reached or a maximum retry delay cap has been
+// reached.
+message RetryInfo {
+ // Clients should wait at least this long between retrying the same request.
+ google.protobuf.Duration retry_delay = 1;
+}
+
+// Describes additional debugging info.
+message DebugInfo {
+ // The stack trace entries indicating where the error occurred.
+ repeated string stack_entries = 1;
+
+ // Additional debugging information provided by the server.
+ string detail = 2;
+}
+
+// Describes how a quota check failed.
+//
+// For example if a daily limit was exceeded for the calling project,
+// a service could respond with a QuotaFailure detail containing the project
+// id and the description of the quota limit that was exceeded. If the
+// calling project hasn't enabled the service in the developer console, then
+// a service could respond with the project id and set `service_disabled`
+// to true.
+//
+// Also see RetryDetail and Help types for other details about handling a
+// quota failure.
+message QuotaFailure {
+ // A message type used to describe a single quota violation. For example, a
+ // daily quota or a custom quota that was exceeded.
+ message Violation {
+ // The subject on which the quota check failed.
+ // For example, "clientip:<ip address of client>" or "project:<Google
+ // developer project id>".
+ string subject = 1;
+
+ // A description of how the quota check failed. Clients can use this
+ // description to find more about the quota configuration in the service's
+ // public documentation, or find the relevant quota limit to adjust through
+ // developer console.
+ //
+ // For example: "Service disabled" or "Daily Limit for read operations
+ // exceeded".
+ string description = 2;
+ }
+
+ // Describes all quota violations.
+ repeated Violation violations = 1;
+}
+
+// Describes what preconditions have failed.
+//
+// For example, if an RPC failed because it required the Terms of Service to be
+// acknowledged, it could list the terms of service violation in the
+// PreconditionFailure message.
+message PreconditionFailure {
+ // A message type used to describe a single precondition failure.
+ message Violation {
+ // The type of PreconditionFailure. We recommend using a service-specific
+ // enum type to define the supported precondition violation types. For
+ // example, "TOS" for "Terms of Service violation".
+ string type = 1;
+
+ // The subject, relative to the type, that failed.
+ // For example, "google.com/cloud" relative to the "TOS" type would
+ // indicate which terms of service is being referenced.
+ string subject = 2;
+
+ // A description of how the precondition failed. Developers can use this
+ // description to understand how to fix the failure.
+ //
+ // For example: "Terms of service not accepted".
+ string description = 3;
+ }
+
+ // Describes all precondition violations.
+ repeated Violation violations = 1;
+}
+
+// Describes violations in a client request. This error type focuses on the
+// syntactic aspects of the request.
+message BadRequest {
+ // A message type used to describe a single bad request field.
+ message FieldViolation {
+ // A path leading to a field in the request body. The value will be a
+ // sequence of dot-separated identifiers that identify a protocol buffer
+ // field. E.g., "field_violations.field" would identify this field.
+ string field = 1;
+
+ // A description of why the request element is bad.
+ string description = 2;
+ }
+
+ // Describes all violations in a client request.
+ repeated FieldViolation field_violations = 1;
+}
+
+// Contains metadata about the request that clients can attach when filing a bug
+// or providing other forms of feedback.
+message RequestInfo {
+ // An opaque string that should only be interpreted by the service generating
+ // it. For example, it can be used to identify requests in the service's logs.
+ string request_id = 1;
+
+ // Any data that was used to serve this request. For example, an encrypted
+ // stack trace that can be sent back to the service provider for debugging.
+ string serving_data = 2;
+}
+
+// Describes the resource that is being accessed.
+message ResourceInfo {
+ // A name for the type of resource being accessed, e.g. "sql table",
+ // "cloud storage bucket", "file", "Google calendar"; or the type URL
+ // of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
+ string resource_type = 1;
+
+ // The name of the resource being accessed. For example, a shared calendar
+ // name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
+ // error is
+ // [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
+ string resource_name = 2;
+
+ // The owner of the resource (optional).
+ // For example, "user:<owner email>" or "project:<Google developer project
+ // id>".
+ string owner = 3;
+
+ // Describes what error is encountered when accessing this resource.
+ // For example, updating a cloud project may require the `writer` permission
+ // on the developer console project.
+ string description = 4;
+}
+
+// Provides links to documentation or for performing an out of band action.
+//
+// For example, if a quota check failed with an error indicating the calling
+// project hasn't enabled the accessed service, this can contain a URL pointing
+// directly to the right place in the developer console to flip the bit.
+message Help {
+ // Describes a URL link.
+ message Link {
+ // Describes what the link offers.
+ string description = 1;
+
+ // The URL of the link.
+ string url = 2;
+ }
+
+ // URL(s) pointing to additional information on handling the current error.
+ repeated Link links = 1;
+}
+
+// Provides a localized error message that is safe to return to the user
+// which can be attached to an RPC error.
+message LocalizedMessage {
+ // The locale used following the specification defined at
+ // http://www.rfc-editor.org/rfc/bcp/bcp47.txt.
+ // Examples are: "en-US", "fr-CH", "es-MX"
+ string locale = 1;
+
+ // The localized error message in the above locale.
+ string message = 2;
+}

protos/google/rpc/status.proto

@@ -0,0 +1,94 @@
+// Copyright 2017 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.rpc;
+
+import "google/protobuf/any.proto";
+
+option go_package = "google.golang.org/genproto/googleapis/rpc/status;status";
+option java_multiple_files = true;
+option java_outer_classname = "StatusProto";
+option java_package = "com.google.rpc";
+option objc_class_prefix = "RPC";
+
+// The `Status` type defines a logical error model that is suitable for
+// different programming environments, including REST APIs and RPC APIs. It is
+// used by [gRPC](https://github.com/grpc). The error model is designed to be:
+//
+// - Simple to use and understand for most users
+// - Flexible enough to meet unexpected needs
+//
+// # Overview
+//
+// The `Status` message contains three pieces of data: error code, error
+// message, and error details. The error code should be an enum value of
+// [google.rpc.Code][google.rpc.Code], but it may accept additional error codes
+// if needed. The error message should be a developer-facing English message
+// that helps developers *understand* and *resolve* the error. If a localized
+// user-facing error message is needed, put the localized message in the error
+// details or localize it in the client. The optional error details may contain
+// arbitrary information about the error. There is a predefined set of error
+// detail types in the package `google.rpc` that can be used for common error
+// conditions.
+//
+// # Language mapping
+//
+// The `Status` message is the logical representation of the error model, but it
+// is not necessarily the actual wire format. When the `Status` message is
+// exposed in different client libraries and different wire protocols, it can be
+// mapped differently. For example, it will likely be mapped to some exceptions
+// in Java, but more likely mapped to some error codes in C.
+//
+// # Other uses
+//
+// The error model and the `Status` message can be used in a variety of
+// environments, either with or without APIs, to provide a
+// consistent developer experience across different environments.
+//
+// Example uses of this error model include:
+//
+// - Partial errors. If a service needs to return partial errors to the client,
+// it may embed the `Status` in the normal response to indicate the partial
+// errors.
+//
+// - Workflow errors. A typical workflow has multiple steps. Each step may
+// have a `Status` message for error reporting.
+//
+// - Batch operations. If a client uses batch request and batch response, the
+// `Status` message should be used directly inside batch response, one for
+// each error sub-response.
+//
+// - Asynchronous operations. If an API call embeds asynchronous operation
+// results in its response, the status of those operations should be
+// represented directly using the `Status` message.
+//
+// - Logging. If some API errors are stored in logs, the message `Status` could
+// be used directly after any stripping needed for security/privacy reasons.
+message Status {
+ // The status code, which should be an enum value of
+ // [google.rpc.Code][google.rpc.Code].
+ int32 code = 1;
+
+ // A developer-facing error message, which should be in English. Any
+ // user-facing error message should be localized and sent in the
+ // [google.rpc.Status.details][google.rpc.Status.details] field, or localized
+ // by the client.
+ string message = 2;
+
+ // A list of messages that carry the error details. There is a common set of
+ // message types for APIs to use.
+ repeated google.protobuf.Any details = 3;
+}

protos/google/type/calendar_period.proto

@@ -0,0 +1,58 @@
+// Copyright 2019 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.type;
+
+option go_package = "google.golang.org/genproto/googleapis/type/calendarperiod;calendarperiod";
+option java_multiple_files = true;
+option java_outer_classname = "CalendarPeriodProto";
+option java_package = "com.google.type";
+option objc_class_prefix = "GTP";
+
+
+// A `CalendarPeriod` represents the abstract concept of a time period that has
+// a canonical start. Grammatically, "the start of the current
+// `CalendarPeriod`." All calendar times begin at midnight UTC.
+enum CalendarPeriod {
+ // Undefined period, raises an error.
+ CALENDAR_PERIOD_UNSPECIFIED = 0;
+
+ // A day.
+ DAY = 1;
+
+ // A week. Weeks begin on Monday, following
+ // [ISO 8601](https://en.wikipedia.org/wiki/ISO_week_date).
+ WEEK = 2;
+
+ // A fortnight. The first calendar fortnight of the year begins at the start
+ // of week 1 according to
+ // [ISO 8601](https://en.wikipedia.org/wiki/ISO_week_date).
+ FORTNIGHT = 3;
+
+ // A month.
+ MONTH = 4;
+
+ // A quarter. Quarters start on dates 1-Jan, 1-Apr, 1-Jul, and 1-Oct of each
+ // year.
+ QUARTER = 5;
+
+ // A half-year. Half-years start on dates 1-Jan and 1-Jul.
+ HALF = 6;
+
+ // A year.
+ YEAR = 7;
+}

protos/google/type/color.proto

@@ -0,0 +1,171 @@
+// Copyright 2019 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.type;
+
+import "google/protobuf/wrappers.proto";
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/type/color;color";
+option java_multiple_files = true;
+option java_outer_classname = "ColorProto";
+option java_package = "com.google.type";
+option objc_class_prefix = "GTP";
+
+
+// Represents a color in the RGBA color space. This representation is designed
+// for simplicity of conversion to/from color representations in various
+// languages over compactness; for example, the fields of this representation
+// can be trivially provided to the constructor of "java.awt.Color" in Java; it
+// can also be trivially provided to UIColor's "+colorWithRed:green:blue:alpha"
+// method in iOS; and, with just a little work, it can be easily formatted into
+// a CSS "rgba()" string in JavaScript, as well.
+//
+// Note: this proto does not carry information about the absolute color space
+// that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB,
+// DCI-P3, BT.2020, etc.). By default, applications SHOULD assume the sRGB color
+// space.
+//
+// Example (Java):
+//
+// import com.google.type.Color;
+//
+// // ...
+// public static java.awt.Color fromProto(Color protocolor) {
+// float alpha = protocolor.hasAlpha()
+// ? protocolor.getAlpha().getValue()
+// : 1.0;
+//
+// return new java.awt.Color(
+// protocolor.getRed(),
+// protocolor.getGreen(),
+// protocolor.getBlue(),
+// alpha);
+// }
+//
+// public static Color toProto(java.awt.Color color) {
+// float red = (float) color.getRed();
+// float green = (float) color.getGreen();
+// float blue = (float) color.getBlue();
+// float denominator = 255.0;
+// Color.Builder resultBuilder =
+// Color
+// .newBuilder()
+// .setRed(red / denominator)
+// .setGreen(green / denominator)
+// .setBlue(blue / denominator);
+// int alpha = color.getAlpha();
+// if (alpha != 255) {
+// result.setAlpha(
+// FloatValue
+// .newBuilder()
+// .setValue(((float) alpha) / denominator)
+// .build());
+// }
+// return resultBuilder.build();
+// }
+// // ...
+//
+// Example (iOS / Obj-C):
+//
+// // ...
+// static UIColor* fromProto(Color* protocolor) {
+// float red = [protocolor red];
+// float green = [protocolor green];
+// float blue = [protocolor blue];
+// FloatValue* alpha_wrapper = [protocolor alpha];
+// float alpha = 1.0;
+// if (alpha_wrapper != nil) {
+// alpha = [alpha_wrapper value];
+// }
+// return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
+// }
+//
+// static Color* toProto(UIColor* color) {
+// CGFloat red, green, blue, alpha;
+// if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) {
+// return nil;
+// }
+// Color* result = [[Color alloc] init];
+// [result setRed:red];
+// [result setGreen:green];
+// [result setBlue:blue];
+// if (alpha <= 0.9999) {
+// [result setAlpha:floatWrapperWithValue(alpha)];
+// }
+// [result autorelease];
+// return result;
+// }
+// // ...
+//
+// Example (JavaScript):
+//
+// // ...
+//
+// var protoToCssColor = function(rgb_color) {
+// var redFrac = rgb_color.red || 0.0;
+// var greenFrac = rgb_color.green || 0.0;
+// var blueFrac = rgb_color.blue || 0.0;
+// var red = Math.floor(redFrac * 255);
+// var green = Math.floor(greenFrac * 255);
+// var blue = Math.floor(blueFrac * 255);
+//
+// if (!('alpha' in rgb_color)) {
+// return rgbToCssColor_(red, green, blue);
+// }
+//
+// var alphaFrac = rgb_color.alpha.value || 0.0;
+// var rgbParams = [red, green, blue].join(',');
+// return ['rgba(', rgbParams, ',', alphaFrac, ')'].join('');
+// };
+//
+// var rgbToCssColor_ = function(red, green, blue) {
+// var rgbNumber = new Number((red << 16) | (green << 8) | blue);
+// var hexString = rgbNumber.toString(16);
+// var missingZeros = 6 - hexString.length;
+// var resultBuilder = ['#'];
+// for (var i = 0; i < missingZeros; i++) {
+// resultBuilder.push('0');
+// }
+// resultBuilder.push(hexString);
+// return resultBuilder.join('');
+// };
+//
+// // ...
+message Color {
+ // The amount of red in the color as a value in the interval [0, 1].
+ float red = 1;
+
+ // The amount of green in the color as a value in the interval [0, 1].
+ float green = 2;
+
+ // The amount of blue in the color as a value in the interval [0, 1].
+ float blue = 3;
+
+ // The fraction of this color that should be applied to the pixel. That is,
+ // the final pixel color is defined by the equation:
+ //
+ // pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
+ //
+ // This means that a value of 1.0 corresponds to a solid color, whereas
+ // a value of 0.0 corresponds to a completely transparent color. This
+ // uses a wrapper message rather than a simple float scalar so that it is
+ // possible to distinguish between a default value and the value being unset.
+ // If omitted, this color object is to be rendered as a solid color
+ // (as if the alpha value had been explicitly given with a value of 1.0).
+ google.protobuf.FloatValue alpha = 4;
+}

protos/google/type/date.proto

@@ -0,0 +1,51 @@
+// Copyright 2019 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.type;
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/type/date;date";
+option java_multiple_files = true;
+option java_outer_classname = "DateProto";
+option java_package = "com.google.type";
+option objc_class_prefix = "GTP";
+
+
+// Represents a whole or partial calendar date, e.g. a birthday. The time of day
+// and time zone are either specified elsewhere or are not significant. The date
+// is relative to the Proleptic Gregorian Calendar. This can represent:
+//
+// * A full date, with non-zero year, month and day values
+// * A month and day value, with a zero year, e.g. an anniversary
+// * A year on its own, with zero month and day values
+// * A year and month value, with a zero day, e.g. a credit card expiration date
+//
+// Related types are [google.type.TimeOfDay][google.type.TimeOfDay] and `google.protobuf.Timestamp`.
+message Date {
+ // Year of date. Must be from 1 to 9999, or 0 if specifying a date without
+ // a year.
+ int32 year = 1;
+
+ // Month of year. Must be from 1 to 12, or 0 if specifying a year without a
+ // month and day.
+ int32 month = 2;
+
+ // Day of month. Must be from 1 to 31 and valid for the year and month, or 0
+ // if specifying a year by itself or a year and month where the day is not
+ // significant.
+ int32 day = 3;
+}

protos/google/type/dayofweek.proto

@@ -0,0 +1,52 @@
+// Copyright 2019 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.type;
+
+option go_package = "google.golang.org/genproto/googleapis/type/dayofweek;dayofweek";
+option java_multiple_files = true;
+option java_outer_classname = "DayOfWeekProto";
+option java_package = "com.google.type";
+option objc_class_prefix = "GTP";
+
+
+// Represents a day of week.
+enum DayOfWeek {
+ // The unspecified day-of-week.
+ DAY_OF_WEEK_UNSPECIFIED = 0;
+
+ // The day-of-week of Monday.
+ MONDAY = 1;
+
+ // The day-of-week of Tuesday.
+ TUESDAY = 2;
+
+ // The day-of-week of Wednesday.
+ WEDNESDAY = 3;
+
+ // The day-of-week of Thursday.
+ THURSDAY = 4;
+
+ // The day-of-week of Friday.
+ FRIDAY = 5;
+
+ // The day-of-week of Saturday.
+ SATURDAY = 6;
+
+ // The day-of-week of Sunday.
+ SUNDAY = 7;
+}

protos/google/type/expr.proto

@@ -0,0 +1,52 @@
+// Copyright 2019 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.type;
+
+option go_package = "google.golang.org/genproto/googleapis/type/expr;expr";
+option java_multiple_files = true;
+option java_outer_classname = "ExprProto";
+option java_package = "com.google.type";
+option objc_class_prefix = "GTP";
+
+
+// Represents an expression text. Example:
+//
+// title: "User account presence"
+// description: "Determines whether the request has a user account"
+// expression: "size(request.user) > 0"
+message Expr {
+ // Textual representation of an expression in
+ // Common Expression Language syntax.
+ //
+ // The application context of the containing message determines which
+ // well-known feature set of CEL is supported.
+ string expression = 1;
+
+ // An optional title for the expression, i.e. a short string describing
+ // its purpose. This can be used e.g. in UIs which allow to enter the
+ // expression.
+ string title = 2;
+
+ // An optional description of the expression. This is a longer text which
+ // describes the expression, e.g. when hovered over it in a UI.
+ string description = 3;
+
+ // An optional string indicating the location of the expression for error
+ // reporting, e.g. a file name and a position in the file.
+ string location = 4;
+}

protos/google/type/fraction.proto

@@ -0,0 +1,35 @@
+// Copyright 2019 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.type;
+
+option go_package = "google.golang.org/genproto/googleapis/type/fraction;fraction";
+option java_multiple_files = true;
+option java_outer_classname = "FractionProto";
+option java_package = "com.google.type";
+option objc_class_prefix = "GTP";
+
+
+// Represents a fraction in terms of a numerator divided by a denominator.
+message Fraction {
+ // The portion of the denominator in the faction, e.g. 2 in 2/3.
+ int64 numerator = 1;
+
+ // The value by which the numerator is divided, e.g. 3 in 2/3. Must be
+ // positive.
+ int64 denominator = 2;
+}

protos/google/type/latlng.proto

@@ -0,0 +1,39 @@
+// Copyright 2019 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.type;
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/type/latlng;latlng";
+option java_multiple_files = true;
+option java_outer_classname = "LatLngProto";
+option java_package = "com.google.type";
+option objc_class_prefix = "GTP";
+
+
+// An object representing a latitude/longitude pair. This is expressed as a pair
+// of doubles representing degrees latitude and degrees longitude. Unless
+// specified otherwise, this must conform to the
+// <a href="http://www.unoosa.org/pdf/icg/2012/template/WGS_84.pdf">WGS84
+// standard</a>. Values must be within normalized ranges.
+message LatLng {
+ // The latitude in degrees. It must be in the range [-90.0, +90.0].
+ double latitude = 1;
+
+ // The longitude in degrees. It must be in the range [-180.0, +180.0].
+ double longitude = 2;
+}

protos/google/type/money.proto

@@ -0,0 +1,44 @@
+// Copyright 2019 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.type;
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/type/money;money";
+option java_multiple_files = true;
+option java_outer_classname = "MoneyProto";
+option java_package = "com.google.type";
+option objc_class_prefix = "GTP";
+
+
+// Represents an amount of money with its currency type.
+message Money {
+ // The 3-letter currency code defined in ISO 4217.
+ string currency_code = 1;
+
+ // The whole units of the amount.
+ // For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
+ int64 units = 2;
+
+ // Number of nano (10^-9) units of the amount.
+ // The value must be between -999,999,999 and +999,999,999 inclusive.
+ // If `units` is positive, `nanos` must be positive or zero.
+ // If `units` is zero, `nanos` can be positive, zero, or negative.
+ // If `units` is negative, `nanos` must be negative or zero.
+ // For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
+ int32 nanos = 3;
+}

protos/google/type/postal_address.proto

@@ -0,0 +1,131 @@
+// Copyright 2016 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.type;
+
+option go_package = "google.golang.org/genproto/googleapis/type/postaladdress;postaladdress";
+option java_multiple_files = true;
+option java_outer_classname = "PostalAddressProto";
+option java_package = "com.google.type";
+option objc_class_prefix = "GTP";
+
+// Represents a postal address, e.g. for postal delivery or payments addresses.
+// Given a postal address, a postal service can deliver items to a premise, P.O.
+// Box or similar.
+// It is not intended to model geographical locations (roads, towns,
+// mountains).
+//
+// In typical usage an address would be created via user input or from importing
+// existing data, depending on the type of process.
+//
+// Advice on address input / editing:
+// - Use an i18n-ready address widget such as
+// https://github.com/googlei18n/libaddressinput)
+// - Users should not be presented with UI elements for input or editing of
+// fields outside countries where that field is used.
+//
+// For more guidance on how to use this schema, please see:
+// https://support.google.com/business/answer/6397478
+message PostalAddress {
+ // The schema revision of the `PostalAddress`.
+ // All new revisions **must** be backward compatible with old revisions.
+ int32 revision = 1;
+
+ // Required. CLDR region code of the country/region of the address. This
+ // is never inferred and it is up to the user to ensure the value is
+ // correct. See http://cldr.unicode.org/ and
+ // http://www.unicode.org/cldr/charts/30/supplemental/territory_information.html
+ // for details. Example: "CH" for Switzerland.
+ string region_code = 2;
+
+ // Optional. BCP-47 language code of the contents of this address (if
+ // known). This is often the UI language of the input form or is expected
+ // to match one of the languages used in the address' country/region, or their
+ // transliterated equivalents.
+ // This can affect formatting in certain countries, but is not critical
+ // to the correctness of the data and will never affect any validation or
+ // other non-formatting related operations.
+ //
+ // If this value is not known, it should be omitted (rather than specifying a
+ // possibly incorrect default).
+ //
+ // Examples: "zh-Hant", "ja", "ja-Latn", "en".
+ string language_code = 3;
+
+ // Optional. Postal code of the address. Not all countries use or require
+ // postal codes to be present, but where they are used, they may trigger
+ // additional validation with other parts of the address (e.g. state/zip
+ // validation in the U.S.A.).
+ string postal_code = 4;
+
+ // Optional. Additional, country-specific, sorting code. This is not used
+ // in most regions. Where it is used, the value is either a string like
+ // "CEDEX", optionally followed by a number (e.g. "CEDEX 7"), or just a number
+ // alone, representing the "sector code" (Jamaica), "delivery area indicator"
+ // (Malawi) or "post office indicator" (e.g. Côte d'Ivoire).
+ string sorting_code = 5;
+
+ // Optional. Highest administrative subdivision which is used for postal
+ // addresses of a country or region.
+ // For example, this can be a state, a province, an oblast, or a prefecture.
+ // Specifically, for Spain this is the province and not the autonomous
+ // community (e.g. "Barcelona" and not "Catalonia").
+ // Many countries don't use an administrative area in postal addresses. E.g.
+ // in Switzerland this should be left unpopulated.
+ string administrative_area = 6;
+
+ // Optional. Generally refers to the city/town portion of the address.
+ // Examples: US city, IT comune, UK post town.
+ // In regions of the world where localities are not well defined or do not fit
+ // into this structure well, leave locality empty and use address_lines.
+ string locality = 7;
+
+ // Optional. Sublocality of the address.
+ // For example, this can be neighborhoods, boroughs, districts.
+ string sublocality = 8;
+
+ // Unstructured address lines describing the lower levels of an address.
+ //
+ // Because values in address_lines do not have type information and may
+ // sometimes contain multiple values in a single field (e.g.
+ // "Austin, TX"), it is important that the line order is clear. The order of
+ // address lines should be "envelope order" for the country/region of the
+ // address. In places where this can vary (e.g. Japan), address_language is
+ // used to make it explicit (e.g. "ja" for large-to-small ordering and
+ // "ja-Latn" or "en" for small-to-large). This way, the most specific line of
+ // an address can be selected based on the language.
+ //
+ // The minimum permitted structural representation of an address consists
+ // of a region_code with all remaining information placed in the
+ // address_lines. It would be possible to format such an address very
+ // approximately without geocoding, but no semantic reasoning could be
+ // made about any of the address components until it was at least
+ // partially resolved.
+ //
+ // Creating an address only containing a region_code and address_lines, and
+ // then geocoding is the recommended way to handle completely unstructured
+ // addresses (as opposed to guessing which parts of the address should be
+ // localities or administrative areas).
+ repeated string address_lines = 9;
+
+ // Optional. The recipient at the address.
+ // This field may, under certain circumstances, contain multiline information.
+ // For example, it might contain "care of" information.
+ repeated string recipients = 10;
+
+ // Optional. The name of the organization at the address.
+ string organization = 11;
+}

protos/google/type/quaternion.proto

@@ -0,0 +1,97 @@
+// Copyright 2019 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.type;
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/type/quaternion;quaternion";
+option java_multiple_files = true;
+option java_outer_classname = "QuaternionProto";
+option java_package = "com.google.type";
+option objc_class_prefix = "GTP";
+
+
+// A quaternion is defined as the quotient of two directed lines in a
+// three-dimensional space or equivalently as the quotient of two Euclidean
+// vectors (https://en.wikipedia.org/wiki/Quaternion).
+//
+// Quaternions are often used in calculations involving three-dimensional
+// rotations (https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation),
+// as they provide greater mathematical robustness by avoiding the gimbal lock
+// problems that can be encountered when using Euler angles
+// (https://en.wikipedia.org/wiki/Gimbal_lock).
+//
+// Quaternions are generally represented in this form:
+//
+// w + xi + yj + zk
+//
+// where x, y, z, and w are real numbers, and i, j, and k are three imaginary
+// numbers.
+//
+// Our naming choice (x, y, z, w) comes from the desire to avoid confusion for
+// those interested in the geometric properties of the quaternion in the 3D
+// Cartesian space. Other texts often use alternative names or subscripts, such
+// as (a, b, c, d), (1, i, j, k), or (0, 1, 2, 3), which are perhaps better
+// suited for mathematical interpretations.
+//
+// To avoid any confusion, as well as to maintain compatibility with a large
+// number of software libraries, the quaternions represented using the protocol
+// buffer below *must* follow the Hamilton convention, which defines ij = k
+// (i.e. a right-handed algebra), and therefore:
+//
+// i^2 = j^2 = k^2 = ijk = −1
+// ij = −ji = k
+// jk = −kj = i
+// ki = −ik = j
+//
+// Please DO NOT use this to represent quaternions that follow the JPL
+// convention, or any of the other quaternion flavors out there.
+//
+// Definitions:
+//
+// - Quaternion norm (or magnitude): sqrt(x^2 + y^2 + z^2 + w^2).
+// - Unit (or normalized) quaternion: a quaternion whose norm is 1.
+// - Pure quaternion: a quaternion whose scalar component (w) is 0.
+// - Rotation quaternion: a unit quaternion used to represent rotation.
+// - Orientation quaternion: a unit quaternion used to represent orientation.
+//
+// A quaternion can be normalized by dividing it by its norm. The resulting
+// quaternion maintains the same direction, but has a norm of 1, i.e. it moves
+// on the unit sphere. This is generally necessary for rotation and orientation
+// quaternions, to avoid rounding errors:
+// https://en.wikipedia.org/wiki/Rotation_formalisms_in_three_dimensions
+//
+// Note that (x, y, z, w) and (-x, -y, -z, -w) represent the same rotation, but
+// normalization would be even more useful, e.g. for comparison purposes, if it
+// would produce a unique representation. It is thus recommended that w be kept
+// positive, which can be achieved by changing all the signs when w is negative.
+//
+//
+// Next available tag: 5
+message Quaternion {
+ // The x component.
+ double x = 1;
+
+ // The y component.
+ double y = 2;
+
+ // The z component.
+ double z = 3;
+
+ // The scalar component.
+ double w = 4;
+}

protos/google/type/timeofday.proto

@@ -0,0 +1,45 @@
+// Copyright 2019 Google LLC.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package google.type;
+
+option cc_enable_arenas = true;
+option go_package = "google.golang.org/genproto/googleapis/type/timeofday;timeofday";
+option java_multiple_files = true;
+option java_outer_classname = "TimeOfDayProto";
+option java_package = "com.google.type";
+option objc_class_prefix = "GTP";
+
+
+// Represents a time of day. The date and time zone are either not significant
+// or are specified elsewhere. An API may choose to allow leap seconds. Related
+// types are [google.type.Date][google.type.Date] and `google.protobuf.Timestamp`.
+message TimeOfDay {
+ // Hours of day in 24 hour format. Should be from 0 to 23. An API may choose
+ // to allow the value "24:00:00" for scenarios like business closing time.
+ int32 hours = 1;
+
+ // Minutes of hour of day. Must be from 0 to 59.
+ int32 minutes = 2;
+
+ // Seconds of minutes of the time. Must normally be from 0 to 59. An API may
+ // allow the value 60 if it allows leap-seconds.
+ int32 seconds = 3;
+
+ // Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
+ int32 nanos = 4;
+}