diff --git a/packages/logging/package.json b/packages/logging/package.json index 55a2cf8395c..a5ee798a363 100644 --- a/packages/logging/package.json +++ b/packages/logging/package.json @@ -51,10 +51,13 @@ ], "dependencies": { "@google-cloud/common": "^0.3.0", + "arguejs": "^0.2.3", "arrify": "^1.0.0", "extend": "^3.0.0", + "google-gax": "^0.6.0", "google-proto-files": "^0.2.1", "is": "^3.0.1", + "lodash": "^4.15.0", "string-format-obj": "^1.0.0" }, "devDependencies": { diff --git a/packages/logging/src/index.js b/packages/logging/src/index.js index cd5843ca1c3..5153d3eaf28 100644 --- a/packages/logging/src/index.js +++ b/packages/logging/src/index.js @@ -575,3 +575,4 @@ Logging.Logging = Logging; Logging.Sink = Sink; module.exports = Logging; +module.exports.v2 = require('./v2'); diff --git a/packages/logging/src/v2/config_service_v2_api.js b/packages/logging/src/v2/config_service_v2_api.js new file mode 100644 index 00000000000..566822ecd13 --- /dev/null +++ b/packages/logging/src/v2/config_service_v2_api.js @@ -0,0 +1,451 @@ +/* + * Copyright 2016 Google Inc. 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. + * + * EDITING INSTRUCTIONS + * This file was generated from the file + * https://github.com/googleapis/googleapis/blob/master/google/logging/v2/logging_config.proto, + * and updates to that file get reflected here through a refresh process. + * For the short term, the refresh process will only be runnable by Google + * engineers. + * + * The only allowed edits are to method and file documentation. A 3-way + * merge preserves those additions if the generated source changes. + */ +/* TODO: introduce line-wrapping so that it never exceeds the limit. */ +/* jscs: disable maximumLineLength */ +'use strict'; + +var arguejs = require('arguejs'); +var configData = require('./config_service_v2_client_config'); +var extend = require('extend'); +var gax = require('google-gax'); + +var SERVICE_ADDRESS = 'logging.googleapis.com'; + +var DEFAULT_SERVICE_PORT = 443; + +var CODE_GEN_NAME_VERSION = 'gapic/0.1.0'; + +var DEFAULT_TIMEOUT = 30; + +var PAGE_DESCRIPTORS = { + 'listSinks': new gax.PageDescriptor( + 'page_token', + 'next_page_token', + 'sinks') +}; + +/** + * The scopes needed to make gRPC calls to all of the methods defined in + * this service. + */ +var ALL_SCOPES = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + 'https://www.googleapis.com/auth/logging.admin', + 'https://www.googleapis.com/auth/logging.read', + 'https://www.googleapis.com/auth/logging.write' +]; + +/** + * Service for configuring sinks used to export log entries outside Stackdriver + * Logging. + * + * This will be created through a builder function which can be obtained by the module. + * See the following example of how to initialize the module and how to access to the builder. + * @see {@link configServiceV2Api} + * + * @example + * var loggingV2 = require('@google-cloud/logging').v2({ + * // optional auth parameters. + * }); + * var api = loggingV2.configServiceV2Api(); + * + * @class + */ +function ConfigServiceV2Api(gaxGrpc, grpcClient, opts) { + opts = opts || {}; + var servicePath = opts.servicePath || SERVICE_ADDRESS; + var port = opts.port || DEFAULT_SERVICE_PORT; + var sslCreds = opts.sslCreds || null; + var clientConfig = opts.clientConfig || {}; + var timeout = opts.timeout || DEFAULT_TIMEOUT; + var appName = opts.appName || 'gax'; + var appVersion = opts.appVersion || gax.Version; + + var googleApiClient = [ + appName + '/' + appVersion, + CODE_GEN_NAME_VERSION, + 'nodejs/' + process.version].join(' '); + + var defaults = gaxGrpc.constructSettings( + 'google.logging.v2.ConfigServiceV2', + configData, + clientConfig, + timeout, + PAGE_DESCRIPTORS, + null, + {'x-goog-api-client': googleApiClient}); + + var stub = gaxGrpc.createStub( + servicePath, + port, + grpcClient.google.logging.v2.ConfigServiceV2, + {sslCreds: sslCreds}); + var methods = [ + 'listSinks', + 'getSink', + 'createSink', + 'updateSink', + 'deleteSink' + ]; + methods.forEach(function(methodName) { + this['_' + methodName] = gax.createApiCall( + stub.then(function(stub) { return stub[methodName].bind(stub); }), + defaults[methodName]); + }.bind(this)); +} + +// Path templates + +var PARENT_PATH_TEMPLATE = new gax.PathTemplate( + 'projects/{project}'); + +var SINK_PATH_TEMPLATE = new gax.PathTemplate( + 'projects/{project}/sinks/{sink}'); + +/** + * Returns a fully-qualified parent resource name string. + * @param {String} project + * @returns {String} + */ +ConfigServiceV2Api.prototype.parentPath = function parentPath(project) { + return PARENT_PATH_TEMPLATE.render({ + 'project': project + }); +}; + +/** + * Parses the parentName from a parent resource. + * @param {String} parentName + * A fully-qualified path representing a parent resources. + * @returns {String} - A string representing the project. + */ +ConfigServiceV2Api.prototype.matchProjectFromParentName = + function matchProjectFromParentName(parentName) { + return PARENT_PATH_TEMPLATE.match(parentName).project; +}; + +/** + * Returns a fully-qualified sink resource name string. + * @param {String} project + * @param {String} sink + * @returns {String} + */ +ConfigServiceV2Api.prototype.sinkPath = function sinkPath(project, sink) { + return SINK_PATH_TEMPLATE.render({ + 'project': project, + 'sink': sink + }); +}; + +/** + * Parses the sinkName from a sink resource. + * @param {String} sinkName + * A fully-qualified path representing a sink resources. + * @returns {String} - A string representing the project. + */ +ConfigServiceV2Api.prototype.matchProjectFromSinkName = + function matchProjectFromSinkName(sinkName) { + return SINK_PATH_TEMPLATE.match(sinkName).project; +}; + +/** + * Parses the sinkName from a sink resource. + * @param {String} sinkName + * A fully-qualified path representing a sink resources. + * @returns {String} - A string representing the sink. + */ +ConfigServiceV2Api.prototype.matchSinkFromSinkName = + function matchSinkFromSinkName(sinkName) { + return SINK_PATH_TEMPLATE.match(sinkName).sink; +}; + +// Service calls + +/** + * Lists sinks. + * + * @param {string} parent + * Required. The resource name containing the sinks. + * Example: `"projects/my-logging-project"`. + * @param {Object=} otherArgs + * @param {number=} otherArgs.pageSize + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {gax.CallOptions=} options + * Overrides the default settings for this call, e.g, timeout, + * retries, etc. + * @returns {Stream} + * An object stream. By default, this emits an object representing + * [LogSink]{@link LogSink} on 'data' event. + * This object can also be configured to emit + * pages of the responses through the options parameter. + * + * @example + * + * var api = loggingV2.configServiceV2Api(); + * var formattedParent = api.parentPath("[PROJECT]"); + * api.listSinks(formattedParent).on('data', function(element) { + * // doThingsWith(element) + * }); + */ +ConfigServiceV2Api.prototype.listSinks = function listSinks() { + var args = arguejs({ + parent: String, + otherArgs: [Object, {}], + options: [gax.CallOptions], + callback: [Function] + }, arguments); + var req = { + parent: args.parent + }; + if ('pageSize' in args.otherArgs) { + req.page_size = args.otherArgs.pageSize; + } + return this._listSinks(req, args.options, args.callback); +}; + +/** + * Gets a sink. + * + * @param {string} sinkName + * The resource name of the sink to return. + * Example: `"projects/my-project-id/sinks/my-sink-id"`. + * @param {gax.CallOptions=} options + * Overrides the default settings for this call, e.g, timeout, + * retries, etc. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [LogSink]{@link LogSink} + * @returns {gax.EventEmitter} - the event emitter to handle the call + * status. + * + * @example + * + * var api = loggingV2.configServiceV2Api(); + * var formattedSinkName = api.sinkPath("[PROJECT]", "[SINK]"); + * api.getSink(formattedSinkName, function(err, response) { + * if (err) { + * console.error(err); + * return; + * } + * // doThingsWith(response) + * }); + */ +ConfigServiceV2Api.prototype.getSink = function getSink() { + var args = arguejs({ + sinkName: String, + options: [gax.CallOptions], + callback: [Function] + }, arguments); + var req = { + sink_name: args.sinkName + }; + return this._getSink(req, args.options, args.callback); +}; + +/** + * Creates a sink. + * + * @param {string} parent + * The resource in which to create the sink. + * Example: `"projects/my-project-id"`. + * + * The new sink must be provided in the request. + * @param {Object} sink + * The new sink, which must not have an identifier that already + * exists. + * + * This object should have the same structure as [LogSink]{@link LogSink} + * @param {gax.CallOptions=} options + * Overrides the default settings for this call, e.g, timeout, + * retries, etc. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [LogSink]{@link LogSink} + * @returns {gax.EventEmitter} - the event emitter to handle the call + * status. + * + * @example + * + * var api = loggingV2.configServiceV2Api(); + * var formattedParent = api.parentPath("[PROJECT]"); + * var sink = {}; + * api.createSink(formattedParent, sink, function(err, response) { + * if (err) { + * console.error(err); + * return; + * } + * // doThingsWith(response) + * }); + */ +ConfigServiceV2Api.prototype.createSink = function createSink() { + var args = arguejs({ + parent: String, + sink: Object, + options: [gax.CallOptions], + callback: [Function] + }, arguments); + var req = { + parent: args.parent, + sink: args.sink + }; + return this._createSink(req, args.options, args.callback); +}; + +/** + * Creates or updates a sink. + * + * @param {string} sinkName + * The resource name of the sink to update. + * Example: `"projects/my-project-id/sinks/my-sink-id"`. + * + * The updated sink must be provided in the request and have the + * same name that is specified in `sinkName`. If the sink does not + * exist, it is created. + * @param {Object} sink + * The updated sink, whose name must be the same as the sink + * identifier in `sinkName`. If `sinkName` does not exist, then + * this method creates a new sink. + * + * This object should have the same structure as [LogSink]{@link LogSink} + * @param {gax.CallOptions=} options + * Overrides the default settings for this call, e.g, timeout, + * retries, etc. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [LogSink]{@link LogSink} + * @returns {gax.EventEmitter} - the event emitter to handle the call + * status. + * + * @example + * + * var api = loggingV2.configServiceV2Api(); + * var formattedSinkName = api.sinkPath("[PROJECT]", "[SINK]"); + * var sink = {}; + * api.updateSink(formattedSinkName, sink, function(err, response) { + * if (err) { + * console.error(err); + * return; + * } + * // doThingsWith(response) + * }); + */ +ConfigServiceV2Api.prototype.updateSink = function updateSink() { + var args = arguejs({ + sinkName: String, + sink: Object, + options: [gax.CallOptions], + callback: [Function] + }, arguments); + var req = { + sink_name: args.sinkName, + sink: args.sink + }; + return this._updateSink(req, args.options, args.callback); +}; + +/** + * Deletes a sink. + * + * @param {string} sinkName + * The resource name of the sink to delete. + * Example: `"projects/my-project-id/sinks/my-sink-id"`. + * @param {gax.CallOptions=} options + * Overrides the default settings for this call, e.g, timeout, + * retries, etc. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @returns {gax.EventEmitter} - the event emitter to handle the call + * status. + * + * @example + * + * var api = loggingV2.configServiceV2Api(); + * var formattedSinkName = api.sinkPath("[PROJECT]", "[SINK]"); + * api.deleteSink(formattedSinkName, function(err) { + * if (err) { + * console.error(err); + * } + * }); + */ +ConfigServiceV2Api.prototype.deleteSink = function deleteSink() { + var args = arguejs({ + sinkName: String, + options: [gax.CallOptions], + callback: [Function] + }, arguments); + var req = { + sink_name: args.sinkName + }; + return this._deleteSink(req, args.options, args.callback); +}; + +function ConfigServiceV2ApiBuilder(gaxGrpc) { + if (!(this instanceof ConfigServiceV2ApiBuilder)) { + return new ConfigServiceV2ApiBuilder(gaxGrpc); + } + + var grpcClient = gaxGrpc.load([{ + root: require('google-proto-files')('..'), + file: 'google/logging/v2/logging_config.proto' + }]); + extend(this, grpcClient.google.logging.v2); + + /** + * Build a new instance of {@link ConfigServiceV2Api}. + * + * @param {Object=} opts - The optional parameters. + * @param {String=} opts.servicePath + * The domain name of the API remote host. + * @param {number=} opts.port + * The port on which to connect to the remote host. + * @param {grpc.ClientCredentials=} opts.sslCreds + * A ClientCredentials for use with an SSL-enabled channel. + * @param {Object=} opts.clientConfig + * The customized config to build the call settings. See + * {@link gax.constructSettings} for the format. + * @param {number=} opts.timeout + * The default timeout, in seconds, for calls made through this client. + * @param {number=} opts.appName + * The codename of the calling service. + * @param {String=} opts.appVersion + * The version of the calling service. + */ + this.configServiceV2Api = function(opts) { + return new ConfigServiceV2Api(gaxGrpc, grpcClient, opts); + }; + extend(this.configServiceV2Api, ConfigServiceV2Api); +}; +module.exports = ConfigServiceV2ApiBuilder; +module.exports.SERVICE_ADDRESS = SERVICE_ADDRESS; +module.exports.ALL_SCOPES = ALL_SCOPES; \ No newline at end of file diff --git a/packages/logging/src/v2/config_service_v2_client_config.json b/packages/logging/src/v2/config_service_v2_client_config.json new file mode 100644 index 00000000000..bdfd9c9e162 --- /dev/null +++ b/packages/logging/src/v2/config_service_v2_client_config.json @@ -0,0 +1,53 @@ +{ + "interfaces": { + "google.logging.v2.ConfigServiceV2": { + "retry_codes": { + "retry_codes_def": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "non_idempotent": [] + } + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.2, + "max_retry_delay_millis": 1000, + "initial_rpc_timeout_millis": 2000, + "rpc_timeout_multiplier": 1.5, + "max_rpc_timeout_millis": 30000, + "total_timeout_millis": 45000 + } + }, + "methods": { + "ListSinks": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetSink": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateSink": { + "timeout_millis": 30000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateSink": { + "timeout_millis": 30000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteSink": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/packages/logging/src/v2/index.js b/packages/logging/src/v2/index.js new file mode 100644 index 00000000000..6128b0e7f05 --- /dev/null +++ b/packages/logging/src/v2/index.js @@ -0,0 +1,42 @@ +/*! + * Copyright 2016 Google Inc. 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. + */ +'use strict'; + +var configServiceV2Api = require('./config_service_v2_api'); +var loggingServiceV2Api = require('./logging_service_v2_api'); +var metricsServiceV2Api = require('./metrics_service_v2_api'); +var extend = require('extend'); +var gax = require('google-gax'); +var lodash = require('lodash'); + +function v2(options) { + options = extend({ + scopes: v2.ALL_SCOPES + }, options); + var gaxGrpc = gax.grpc(options); + var result = {}; + extend(result, configServiceV2Api(gaxGrpc)); + extend(result, loggingServiceV2Api(gaxGrpc)); + extend(result, metricsServiceV2Api(gaxGrpc)); + return result; +} + +v2.SERVICE_ADDRESS = loggingServiceV2Api.SERVICE_ADDRESS; +v2.ALL_SCOPES = lodash.union( + configServiceV2Api.ALL_SCOPES, + loggingServiceV2Api.ALL_SCOPES, + metricsServiceV2Api.ALL_SCOPES); +module.exports = v2; diff --git a/packages/logging/src/v2/logging_service_v2_api.js b/packages/logging/src/v2/logging_service_v2_api.js new file mode 100644 index 00000000000..64690252df8 --- /dev/null +++ b/packages/logging/src/v2/logging_service_v2_api.js @@ -0,0 +1,454 @@ +/* + * Copyright 2016 Google Inc. 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. + * + * EDITING INSTRUCTIONS + * This file was generated from the file + * https://github.com/googleapis/googleapis/blob/master/google/logging/v2/logging.proto, + * and updates to that file get reflected here through a refresh process. + * For the short term, the refresh process will only be runnable by Google + * engineers. + * + * The only allowed edits are to method and file documentation. A 3-way + * merge preserves those additions if the generated source changes. + */ +/* TODO: introduce line-wrapping so that it never exceeds the limit. */ +/* jscs: disable maximumLineLength */ +'use strict'; + +var arguejs = require('arguejs'); +var configData = require('./logging_service_v2_client_config'); +var extend = require('extend'); +var gax = require('google-gax'); + +var SERVICE_ADDRESS = 'logging.googleapis.com'; + +var DEFAULT_SERVICE_PORT = 443; + +var CODE_GEN_NAME_VERSION = 'gapic/0.1.0'; + +var DEFAULT_TIMEOUT = 30; + +var PAGE_DESCRIPTORS = { + 'listLogEntries': new gax.PageDescriptor( + 'page_token', + 'next_page_token', + 'entries'), + 'listMonitoredResourceDescriptors': new gax.PageDescriptor( + 'page_token', + 'next_page_token', + 'resource_descriptors') +}; + +/** + * The scopes needed to make gRPC calls to all of the methods defined in + * this service. + */ +var ALL_SCOPES = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + 'https://www.googleapis.com/auth/logging.admin', + 'https://www.googleapis.com/auth/logging.read', + 'https://www.googleapis.com/auth/logging.write' +]; + +/** + * Service for ingesting and querying logs. + * + * This will be created through a builder function which can be obtained by the module. + * See the following example of how to initialize the module and how to access to the builder. + * @see {@link loggingServiceV2Api} + * + * @example + * var loggingV2 = require('@google-cloud/logging').v2({ + * // optional auth parameters. + * }); + * var api = loggingV2.loggingServiceV2Api(); + * + * @class + */ +function LoggingServiceV2Api(gaxGrpc, grpcClient, opts) { + opts = opts || {}; + var servicePath = opts.servicePath || SERVICE_ADDRESS; + var port = opts.port || DEFAULT_SERVICE_PORT; + var sslCreds = opts.sslCreds || null; + var clientConfig = opts.clientConfig || {}; + var timeout = opts.timeout || DEFAULT_TIMEOUT; + var appName = opts.appName || 'gax'; + var appVersion = opts.appVersion || gax.Version; + + var googleApiClient = [ + appName + '/' + appVersion, + CODE_GEN_NAME_VERSION, + 'nodejs/' + process.version].join(' '); + + var defaults = gaxGrpc.constructSettings( + 'google.logging.v2.LoggingServiceV2', + configData, + clientConfig, + timeout, + PAGE_DESCRIPTORS, + null, + {'x-goog-api-client': googleApiClient}); + + var stub = gaxGrpc.createStub( + servicePath, + port, + grpcClient.google.logging.v2.LoggingServiceV2, + {sslCreds: sslCreds}); + var methods = [ + 'deleteLog', + 'writeLogEntries', + 'listLogEntries', + 'listMonitoredResourceDescriptors' + ]; + methods.forEach(function(methodName) { + this['_' + methodName] = gax.createApiCall( + stub.then(function(stub) { return stub[methodName].bind(stub); }), + defaults[methodName]); + }.bind(this)); +} + +// Path templates + +var PARENT_PATH_TEMPLATE = new gax.PathTemplate( + 'projects/{project}'); + +var LOG_PATH_TEMPLATE = new gax.PathTemplate( + 'projects/{project}/logs/{log}'); + +/** + * Returns a fully-qualified parent resource name string. + * @param {String} project + * @returns {String} + */ +LoggingServiceV2Api.prototype.parentPath = function parentPath(project) { + return PARENT_PATH_TEMPLATE.render({ + 'project': project + }); +}; + +/** + * Parses the parentName from a parent resource. + * @param {String} parentName + * A fully-qualified path representing a parent resources. + * @returns {String} - A string representing the project. + */ +LoggingServiceV2Api.prototype.matchProjectFromParentName = + function matchProjectFromParentName(parentName) { + return PARENT_PATH_TEMPLATE.match(parentName).project; +}; + +/** + * Returns a fully-qualified log resource name string. + * @param {String} project + * @param {String} log + * @returns {String} + */ +LoggingServiceV2Api.prototype.logPath = function logPath(project, log) { + return LOG_PATH_TEMPLATE.render({ + 'project': project, + 'log': log + }); +}; + +/** + * Parses the logName from a log resource. + * @param {String} logName + * A fully-qualified path representing a log resources. + * @returns {String} - A string representing the project. + */ +LoggingServiceV2Api.prototype.matchProjectFromLogName = + function matchProjectFromLogName(logName) { + return LOG_PATH_TEMPLATE.match(logName).project; +}; + +/** + * Parses the logName from a log resource. + * @param {String} logName + * A fully-qualified path representing a log resources. + * @returns {String} - A string representing the log. + */ +LoggingServiceV2Api.prototype.matchLogFromLogName = + function matchLogFromLogName(logName) { + return LOG_PATH_TEMPLATE.match(logName).log; +}; + +// Service calls + +/** + * Deletes a log and all its log entries. + * The log will reappear if it receives new entries. + * + * @param {string} logName + * Required. The resource name of the log to delete. Example: + * `"projects/my-project/logs/syslog"`. + * @param {gax.CallOptions=} options + * Overrides the default settings for this call, e.g, timeout, + * retries, etc. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @returns {gax.EventEmitter} - the event emitter to handle the call + * status. + * + * @example + * + * var api = loggingV2.loggingServiceV2Api(); + * var formattedLogName = api.logPath("[PROJECT]", "[LOG]"); + * api.deleteLog(formattedLogName, function(err) { + * if (err) { + * console.error(err); + * } + * }); + */ +LoggingServiceV2Api.prototype.deleteLog = function deleteLog() { + var args = arguejs({ + logName: String, + options: [gax.CallOptions], + callback: [Function] + }, arguments); + var req = { + log_name: args.logName + }; + return this._deleteLog(req, args.options, args.callback); +}; + +/** + * Writes log entries to Stackdriver Logging. All log entries are + * written by this method. + * + * @param {Object[]} entries + * Required. The log entries to write. The log entries must have values for + * all required fields. + * + * To improve throughput and to avoid exceeding the quota limit for calls + * to `entries.write`, use this field to write multiple log entries at once + * rather than // calling this method for each log entry. + * + * This object should have the same structure as [LogEntry]{@link LogEntry} + * @param {Object=} otherArgs + * @param {string=} otherArgs.logName + * Optional. A default log resource name for those log entries in `entries` + * that do not specify their own `logName`. Example: + * `"projects/my-project/logs/syslog"`. See + * {@link LogEntry}. + * @param {Object=} otherArgs.resource + * Optional. A default monitored resource for those log entries in `entries` + * that do not specify their own `resource`. + * + * This object should have the same structure as [google.api.MonitoredResource]{@link external:"google.api.MonitoredResource"} + * @param {Object.=} otherArgs.labels + * Optional. User-defined `key:value` items that are added to + * the `labels` field of each log entry in `entries`, except when a log + * entry specifies its own `key:value` item with the same key. + * Example: `{ "size": "large", "color":"red" }` + * @param {boolean=} otherArgs.partialSuccess + * Optional. Whether valid entries should be written even if some other + * entries fail due to INVALID_ARGUMENT or PERMISSION_DENIED errors. If any + * entry is not written, the response status will be the error associated + * with one of the failed entries and include error details in the form of + * WriteLogEntriesPartialErrors. + * @param {gax.CallOptions=} options + * Overrides the default settings for this call, e.g, timeout, + * retries, etc. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [WriteLogEntriesResponse]{@link WriteLogEntriesResponse} + * @returns {gax.EventEmitter} - the event emitter to handle the call + * status. + * + * @example + * + * var api = loggingV2.loggingServiceV2Api(); + * var entries = []; + * api.writeLogEntries(entries, function(err, response) { + * if (err) { + * console.error(err); + * return; + * } + * // doThingsWith(response) + * }); + */ +LoggingServiceV2Api.prototype.writeLogEntries = function writeLogEntries() { + var args = arguejs({ + entries: Array, + otherArgs: [Object, {}], + options: [gax.CallOptions], + callback: [Function] + }, arguments); + var req = { + entries: args.entries + }; + if ('logName' in args.otherArgs) { + req.log_name = args.otherArgs.logName; + } + if ('resource' in args.otherArgs) { + req.resource = args.otherArgs.resource; + } + if ('labels' in args.otherArgs) { + req.labels = args.otherArgs.labels; + } + if ('partialSuccess' in args.otherArgs) { + req.partial_success = args.otherArgs.partialSuccess; + } + return this._writeLogEntries(req, args.options, args.callback); +}; + +/** + * Lists log entries. Use this method to retrieve log entries from Cloud + * Logging. For ways to export log entries, see + * [Exporting Logs](https://cloud.google.com/logging/docs/export). + * + * @param {string[]} projectIds + * Required. One or more project IDs or project numbers from which to retrieve + * log entries. Examples of a project ID: `"my-project-1A"`, `"1234567890"`. + * @param {Object=} otherArgs + * @param {string=} otherArgs.filter + * Optional. An [advanced logs filter](https://cloud.google.com/logging/docs/view/advanced_filters). + * The filter is compared against all log entries in the projects specified by + * `projectIds`. Only entries that match the filter are retrieved. An empty + * filter matches all log entries. + * @param {string=} otherArgs.orderBy + * Optional. How the results should be sorted. Presently, the only permitted + * values are `"timestamp asc"` (default) and `"timestamp desc"`. The first + * option returns entries in order of increasing values of + * `LogEntry.timestamp` (oldest first), and the second option returns entries + * in order of decreasing timestamps (newest first). Entries with equal + * timestamps are returned in order of `LogEntry.insertId`. + * @param {number=} otherArgs.pageSize + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {gax.CallOptions=} options + * Overrides the default settings for this call, e.g, timeout, + * retries, etc. + * @returns {Stream} + * An object stream. By default, this emits an object representing + * [LogEntry]{@link LogEntry} on 'data' event. + * This object can also be configured to emit + * pages of the responses through the options parameter. + * + * @example + * + * var api = loggingV2.loggingServiceV2Api(); + * var projectIds = []; + * api.listLogEntries(projectIds).on('data', function(element) { + * // doThingsWith(element) + * }); + */ +LoggingServiceV2Api.prototype.listLogEntries = function listLogEntries() { + var args = arguejs({ + projectIds: Array, + otherArgs: [Object, {}], + options: [gax.CallOptions], + callback: [Function] + }, arguments); + var req = { + project_ids: args.projectIds + }; + if ('filter' in args.otherArgs) { + req.filter = args.otherArgs.filter; + } + if ('orderBy' in args.otherArgs) { + req.order_by = args.otherArgs.orderBy; + } + if ('pageSize' in args.otherArgs) { + req.page_size = args.otherArgs.pageSize; + } + return this._listLogEntries(req, args.options, args.callback); +}; + +/** + * Lists the monitored resource descriptors used by Stackdriver Logging. + * + * @param {Object=} otherArgs + * @param {number=} otherArgs.pageSize + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {gax.CallOptions=} options + * Overrides the default settings for this call, e.g, timeout, + * retries, etc. + * @returns {Stream} + * An object stream. By default, this emits an object representing + * [google.api.MonitoredResourceDescriptor]{@link external:"google.api.MonitoredResourceDescriptor"} on 'data' event. + * This object can also be configured to emit + * pages of the responses through the options parameter. + * + * @example + * + * var api = loggingV2.loggingServiceV2Api(); + * + * api.listMonitoredResourceDescriptors().on('data', function(element) { + * // doThingsWith(element) + * }); + */ +LoggingServiceV2Api.prototype.listMonitoredResourceDescriptors = function listMonitoredResourceDescriptors() { + var args = arguejs({ + otherArgs: [Object, {}], + options: [gax.CallOptions], + callback: [Function] + }, arguments); + var req = { + }; + if ('pageSize' in args.otherArgs) { + req.page_size = args.otherArgs.pageSize; + } + return this._listMonitoredResourceDescriptors(req, args.options, args.callback); +}; + +function LoggingServiceV2ApiBuilder(gaxGrpc) { + if (!(this instanceof LoggingServiceV2ApiBuilder)) { + return new LoggingServiceV2ApiBuilder(gaxGrpc); + } + + var grpcClient = gaxGrpc.load([{ + root: require('google-proto-files')('..'), + file: 'google/logging/v2/logging.proto' + }]); + extend(this, grpcClient.google.logging.v2); + + /** + * Build a new instance of {@link LoggingServiceV2Api}. + * + * @param {Object=} opts - The optional parameters. + * @param {String=} opts.servicePath + * The domain name of the API remote host. + * @param {number=} opts.port + * The port on which to connect to the remote host. + * @param {grpc.ClientCredentials=} opts.sslCreds + * A ClientCredentials for use with an SSL-enabled channel. + * @param {Object=} opts.clientConfig + * The customized config to build the call settings. See + * {@link gax.constructSettings} for the format. + * @param {number=} opts.timeout + * The default timeout, in seconds, for calls made through this client. + * @param {number=} opts.appName + * The codename of the calling service. + * @param {String=} opts.appVersion + * The version of the calling service. + */ + this.loggingServiceV2Api = function(opts) { + return new LoggingServiceV2Api(gaxGrpc, grpcClient, opts); + }; + extend(this.loggingServiceV2Api, LoggingServiceV2Api); +}; +module.exports = LoggingServiceV2ApiBuilder; +module.exports.SERVICE_ADDRESS = SERVICE_ADDRESS; +module.exports.ALL_SCOPES = ALL_SCOPES; \ No newline at end of file diff --git a/packages/logging/src/v2/logging_service_v2_client_config.json b/packages/logging/src/v2/logging_service_v2_client_config.json new file mode 100644 index 00000000000..041bd4e3998 --- /dev/null +++ b/packages/logging/src/v2/logging_service_v2_client_config.json @@ -0,0 +1,57 @@ +{ + "interfaces": { + "google.logging.v2.LoggingServiceV2": { + "retry_codes": { + "retry_codes_def": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "non_idempotent": [] + } + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.2, + "max_retry_delay_millis": 1000, + "initial_rpc_timeout_millis": 2000, + "rpc_timeout_multiplier": 1.5, + "max_rpc_timeout_millis": 30000, + "total_timeout_millis": 45000 + }, + "list": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.2, + "max_retry_delay_millis": 1000, + "initial_rpc_timeout_millis": 7000, + "rpc_timeout_multiplier": 1.5, + "max_rpc_timeout_millis": 30000, + "total_timeout_millis": 45000 + } + }, + "methods": { + "DeleteLog": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "WriteLogEntries": { + "timeout_millis": 30000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListLogEntries": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "list" + }, + "ListMonitoredResourceDescriptors": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/packages/logging/src/v2/metrics_service_v2_api.js b/packages/logging/src/v2/metrics_service_v2_api.js new file mode 100644 index 00000000000..57295b15d59 --- /dev/null +++ b/packages/logging/src/v2/metrics_service_v2_api.js @@ -0,0 +1,450 @@ +/* + * Copyright 2016 Google Inc. 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. + * + * EDITING INSTRUCTIONS + * This file was generated from the file + * https://github.com/googleapis/googleapis/blob/master/google/logging/v2/logging_metrics.proto, + * and updates to that file get reflected here through a refresh process. + * For the short term, the refresh process will only be runnable by Google + * engineers. + * + * The only allowed edits are to method and file documentation. A 3-way + * merge preserves those additions if the generated source changes. + */ +/* TODO: introduce line-wrapping so that it never exceeds the limit. */ +/* jscs: disable maximumLineLength */ +'use strict'; + +var arguejs = require('arguejs'); +var configData = require('./metrics_service_v2_client_config'); +var extend = require('extend'); +var gax = require('google-gax'); + +var SERVICE_ADDRESS = 'logging.googleapis.com'; + +var DEFAULT_SERVICE_PORT = 443; + +var CODE_GEN_NAME_VERSION = 'gapic/0.1.0'; + +var DEFAULT_TIMEOUT = 30; + +var PAGE_DESCRIPTORS = { + 'listLogMetrics': new gax.PageDescriptor( + 'page_token', + 'next_page_token', + 'metrics') +}; + +/** + * The scopes needed to make gRPC calls to all of the methods defined in + * this service. + */ +var ALL_SCOPES = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + 'https://www.googleapis.com/auth/logging.admin', + 'https://www.googleapis.com/auth/logging.read', + 'https://www.googleapis.com/auth/logging.write' +]; + +/** + * Service for configuring logs-based metrics. + * + * This will be created through a builder function which can be obtained by the module. + * See the following example of how to initialize the module and how to access to the builder. + * @see {@link metricsServiceV2Api} + * + * @example + * var loggingV2 = require('@google-cloud/logging').v2({ + * // optional auth parameters. + * }); + * var api = loggingV2.metricsServiceV2Api(); + * + * @class + */ +function MetricsServiceV2Api(gaxGrpc, grpcClient, opts) { + opts = opts || {}; + var servicePath = opts.servicePath || SERVICE_ADDRESS; + var port = opts.port || DEFAULT_SERVICE_PORT; + var sslCreds = opts.sslCreds || null; + var clientConfig = opts.clientConfig || {}; + var timeout = opts.timeout || DEFAULT_TIMEOUT; + var appName = opts.appName || 'gax'; + var appVersion = opts.appVersion || gax.Version; + + var googleApiClient = [ + appName + '/' + appVersion, + CODE_GEN_NAME_VERSION, + 'nodejs/' + process.version].join(' '); + + var defaults = gaxGrpc.constructSettings( + 'google.logging.v2.MetricsServiceV2', + configData, + clientConfig, + timeout, + PAGE_DESCRIPTORS, + null, + {'x-goog-api-client': googleApiClient}); + + var stub = gaxGrpc.createStub( + servicePath, + port, + grpcClient.google.logging.v2.MetricsServiceV2, + {sslCreds: sslCreds}); + var methods = [ + 'listLogMetrics', + 'getLogMetric', + 'createLogMetric', + 'updateLogMetric', + 'deleteLogMetric' + ]; + methods.forEach(function(methodName) { + this['_' + methodName] = gax.createApiCall( + stub.then(function(stub) { return stub[methodName].bind(stub); }), + defaults[methodName]); + }.bind(this)); +} + +// Path templates + +var PARENT_PATH_TEMPLATE = new gax.PathTemplate( + 'projects/{project}'); + +var METRIC_PATH_TEMPLATE = new gax.PathTemplate( + 'projects/{project}/metrics/{metric}'); + +/** + * Returns a fully-qualified parent resource name string. + * @param {String} project + * @returns {String} + */ +MetricsServiceV2Api.prototype.parentPath = function parentPath(project) { + return PARENT_PATH_TEMPLATE.render({ + 'project': project + }); +}; + +/** + * Parses the parentName from a parent resource. + * @param {String} parentName + * A fully-qualified path representing a parent resources. + * @returns {String} - A string representing the project. + */ +MetricsServiceV2Api.prototype.matchProjectFromParentName = + function matchProjectFromParentName(parentName) { + return PARENT_PATH_TEMPLATE.match(parentName).project; +}; + +/** + * Returns a fully-qualified metric resource name string. + * @param {String} project + * @param {String} metric + * @returns {String} + */ +MetricsServiceV2Api.prototype.metricPath = function metricPath(project, metric) { + return METRIC_PATH_TEMPLATE.render({ + 'project': project, + 'metric': metric + }); +}; + +/** + * Parses the metricName from a metric resource. + * @param {String} metricName + * A fully-qualified path representing a metric resources. + * @returns {String} - A string representing the project. + */ +MetricsServiceV2Api.prototype.matchProjectFromMetricName = + function matchProjectFromMetricName(metricName) { + return METRIC_PATH_TEMPLATE.match(metricName).project; +}; + +/** + * Parses the metricName from a metric resource. + * @param {String} metricName + * A fully-qualified path representing a metric resources. + * @returns {String} - A string representing the metric. + */ +MetricsServiceV2Api.prototype.matchMetricFromMetricName = + function matchMetricFromMetricName(metricName) { + return METRIC_PATH_TEMPLATE.match(metricName).metric; +}; + +// Service calls + +/** + * Lists logs-based metrics. + * + * @param {string} parent + * Required. The resource name containing the metrics. + * Example: `"projects/my-project-id"`. + * @param {Object=} otherArgs + * @param {number=} otherArgs.pageSize + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {gax.CallOptions=} options + * Overrides the default settings for this call, e.g, timeout, + * retries, etc. + * @returns {Stream} + * An object stream. By default, this emits an object representing + * [LogMetric]{@link LogMetric} on 'data' event. + * This object can also be configured to emit + * pages of the responses through the options parameter. + * + * @example + * + * var api = loggingV2.metricsServiceV2Api(); + * var formattedParent = api.parentPath("[PROJECT]"); + * api.listLogMetrics(formattedParent).on('data', function(element) { + * // doThingsWith(element) + * }); + */ +MetricsServiceV2Api.prototype.listLogMetrics = function listLogMetrics() { + var args = arguejs({ + parent: String, + otherArgs: [Object, {}], + options: [gax.CallOptions], + callback: [Function] + }, arguments); + var req = { + parent: args.parent + }; + if ('pageSize' in args.otherArgs) { + req.page_size = args.otherArgs.pageSize; + } + return this._listLogMetrics(req, args.options, args.callback); +}; + +/** + * Gets a logs-based metric. + * + * @param {string} metricName + * The resource name of the desired metric. + * Example: `"projects/my-project-id/metrics/my-metric-id"`. + * @param {gax.CallOptions=} options + * Overrides the default settings for this call, e.g, timeout, + * retries, etc. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [LogMetric]{@link LogMetric} + * @returns {gax.EventEmitter} - the event emitter to handle the call + * status. + * + * @example + * + * var api = loggingV2.metricsServiceV2Api(); + * var formattedMetricName = api.metricPath("[PROJECT]", "[METRIC]"); + * api.getLogMetric(formattedMetricName, function(err, response) { + * if (err) { + * console.error(err); + * return; + * } + * // doThingsWith(response) + * }); + */ +MetricsServiceV2Api.prototype.getLogMetric = function getLogMetric() { + var args = arguejs({ + metricName: String, + options: [gax.CallOptions], + callback: [Function] + }, arguments); + var req = { + metric_name: args.metricName + }; + return this._getLogMetric(req, args.options, args.callback); +}; + +/** + * Creates a logs-based metric. + * + * @param {string} parent + * The resource name of the project in which to create the metric. + * Example: `"projects/my-project-id"`. + * + * The new metric must be provided in the request. + * @param {Object} metric + * The new logs-based metric, which must not have an identifier that + * already exists. + * + * This object should have the same structure as [LogMetric]{@link LogMetric} + * @param {gax.CallOptions=} options + * Overrides the default settings for this call, e.g, timeout, + * retries, etc. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [LogMetric]{@link LogMetric} + * @returns {gax.EventEmitter} - the event emitter to handle the call + * status. + * + * @example + * + * var api = loggingV2.metricsServiceV2Api(); + * var formattedParent = api.parentPath("[PROJECT]"); + * var metric = {}; + * api.createLogMetric(formattedParent, metric, function(err, response) { + * if (err) { + * console.error(err); + * return; + * } + * // doThingsWith(response) + * }); + */ +MetricsServiceV2Api.prototype.createLogMetric = function createLogMetric() { + var args = arguejs({ + parent: String, + metric: Object, + options: [gax.CallOptions], + callback: [Function] + }, arguments); + var req = { + parent: args.parent, + metric: args.metric + }; + return this._createLogMetric(req, args.options, args.callback); +}; + +/** + * Creates or updates a logs-based metric. + * + * @param {string} metricName + * The resource name of the metric to update. + * Example: `"projects/my-project-id/metrics/my-metric-id"`. + * + * The updated metric must be provided in the request and have the + * same identifier that is specified in `metricName`. + * If the metric does not exist, it is created. + * @param {Object} metric + * The updated metric, whose name must be the same as the + * metric identifier in `metricName`. If `metricName` does not + * exist, then a new metric is created. + * + * This object should have the same structure as [LogMetric]{@link LogMetric} + * @param {gax.CallOptions=} options + * Overrides the default settings for this call, e.g, timeout, + * retries, etc. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [LogMetric]{@link LogMetric} + * @returns {gax.EventEmitter} - the event emitter to handle the call + * status. + * + * @example + * + * var api = loggingV2.metricsServiceV2Api(); + * var formattedMetricName = api.metricPath("[PROJECT]", "[METRIC]"); + * var metric = {}; + * api.updateLogMetric(formattedMetricName, metric, function(err, response) { + * if (err) { + * console.error(err); + * return; + * } + * // doThingsWith(response) + * }); + */ +MetricsServiceV2Api.prototype.updateLogMetric = function updateLogMetric() { + var args = arguejs({ + metricName: String, + metric: Object, + options: [gax.CallOptions], + callback: [Function] + }, arguments); + var req = { + metric_name: args.metricName, + metric: args.metric + }; + return this._updateLogMetric(req, args.options, args.callback); +}; + +/** + * Deletes a logs-based metric. + * + * @param {string} metricName + * The resource name of the metric to delete. + * Example: `"projects/my-project-id/metrics/my-metric-id"`. + * @param {gax.CallOptions=} options + * Overrides the default settings for this call, e.g, timeout, + * retries, etc. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @returns {gax.EventEmitter} - the event emitter to handle the call + * status. + * + * @example + * + * var api = loggingV2.metricsServiceV2Api(); + * var formattedMetricName = api.metricPath("[PROJECT]", "[METRIC]"); + * api.deleteLogMetric(formattedMetricName, function(err) { + * if (err) { + * console.error(err); + * } + * }); + */ +MetricsServiceV2Api.prototype.deleteLogMetric = function deleteLogMetric() { + var args = arguejs({ + metricName: String, + options: [gax.CallOptions], + callback: [Function] + }, arguments); + var req = { + metric_name: args.metricName + }; + return this._deleteLogMetric(req, args.options, args.callback); +}; + +function MetricsServiceV2ApiBuilder(gaxGrpc) { + if (!(this instanceof MetricsServiceV2ApiBuilder)) { + return new MetricsServiceV2ApiBuilder(gaxGrpc); + } + + var grpcClient = gaxGrpc.load([{ + root: require('google-proto-files')('..'), + file: 'google/logging/v2/logging_metrics.proto' + }]); + extend(this, grpcClient.google.logging.v2); + + /** + * Build a new instance of {@link MetricsServiceV2Api}. + * + * @param {Object=} opts - The optional parameters. + * @param {String=} opts.servicePath + * The domain name of the API remote host. + * @param {number=} opts.port + * The port on which to connect to the remote host. + * @param {grpc.ClientCredentials=} opts.sslCreds + * A ClientCredentials for use with an SSL-enabled channel. + * @param {Object=} opts.clientConfig + * The customized config to build the call settings. See + * {@link gax.constructSettings} for the format. + * @param {number=} opts.timeout + * The default timeout, in seconds, for calls made through this client. + * @param {number=} opts.appName + * The codename of the calling service. + * @param {String=} opts.appVersion + * The version of the calling service. + */ + this.metricsServiceV2Api = function(opts) { + return new MetricsServiceV2Api(gaxGrpc, grpcClient, opts); + }; + extend(this.metricsServiceV2Api, MetricsServiceV2Api); +}; +module.exports = MetricsServiceV2ApiBuilder; +module.exports.SERVICE_ADDRESS = SERVICE_ADDRESS; +module.exports.ALL_SCOPES = ALL_SCOPES; \ No newline at end of file diff --git a/packages/logging/src/v2/metrics_service_v2_client_config.json b/packages/logging/src/v2/metrics_service_v2_client_config.json new file mode 100644 index 00000000000..0400cb5bb63 --- /dev/null +++ b/packages/logging/src/v2/metrics_service_v2_client_config.json @@ -0,0 +1,53 @@ +{ + "interfaces": { + "google.logging.v2.MetricsServiceV2": { + "retry_codes": { + "retry_codes_def": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "non_idempotent": [] + } + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.2, + "max_retry_delay_millis": 1000, + "initial_rpc_timeout_millis": 2000, + "rpc_timeout_multiplier": 1.5, + "max_rpc_timeout_millis": 30000, + "total_timeout_millis": 45000 + } + }, + "methods": { + "ListLogMetrics": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetLogMetric": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateLogMetric": { + "timeout_millis": 30000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateLogMetric": { + "timeout_millis": 30000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteLogMetric": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +}