diff --git a/baselines/bigquery-storage/src/v1beta1/big_query_storage_client.ts.baseline b/baselines/bigquery-storage/src/v1beta1/big_query_storage_client.ts.baseline index efb073386..be0a906b2 100644 --- a/baselines/bigquery-storage/src/v1beta1/big_query_storage_client.ts.baseline +++ b/baselines/bigquery-storage/src/v1beta1/big_query_storage_client.ts.baseline @@ -33,7 +33,7 @@ const version = require('../../../package.json').version; * @memberof v1beta1 */ export class BigQueryStorageClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; private _innerApiCalls: {[name: string]: Function}; private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; diff --git a/baselines/disable-packing-test/src/v1beta1/echo_client.ts.baseline b/baselines/disable-packing-test/src/v1beta1/echo_client.ts.baseline index 7c9f1cc0b..57ccbd3bc 100644 --- a/baselines/disable-packing-test/src/v1beta1/echo_client.ts.baseline +++ b/baselines/disable-packing-test/src/v1beta1/echo_client.ts.baseline @@ -36,7 +36,7 @@ const version = require('../../../package.json').version; * @memberof v1beta1 */ export class EchoClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; private _innerApiCalls: {[name: string]: Function}; private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; diff --git a/baselines/disable-packing-test/src/v1beta1/identity_client.ts.baseline b/baselines/disable-packing-test/src/v1beta1/identity_client.ts.baseline index b3edf3441..066b2650e 100644 --- a/baselines/disable-packing-test/src/v1beta1/identity_client.ts.baseline +++ b/baselines/disable-packing-test/src/v1beta1/identity_client.ts.baseline @@ -32,7 +32,7 @@ const version = require('../../../package.json').version; * @memberof v1beta1 */ export class IdentityClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; private _innerApiCalls: {[name: string]: Function}; private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; diff --git a/baselines/disable-packing-test/src/v1beta1/messaging_client.ts.baseline b/baselines/disable-packing-test/src/v1beta1/messaging_client.ts.baseline index 7c21f8e28..94c5aa9cc 100644 --- a/baselines/disable-packing-test/src/v1beta1/messaging_client.ts.baseline +++ b/baselines/disable-packing-test/src/v1beta1/messaging_client.ts.baseline @@ -35,7 +35,7 @@ const version = require('../../../package.json').version; * @memberof v1beta1 */ export class MessagingClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; private _innerApiCalls: {[name: string]: Function}; private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; diff --git a/baselines/disable-packing-test/src/v1beta1/testing_client.ts.baseline b/baselines/disable-packing-test/src/v1beta1/testing_client.ts.baseline index c0adac96b..26e2cc804 100644 --- a/baselines/disable-packing-test/src/v1beta1/testing_client.ts.baseline +++ b/baselines/disable-packing-test/src/v1beta1/testing_client.ts.baseline @@ -33,7 +33,7 @@ const version = require('../../../package.json').version; * @memberof v1beta1 */ export class TestingClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; private _innerApiCalls: {[name: string]: Function}; private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; diff --git a/baselines/dlp/src/v2/dlp_service_client.ts.baseline b/baselines/dlp/src/v2/dlp_service_client.ts.baseline index 0b53cb98c..a58d846af 100644 --- a/baselines/dlp/src/v2/dlp_service_client.ts.baseline +++ b/baselines/dlp/src/v2/dlp_service_client.ts.baseline @@ -40,7 +40,7 @@ const version = require('../../../package.json').version; * @memberof v2 */ export class DlpServiceClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; private _innerApiCalls: {[name: string]: Function}; private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; diff --git a/baselines/kms/src/v1/key_management_service_client.ts.baseline b/baselines/kms/src/v1/key_management_service_client.ts.baseline index 56df2159f..a1bab6ae5 100644 --- a/baselines/kms/src/v1/key_management_service_client.ts.baseline +++ b/baselines/kms/src/v1/key_management_service_client.ts.baseline @@ -42,7 +42,7 @@ const version = require('../../../package.json').version; * @memberof v1 */ export class KeyManagementServiceClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; private _innerApiCalls: {[name: string]: Function}; private _terminated = false; private _opts: ClientOptions; diff --git a/baselines/logging/.gitignore.baseline b/baselines/logging/.gitignore.baseline new file mode 100644 index 000000000..5d32b2378 --- /dev/null +++ b/baselines/logging/.gitignore.baseline @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/baselines/logging/.jsdoc.js.baseline b/baselines/logging/.jsdoc.js.baseline new file mode 100644 index 000000000..6bd13fe8d --- /dev/null +++ b/baselines/logging/.jsdoc.js.baseline @@ -0,0 +1,55 @@ +// Copyright 2020 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2019 Google, LLC.', + includeDate: false, + sourceFiles: false, + systemName: 'logging', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/baselines/logging/.mocharc.json.baseline b/baselines/logging/.mocharc.json.baseline new file mode 100644 index 000000000..670c5e2c2 --- /dev/null +++ b/baselines/logging/.mocharc.json.baseline @@ -0,0 +1,5 @@ +{ + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} diff --git a/baselines/logging/README.md.baseline b/baselines/logging/README.md.baseline new file mode 100644 index 000000000..bdf6f36eb --- /dev/null +++ b/baselines/logging/README.md.baseline @@ -0,0 +1 @@ +Logging: Nodejs Client diff --git a/baselines/logging/linkinator.config.json.baseline b/baselines/logging/linkinator.config.json.baseline new file mode 100644 index 000000000..29a223b6d --- /dev/null +++ b/baselines/logging/linkinator.config.json.baseline @@ -0,0 +1,10 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io" + ], + "silent": true, + "concurrency": 10 +} diff --git a/baselines/logging/package.json b/baselines/logging/package.json new file mode 100644 index 000000000..cad77a5d1 --- /dev/null +++ b/baselines/logging/package.json @@ -0,0 +1,49 @@ +{ + "name": "logging", + "version": "0.1.0", + "description": "Logging client for Node.js", + "repository": "googleapis/nodejs-logging", + "license": "Apache-2.0", + "author": "Google LLC", + "files": [ + "build/src", + "build/protos" + ], + "main": "build/src/index.js", + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "predocs-test": "npm run docs", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^1.15.1" + }, + "devDependencies": { + "@types/mocha": "^5.2.7", + "@types/node": "^12.12.30", + "c8": "^7.1.0", + "gts": "^1.1.2", + "jsdoc": "^3.6.3", + "jsdoc-fresh": "^1.0.2", + "jsdoc-region-tag": "^1.0.4", + "linkinator": "^2.0.3", + "mocha": "^6.2.2", + "pack-n-play": "^1.0.0-2", + "null-loader": "^3.0.0", + "ts-loader": "^6.2.1", + "typescript": "~3.7.5", + "webpack": "^4.42.0", + "webpack-cli": "^3.3.11" + }, + "engines": { + "node": ">=8.13.0" + } +} diff --git a/baselines/logging/package.json.baseline b/baselines/logging/package.json.baseline new file mode 120000 index 000000000..2ff8622f1 --- /dev/null +++ b/baselines/logging/package.json.baseline @@ -0,0 +1 @@ +package.json \ No newline at end of file diff --git a/baselines/logging/proto.list.baseline b/baselines/logging/proto.list.baseline new file mode 100644 index 000000000..40fea00c0 --- /dev/null +++ b/baselines/logging/proto.list.baseline @@ -0,0 +1,25 @@ +google/protobuf/descriptor.proto +google/api/field_behavior.proto +google/api/label.proto +google/api/launch_stage.proto +google/protobuf/struct.proto +google/api/monitored_resource.proto +google/api/resource.proto +google/protobuf/duration.proto +google/api/http.proto +google/api/annotations.proto +google/logging/type/http_request.proto +google/logging/type/log_severity.proto +google/protobuf/any.proto +google/protobuf/timestamp.proto +google/rpc/status.proto +google/logging/v2/log_entry.proto +google/api/client.proto +google/protobuf/empty.proto +google/protobuf/field_mask.proto +google/logging/v2/logging_config.proto +google/logging/v2/logging.proto +google/api/distribution.proto +google/api/metric.proto +google/logging/v2/logging_metrics.proto +google/cloud/common_resources.proto diff --git a/baselines/logging/protos/google/cloud/common_resources.proto.baseline b/baselines/logging/protos/google/cloud/common_resources.proto.baseline new file mode 100644 index 000000000..a2f46cea3 --- /dev/null +++ b/baselines/logging/protos/google/cloud/common_resources.proto.baseline @@ -0,0 +1,52 @@ +// Copyright 2020 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. + +// This file contains stub messages for common resources in GCP. +// It is not intended to be directly generated, and is instead used by +// other tooling to be able to match common resource patterns. +syntax = "proto3"; + +package google.cloud; + +import "google/api/resource.proto"; + + +option (google.api.resource_definition) = { + type: "cloudresourcemanager.googleapis.com/Project" + pattern: "projects/{project}" +}; + + +option (google.api.resource_definition) = { + type: "cloudresourcemanager.googleapis.com/Organization" + pattern: "organizations/{organization}" +}; + + +option (google.api.resource_definition) = { + type: "cloudresourcemanager.googleapis.com/Folder" + pattern: "folders/{folder}" +}; + + +option (google.api.resource_definition) = { + type: "cloudbilling.googleapis.com/BillingAccount" + pattern: "billingAccounts/{billing_account}" +}; + +option (google.api.resource_definition) = { + type: "locations.googleapis.com/Location" + pattern: "projects/{project}/locations/{location}" +}; + diff --git a/baselines/logging/protos/google/logging/v2/log_entry.proto.baseline b/baselines/logging/protos/google/logging/v2/log_entry.proto.baseline new file mode 100644 index 000000000..ba8a08ff2 --- /dev/null +++ b/baselines/logging/protos/google/logging/v2/log_entry.proto.baseline @@ -0,0 +1,210 @@ +// 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.logging.v2; + +import "google/api/field_behavior.proto"; +import "google/api/monitored_resource.proto"; +import "google/api/resource.proto"; +import "google/logging/type/http_request.proto"; +import "google/logging/type/log_severity.proto"; +import "google/protobuf/any.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/api/annotations.proto"; + +option cc_enable_arenas = true; +option csharp_namespace = "Google.Cloud.Logging.V2"; +option go_package = "google.golang.org/genproto/googleapis/logging/v2;logging"; +option java_multiple_files = true; +option java_outer_classname = "LogEntryProto"; +option java_package = "com.google.logging.v2"; +option php_namespace = "Google\\Cloud\\Logging\\V2"; + +// An individual entry in a log. +// +// +message LogEntry { + option (google.api.resource) = { + type: "logging.googleapis.com/Log" + pattern: "projects/{project}/logs/{log}" + pattern: "organizations/{organization}/logs/{log}" + pattern: "folders/{folder}/logs/{log}" + pattern: "billingAccounts/{billing_account}/logs/{log}" + name_field: "log_name" + }; + + // Required. The resource name of the log to which this log entry belongs: + // + // "projects/[PROJECT_ID]/logs/[LOG_ID]" + // "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" + // "folders/[FOLDER_ID]/logs/[LOG_ID]" + // + // A project number may be used in place of PROJECT_ID. The project number is + // translated to its corresponding PROJECT_ID internally and the `log_name` + // field will contain PROJECT_ID in queries and exports. + // + // `[LOG_ID]` must be URL-encoded within `log_name`. Example: + // `"organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity"`. + // `[LOG_ID]` must be less than 512 characters long and can only include the + // following characters: upper and lower case alphanumeric characters, + // forward-slash, underscore, hyphen, and period. + // + // For backward compatibility, if `log_name` begins with a forward-slash, such + // as `/projects/...`, then the log entry is ingested as usual but the + // forward-slash is removed. Listing the log entry will not show the leading + // slash and filtering for a log name with a leading slash will never return + // any results. + string log_name = 12 [(google.api.field_behavior) = REQUIRED]; + + // Required. The monitored resource that produced this log entry. + // + // Example: a log entry that reports a database error would be associated with + // the monitored resource designating the particular database that reported + // the error. + google.api.MonitoredResource resource = 8 [(google.api.field_behavior) = REQUIRED]; + + // The log entry payload, which can be one of multiple types. + oneof payload { + // The log entry payload, represented as a protocol buffer. Some Google + // Cloud Platform services use this field for their log entry payloads. + // + // The following protocol buffer types are supported; user-defined types + // are not supported: + // + // "type.googleapis.com/google.cloud.audit.AuditLog" + // "type.googleapis.com/google.appengine.logging.v1.RequestLog" + 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 json_payload = 6; + } + + // Optional. The time the event described by the log entry occurred. This time is used + // to compute the log entry's age and to enforce the logs retention period. + // If this field is omitted in a new log entry, then Logging assigns it the + // current time. Timestamps have nanosecond accuracy, but trailing zeros in + // the fractional seconds might be omitted when the timestamp is displayed. + // + // Incoming log entries should have timestamps that are no more than the [logs + // retention period](/logging/quotas) in the past, and no more than 24 hours + // in the future. Log entries outside those time boundaries will not be + // available when calling `entries.list`, but those log entries can still be + // [exported with LogSinks](/logging/docs/api/tasks/exporting-logs). + google.protobuf.Timestamp timestamp = 9 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The time the log entry was received by Logging. + google.protobuf.Timestamp receive_timestamp = 24 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. The severity of the log entry. The default value is `LogSeverity.DEFAULT`. + google.logging.type.LogSeverity severity = 10 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A unique identifier for the log entry. If you provide a value, then + // Logging considers other log entries in the same project, with the same + // `timestamp`, and with the same `insert_id` to be duplicates which are + // removed in a single query result. However, there are no guarantees of + // de-duplication in the export of logs. + // + // If the `insert_id` is omitted when writing a log entry, the Logging API + // assigns its own unique identifier in this field. + // + // In queries, the `insert_id` is also used to order log entries that have + // the same `log_name` and `timestamp` values. + string insert_id = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Information about the HTTP request associated with this log entry, if + // applicable. + google.logging.type.HttpRequest http_request = 7 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A set of user-defined (key, value) data that provides additional + // information about the log entry. + map labels = 11 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Information about an operation associated with the log entry, if + // applicable. + LogEntryOperation operation = 15 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Resource name of the trace associated with the log entry, if any. If it + // contains a relative resource name, the name is assumed to be relative to + // `//tracing.googleapis.com`. Example: + // `projects/my-projectid/traces/06796866738c859f2f19b7cfb3214824` + string trace = 22 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The span ID within the trace associated with the log entry. + // + // For Trace spans, this is the same format that the Trace API v2 uses: a + // 16-character hexadecimal encoding of an 8-byte array, such as + // `000000000000004a`. + string span_id = 27 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The sampling decision of the trace associated with the log entry. + // + // True means that the trace resource name in the `trace` field was sampled + // for storage in a trace backend. False means that the trace was not sampled + // for storage when this log entry was written, or the sampling decision was + // unknown at the time. A non-sampled `trace` value is still useful as a + // request correlation identifier. The default is False. + bool trace_sampled = 30 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Source code location information associated with the log entry, if any. + LogEntrySourceLocation source_location = 23 [(google.api.field_behavior) = OPTIONAL]; +} + +// Additional information about a potentially long-running operation with which +// a log entry is associated. +message LogEntryOperation { + // Optional. An arbitrary operation identifier. Log entries with the same + // identifier are assumed to be part of the same operation. + string id = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. An arbitrary producer identifier. The combination of `id` and + // `producer` must be globally unique. Examples for `producer`: + // `"MyDivision.MyBigCompany.com"`, `"github.com/MyProject/MyApplication"`. + string producer = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Set this to True if this is the first log entry in the operation. + bool first = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Set this to True if this is the last log entry in the operation. + bool last = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Additional information about the source code location that produced the log +// entry. +message LogEntrySourceLocation { + // Optional. Source file name. Depending on the runtime environment, this + // might be a simple name or a fully-qualified name. + string file = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Line within the source file. 1-based; 0 indicates no line number + // available. + int64 line = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Human-readable name of the function or method being invoked, with + // optional context such as the class or package name. This information may be + // used in contexts such as the logs viewer, where a file and line number are + // less meaningful. The format can vary by language. For example: + // `qual.if.ied.Class.method` (Java), `dir/package.func` (Go), `function` + // (Python). + string function = 3 [(google.api.field_behavior) = OPTIONAL]; +} diff --git a/baselines/logging/protos/google/logging/v2/logging.proto.baseline b/baselines/logging/protos/google/logging/v2/logging.proto.baseline new file mode 100644 index 000000000..00af178c3 --- /dev/null +++ b/baselines/logging/protos/google/logging/v2/logging.proto.baseline @@ -0,0 +1,375 @@ +// 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.logging.v2; + +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/monitored_resource.proto"; +import "google/api/resource.proto"; +import "google/logging/v2/log_entry.proto"; +import "google/logging/v2/logging_config.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/api/annotations.proto"; + +option cc_enable_arenas = true; +option csharp_namespace = "Google.Cloud.Logging.V2"; +option go_package = "google.golang.org/genproto/googleapis/logging/v2;logging"; +option java_multiple_files = true; +option java_outer_classname = "LoggingProto"; +option java_package = "com.google.logging.v2"; +option php_namespace = "Google\\Cloud\\Logging\\V2"; + +// Service for ingesting and querying logs. +service LoggingServiceV2 { + option (google.api.default_host) = "logging.googleapis.com"; + option (google.api.oauth_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"; + + // Deletes all the log entries in a log. The log reappears if it receives new + // entries. Log entries written shortly before the delete operation might not + // be deleted. Entries received after the delete operation with a timestamp + // before the operation will be deleted. + rpc DeleteLog(DeleteLogRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2/{log_name=projects/*/logs/*}" + additional_bindings { + delete: "/v2/{log_name=*/*/logs/*}" + } + additional_bindings { + delete: "/v2/{log_name=organizations/*/logs/*}" + } + additional_bindings { + delete: "/v2/{log_name=folders/*/logs/*}" + } + additional_bindings { + delete: "/v2/{log_name=billingAccounts/*/logs/*}" + } + }; + option (google.api.method_signature) = "log_name"; + } + + // Writes log entries to Logging. This API method is the + // only way to send log entries to Logging. This method + // is used, directly or indirectly, by the Logging agent + // (fluentd) and all logging libraries configured to use Logging. + // A single request may contain log entries for a maximum of 1000 + // different resources (projects, organizations, billing accounts or + // folders) + rpc WriteLogEntries(WriteLogEntriesRequest) returns (WriteLogEntriesResponse) { + option (google.api.http) = { + post: "/v2/entries:write" + body: "*" + }; + option (google.api.method_signature) = "log_name,resource,labels,entries"; + } + + // Lists log entries. Use this method to retrieve log entries that originated + // from a project/folder/organization/billing account. For ways to export log + // entries, see [Exporting Logs](/logging/docs/export). + rpc ListLogEntries(ListLogEntriesRequest) returns (ListLogEntriesResponse) { + option (google.api.http) = { + post: "/v2/entries:list" + body: "*" + }; + option (google.api.method_signature) = "resource_names,filter,order_by"; + } + + // Lists the descriptors for monitored resource types used by Logging. + rpc ListMonitoredResourceDescriptors(ListMonitoredResourceDescriptorsRequest) returns (ListMonitoredResourceDescriptorsResponse) { + option (google.api.http) = { + get: "/v2/monitoredResourceDescriptors" + }; + } + + // Lists the logs in projects, organizations, folders, or billing accounts. + // Only logs that have entries are listed. + rpc ListLogs(ListLogsRequest) returns (ListLogsResponse) { + option (google.api.http) = { + get: "/v2/{parent=*/*}/logs" + additional_bindings { + get: "/v2/{parent=projects/*}/logs" + } + additional_bindings { + get: "/v2/{parent=organizations/*}/logs" + } + additional_bindings { + get: "/v2/{parent=folders/*}/logs" + } + additional_bindings { + get: "/v2/{parent=billingAccounts/*}/logs" + } + }; + option (google.api.method_signature) = "parent"; + } +} + +// The parameters to DeleteLog. +message DeleteLogRequest { + // Required. The resource name of the log to delete: + // + // "projects/[PROJECT_ID]/logs/[LOG_ID]" + // "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" + // "folders/[FOLDER_ID]/logs/[LOG_ID]" + // + // `[LOG_ID]` must be URL-encoded. For example, + // `"projects/my-project-id/logs/syslog"`, + // `"organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity"`. + // For more information about log names, see + // [LogEntry][google.logging.v2.LogEntry]. + string log_name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "logging.googleapis.com/Log" + } + ]; +} + +// The parameters to WriteLogEntries. +message WriteLogEntriesRequest { + // Optional. A default log resource name that is assigned to all log entries + // in `entries` that do not specify a value for `log_name`: + // + // "projects/[PROJECT_ID]/logs/[LOG_ID]" + // "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" + // "folders/[FOLDER_ID]/logs/[LOG_ID]" + // + // `[LOG_ID]` must be URL-encoded. For example: + // + // "projects/my-project-id/logs/syslog" + // "organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity" + // + // The permission `logging.logEntries.create` is needed on each project, + // organization, billing account, or folder that is receiving new log + // entries, whether the resource is specified in `logName` or in an + // individual log entry. + string log_name = 1 [ + (google.api.field_behavior) = OPTIONAL, + (google.api.resource_reference) = { + type: "logging.googleapis.com/Log" + } + ]; + + // Optional. A default monitored resource object that is assigned to all log + // entries in `entries` that do not specify a value for `resource`. Example: + // + // { "type": "gce_instance", + // "labels": { + // "zone": "us-central1-a", "instance_id": "00000000000000000000" }} + // + // See [LogEntry][google.logging.v2.LogEntry]. + google.api.MonitoredResource resource = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Default labels that are added to the `labels` field of all log + // entries in `entries`. If a log entry already has a label with the same key + // as a label in this parameter, then the log entry's label is not changed. + // See [LogEntry][google.logging.v2.LogEntry]. + map labels = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Required. The log entries to send to Logging. The order of log + // entries in this list does not matter. Values supplied in this method's + // `log_name`, `resource`, and `labels` fields are copied into those log + // entries in this list that do not include values for their corresponding + // fields. For more information, see the + // [LogEntry][google.logging.v2.LogEntry] type. + // + // If the `timestamp` or `insert_id` fields are missing in log entries, then + // this method supplies the current time or a unique identifier, respectively. + // The supplied values are chosen so that, among the log entries that did not + // supply their own values, the entries earlier in the list will sort before + // the entries later in the list. See the `entries.list` method. + // + // Log entries with timestamps that are more than the + // [logs retention period](/logging/quota-policy) in the past or more than + // 24 hours in the future will not be available when calling `entries.list`. + // However, those log entries can still be + // [exported with LogSinks](/logging/docs/api/tasks/exporting-logs). + // + // To improve throughput and to avoid exceeding the + // [quota limit](/logging/quota-policy) for calls to `entries.write`, + // you should try to include several log entries in this list, + // rather than calling this method for each individual log entry. + repeated LogEntry entries = 4 [(google.api.field_behavior) = REQUIRED]; + + // 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, then the response status is the error associated + // with one of the failed entries and the response includes error details + // keyed by the entries' zero-based index in the `entries.write` method. + bool partial_success = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If true, the request should expect normal response, but the + // entries won't be persisted nor exported. Useful for checking whether the + // logging API endpoints are working properly before sending valuable data. + bool dry_run = 6 [(google.api.field_behavior) = OPTIONAL]; +} + +// Result returned from WriteLogEntries. +message WriteLogEntriesResponse {} + +// Error details for WriteLogEntries with partial success. +message WriteLogEntriesPartialErrors { + // When `WriteLogEntriesRequest.partial_success` is true, records the error + // status for entries that were not written due to a permanent error, keyed + // by the entry's zero-based index in `WriteLogEntriesRequest.entries`. + // + // Failed requests for which no entries are written will not include + // per-entry errors. + map log_entry_errors = 1; +} + +// The parameters to `ListLogEntries`. +message ListLogEntriesRequest { + // Required. Names of one or more parent resources from which to + // retrieve log entries: + // + // "projects/[PROJECT_ID]" + // "organizations/[ORGANIZATION_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]" + // "folders/[FOLDER_ID]" + // + // + // Projects listed in the `project_ids` field are added to this list. + repeated string resource_names = 8 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "logging.googleapis.com/Log" + } + ]; + + // Optional. A filter that chooses which log entries to return. See [Advanced + // Logs Queries](/logging/docs/view/advanced-queries). Only log entries that + // match the filter are returned. An empty filter matches all log entries in + // the resources listed in `resource_names`. Referencing a parent resource + // that is not listed in `resource_names` will cause the filter to return no + // results. + // The maximum length of the filter is 20000 characters. + string filter = 2 [(google.api.field_behavior) = OPTIONAL]; + + // 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 their `insert_id` values. + string order_by = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maximum number of results to return from this request. + // Non-positive values are ignored. The presence of `next_page_token` in the + // response indicates that more results might be available. + int32 page_size = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If present, then retrieve the next batch of results from the + // preceding call to this method. `page_token` must be the value of + // `next_page_token` from the previous response. The values of other method + // parameters should be identical to those in the previous call. + string page_token = 5 [(google.api.field_behavior) = OPTIONAL]; +} + +// Result returned from `ListLogEntries`. +message ListLogEntriesResponse { + // A list of log entries. If `entries` is empty, `nextPageToken` may still be + // returned, indicating that more entries may exist. See `nextPageToken` for + // more information. + repeated LogEntry entries = 1; + + // If there might be more results than those appearing in this response, then + // `nextPageToken` is included. To get the next set of results, call this + // method again using the value of `nextPageToken` as `pageToken`. + // + // If a value for `next_page_token` appears and the `entries` field is empty, + // it means that the search found no log entries so far but it did not have + // time to search all the possible log entries. Retry the method with this + // value for `page_token` to continue the search. Alternatively, consider + // speeding up the search by changing your filter to specify a single log name + // or resource type, or to narrow the time range of the search. + string next_page_token = 2; +} + +// The parameters to ListMonitoredResourceDescriptors +message ListMonitoredResourceDescriptorsRequest { + // Optional. The maximum number of results to return from this request. + // Non-positive values are ignored. The presence of `nextPageToken` in the + // response indicates that more results might be available. + int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If present, then retrieve the next batch of results from the + // preceding call to this method. `pageToken` must be the value of + // `nextPageToken` from the previous response. The values of other method + // parameters should be identical to those in the previous call. + string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// Result returned from ListMonitoredResourceDescriptors. +message ListMonitoredResourceDescriptorsResponse { + // A list of resource descriptors. + repeated google.api.MonitoredResourceDescriptor resource_descriptors = 1; + + // If there might be more results than those appearing in this response, then + // `nextPageToken` is included. To get the next set of results, call this + // method again using the value of `nextPageToken` as `pageToken`. + string next_page_token = 2; +} + +// The parameters to ListLogs. +message ListLogsRequest { + // Required. The resource name that owns the logs: + // + // "projects/[PROJECT_ID]" + // "organizations/[ORGANIZATION_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]" + // "folders/[FOLDER_ID]" + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "logging.googleapis.com/Log" + } + ]; + + // Optional. The maximum number of results to return from this request. + // Non-positive values are ignored. The presence of `nextPageToken` in the + // response indicates that more results might be available. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If present, then retrieve the next batch of results from the + // preceding call to this method. `pageToken` must be the value of + // `nextPageToken` from the previous response. The values of other method + // parameters should be identical to those in the previous call. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Result returned from ListLogs. +message ListLogsResponse { + // A list of log names. For example, + // `"projects/my-project/logs/syslog"` or + // `"organizations/123/logs/cloudresourcemanager.googleapis.com%2Factivity"`. + repeated string log_names = 3; + + // If there might be more results than those appearing in this response, then + // `nextPageToken` is included. To get the next set of results, call this + // method again using the value of `nextPageToken` as `pageToken`. + string next_page_token = 2; +} diff --git a/baselines/logging/protos/google/logging/v2/logging_config.proto.baseline b/baselines/logging/protos/google/logging/v2/logging_config.proto.baseline new file mode 100644 index 000000000..1062a6521 --- /dev/null +++ b/baselines/logging/protos/google/logging/v2/logging_config.proto.baseline @@ -0,0 +1,1156 @@ +// 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.logging.v2; + +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/api/annotations.proto"; + +option cc_enable_arenas = true; +option csharp_namespace = "Google.Cloud.Logging.V2"; +option go_package = "google.golang.org/genproto/googleapis/logging/v2;logging"; +option java_multiple_files = true; +option java_outer_classname = "LoggingConfigProto"; +option java_package = "com.google.logging.v2"; +option php_namespace = "Google\\Cloud\\Logging\\V2"; + +// Service for configuring sinks used to route log entries. +service ConfigServiceV2 { + option (google.api.default_host) = "logging.googleapis.com"; + option (google.api.oauth_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"; + + // Lists buckets (Beta). + rpc ListBuckets(ListBucketsRequest) returns (ListBucketsResponse) { + option (google.api.http) = { + get: "/v2/{parent=*/*/locations/*}/buckets" + additional_bindings { + get: "/v2/{parent=projects/*/locations/*}/buckets" + } + additional_bindings { + get: "/v2/{parent=organizations/*/locations/*}/buckets" + } + additional_bindings { + get: "/v2/{parent=folders/*/locations/*}/buckets" + } + additional_bindings { + get: "/v2/{parent=billingAccounts/*/locations/*}/buckets" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Gets a bucket (Beta). + rpc GetBucket(GetBucketRequest) returns (LogBucket) { + option (google.api.http) = { + get: "/v2/{name=*/*/locations/*/buckets/*}" + additional_bindings { + get: "/v2/{name=projects/*/locations/*/buckets/*}" + } + additional_bindings { + get: "/v2/{name=organizations/*/locations/*/buckets/*}" + } + additional_bindings { + get: "/v2/{name=folders/*/locations/*/buckets/*}" + } + additional_bindings { + get: "/v2/{name=billingAccounts/*/buckets/*}" + } + }; + } + + // Updates a bucket. This method replaces the following fields in the + // existing bucket with values from the new bucket: `retention_period` + // + // If the retention period is decreased and the bucket is locked, + // FAILED_PRECONDITION will be returned. + // + // If the bucket has a LifecycleState of DELETE_REQUESTED, FAILED_PRECONDITION + // will be returned. + // + // A buckets region may not be modified after it is created. + // This method is in Beta. + rpc UpdateBucket(UpdateBucketRequest) returns (LogBucket) { + option (google.api.http) = { + patch: "/v2/{name=*/*/locations/*/buckets/*}" + body: "bucket" + additional_bindings { + patch: "/v2/{name=projects/*/locations/*/buckets/*}" + body: "bucket" + } + additional_bindings { + patch: "/v2/{name=organizations/*/locations/*/buckets/*}" + body: "bucket" + } + additional_bindings { + patch: "/v2/{name=folders/*/locations/*/buckets/*}" + body: "bucket" + } + additional_bindings { + patch: "/v2/{name=billingAccounts/*/locations/*/buckets/*}" + body: "bucket" + } + }; + } + + // Lists sinks. + rpc ListSinks(ListSinksRequest) returns (ListSinksResponse) { + option (google.api.http) = { + get: "/v2/{parent=*/*}/sinks" + additional_bindings { + get: "/v2/{parent=projects/*}/sinks" + } + additional_bindings { + get: "/v2/{parent=organizations/*}/sinks" + } + additional_bindings { + get: "/v2/{parent=folders/*}/sinks" + } + additional_bindings { + get: "/v2/{parent=billingAccounts/*}/sinks" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Gets a sink. + rpc GetSink(GetSinkRequest) returns (LogSink) { + option (google.api.http) = { + get: "/v2/{sink_name=*/*/sinks/*}" + additional_bindings { + get: "/v2/{sink_name=projects/*/sinks/*}" + } + additional_bindings { + get: "/v2/{sink_name=organizations/*/sinks/*}" + } + additional_bindings { + get: "/v2/{sink_name=folders/*/sinks/*}" + } + additional_bindings { + get: "/v2/{sink_name=billingAccounts/*/sinks/*}" + } + }; + option (google.api.method_signature) = "sink_name"; + } + + // Creates a sink that exports specified log entries to a destination. The + // export of newly-ingested log entries begins immediately, unless the sink's + // `writer_identity` is not permitted to write to the destination. A sink can + // export log entries only from the resource owning the sink. + rpc CreateSink(CreateSinkRequest) returns (LogSink) { + option (google.api.http) = { + post: "/v2/{parent=*/*}/sinks" + body: "sink" + additional_bindings { + post: "/v2/{parent=projects/*}/sinks" + body: "sink" + } + additional_bindings { + post: "/v2/{parent=organizations/*}/sinks" + body: "sink" + } + additional_bindings { + post: "/v2/{parent=folders/*}/sinks" + body: "sink" + } + additional_bindings { + post: "/v2/{parent=billingAccounts/*}/sinks" + body: "sink" + } + }; + option (google.api.method_signature) = "parent,sink"; + } + + // Updates a sink. This method replaces the following fields in the existing + // sink with values from the new sink: `destination`, and `filter`. + // + // The updated sink might also have a new `writer_identity`; see the + // `unique_writer_identity` field. + rpc UpdateSink(UpdateSinkRequest) returns (LogSink) { + option (google.api.http) = { + put: "/v2/{sink_name=*/*/sinks/*}" + body: "sink" + additional_bindings { + put: "/v2/{sink_name=projects/*/sinks/*}" + body: "sink" + } + additional_bindings { + put: "/v2/{sink_name=organizations/*/sinks/*}" + body: "sink" + } + additional_bindings { + put: "/v2/{sink_name=folders/*/sinks/*}" + body: "sink" + } + additional_bindings { + put: "/v2/{sink_name=billingAccounts/*/sinks/*}" + body: "sink" + } + additional_bindings { + patch: "/v2/{sink_name=projects/*/sinks/*}" + body: "sink" + } + additional_bindings { + patch: "/v2/{sink_name=organizations/*/sinks/*}" + body: "sink" + } + additional_bindings { + patch: "/v2/{sink_name=folders/*/sinks/*}" + body: "sink" + } + additional_bindings { + patch: "/v2/{sink_name=billingAccounts/*/sinks/*}" + body: "sink" + } + }; + option (google.api.method_signature) = "sink_name,sink,update_mask"; + option (google.api.method_signature) = "sink_name,sink"; + } + + // Deletes a sink. If the sink has a unique `writer_identity`, then that + // service account is also deleted. + rpc DeleteSink(DeleteSinkRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2/{sink_name=*/*/sinks/*}" + additional_bindings { + delete: "/v2/{sink_name=projects/*/sinks/*}" + } + additional_bindings { + delete: "/v2/{sink_name=organizations/*/sinks/*}" + } + additional_bindings { + delete: "/v2/{sink_name=folders/*/sinks/*}" + } + additional_bindings { + delete: "/v2/{sink_name=billingAccounts/*/sinks/*}" + } + }; + option (google.api.method_signature) = "sink_name"; + } + + // Lists all the exclusions in a parent resource. + rpc ListExclusions(ListExclusionsRequest) returns (ListExclusionsResponse) { + option (google.api.http) = { + get: "/v2/{parent=*/*}/exclusions" + additional_bindings { + get: "/v2/{parent=projects/*}/exclusions" + } + additional_bindings { + get: "/v2/{parent=organizations/*}/exclusions" + } + additional_bindings { + get: "/v2/{parent=folders/*}/exclusions" + } + additional_bindings { + get: "/v2/{parent=billingAccounts/*}/exclusions" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Gets the description of an exclusion. + rpc GetExclusion(GetExclusionRequest) returns (LogExclusion) { + option (google.api.http) = { + get: "/v2/{name=*/*/exclusions/*}" + additional_bindings { + get: "/v2/{name=projects/*/exclusions/*}" + } + additional_bindings { + get: "/v2/{name=organizations/*/exclusions/*}" + } + additional_bindings { + get: "/v2/{name=folders/*/exclusions/*}" + } + additional_bindings { + get: "/v2/{name=billingAccounts/*/exclusions/*}" + } + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new exclusion in a specified parent resource. + // Only log entries belonging to that resource can be excluded. + // You can have up to 10 exclusions in a resource. + rpc CreateExclusion(CreateExclusionRequest) returns (LogExclusion) { + option (google.api.http) = { + post: "/v2/{parent=*/*}/exclusions" + body: "exclusion" + additional_bindings { + post: "/v2/{parent=projects/*}/exclusions" + body: "exclusion" + } + additional_bindings { + post: "/v2/{parent=organizations/*}/exclusions" + body: "exclusion" + } + additional_bindings { + post: "/v2/{parent=folders/*}/exclusions" + body: "exclusion" + } + additional_bindings { + post: "/v2/{parent=billingAccounts/*}/exclusions" + body: "exclusion" + } + }; + option (google.api.method_signature) = "parent,exclusion"; + } + + // Changes one or more properties of an existing exclusion. + rpc UpdateExclusion(UpdateExclusionRequest) returns (LogExclusion) { + option (google.api.http) = { + patch: "/v2/{name=*/*/exclusions/*}" + body: "exclusion" + additional_bindings { + patch: "/v2/{name=projects/*/exclusions/*}" + body: "exclusion" + } + additional_bindings { + patch: "/v2/{name=organizations/*/exclusions/*}" + body: "exclusion" + } + additional_bindings { + patch: "/v2/{name=folders/*/exclusions/*}" + body: "exclusion" + } + additional_bindings { + patch: "/v2/{name=billingAccounts/*/exclusions/*}" + body: "exclusion" + } + }; + option (google.api.method_signature) = "name,exclusion,update_mask"; + } + + // Deletes an exclusion. + rpc DeleteExclusion(DeleteExclusionRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2/{name=*/*/exclusions/*}" + additional_bindings { + delete: "/v2/{name=projects/*/exclusions/*}" + } + additional_bindings { + delete: "/v2/{name=organizations/*/exclusions/*}" + } + additional_bindings { + delete: "/v2/{name=folders/*/exclusions/*}" + } + additional_bindings { + delete: "/v2/{name=billingAccounts/*/exclusions/*}" + } + }; + option (google.api.method_signature) = "name"; + } + + // Gets the Logs Router CMEK settings for the given resource. + // + // Note: CMEK for the Logs Router can currently only be configured for GCP + // organizations. Once configured, it applies to all projects and folders in + // the GCP organization. + // + // See [Enabling CMEK for Logs + // Router](/logging/docs/routing/managed-encryption) for more information. + rpc GetCmekSettings(GetCmekSettingsRequest) returns (CmekSettings) { + option (google.api.http) = { + get: "/v2/{name=*/*}/cmekSettings" + additional_bindings { + get: "/v2/{name=organizations/*}/cmekSettings" + } + }; + } + + // Updates the Logs Router CMEK settings for the given resource. + // + // Note: CMEK for the Logs Router can currently only be configured for GCP + // organizations. Once configured, it applies to all projects and folders in + // the GCP organization. + // + // [UpdateCmekSettings][google.logging.v2.ConfigServiceV2.UpdateCmekSettings] + // will fail if 1) `kms_key_name` is invalid, or 2) the associated service + // account does not have the required + // `roles/cloudkms.cryptoKeyEncrypterDecrypter` role assigned for the key, or + // 3) access to the key is disabled. + // + // See [Enabling CMEK for Logs + // Router](/logging/docs/routing/managed-encryption) for more information. + rpc UpdateCmekSettings(UpdateCmekSettingsRequest) returns (CmekSettings) { + option (google.api.http) = { + patch: "/v2/{name=*/*}/cmekSettings" + body: "cmek_settings" + additional_bindings { + patch: "/v2/{name=organizations/*}/cmekSettings" + body: "cmek_settings" + } + }; + } +} + +// Describes a repository of logs (Beta). +message LogBucket { + option (google.api.resource) = { + type: "logging.googleapis.com/LogBucket" + pattern: "projects/{project}/locations/{location}/buckets/{bucket}" + pattern: "organizations/{organization}/locations/{location}/buckets/{bucket}" + pattern: "folders/{folder}/locations/{location}/buckets/{bucket}" + pattern: "billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}" + }; + + // The resource name of the bucket. + // For example: + // "projects/my-project-id/locations/my-location/buckets/my-bucket-id The + // supported locations are: + // "global" + // "us-central1" + // + // For the location of `global` it is unspecified where logs are actually + // stored. + // Once a bucket has been created, the location can not be changed. + string name = 1; + + // Describes this bucket. + string description = 3; + + // Output only. The creation timestamp of the bucket. This is not set for any of the + // default buckets. + google.protobuf.Timestamp create_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The last update timestamp of the bucket. + google.protobuf.Timestamp update_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Logs will be retained by default for this amount of time, after which they + // will automatically be deleted. The minimum retention period is 1 day. + // If this value is set to zero at bucket creation time, the default time of + // 30 days will be used. + int32 retention_days = 11; + + // Output only. The bucket lifecycle state. + LifecycleState lifecycle_state = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Describes a sink used to export log entries to one of the following +// destinations in any project: a Cloud Storage bucket, a BigQuery dataset, or a +// Cloud Pub/Sub topic. A logs filter controls which log entries are exported. +// The sink must be created within a project, organization, billing account, or +// folder. +message LogSink { + option (google.api.resource) = { + type: "logging.googleapis.com/LogSink" + pattern: "projects/{project}/sinks/{sink}" + pattern: "organizations/{organization}/sinks/{sink}" + pattern: "folders/{folder}/sinks/{sink}" + pattern: "billingAccounts/{billing_account}/sinks/{sink}" + }; + + // Available log entry formats. Log entries can be written to + // Logging in either format and can be exported in either format. + // Version 2 is the preferred format. + enum VersionFormat { + // An unspecified format version that will default to V2. + VERSION_FORMAT_UNSPECIFIED = 0; + + // `LogEntry` version 2 format. + V2 = 1; + + // `LogEntry` version 1 format. + V1 = 2; + } + + // Required. The client-assigned sink identifier, unique within the project. Example: + // `"my-syslog-errors-to-pubsub"`. Sink identifiers are limited to 100 + // characters and can include only the following characters: upper and + // lower-case alphanumeric characters, underscores, hyphens, and periods. + // First character has to be alphanumeric. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The export destination: + // + // "storage.googleapis.com/[GCS_BUCKET]" + // "bigquery.googleapis.com/projects/[PROJECT_ID]/datasets/[DATASET]" + // "pubsub.googleapis.com/projects/[PROJECT_ID]/topics/[TOPIC_ID]" + // + // The sink's `writer_identity`, set when the sink is created, must + // have permission to write to the destination or else the log + // entries are not exported. For more information, see + // [Exporting Logs with Sinks](/logging/docs/api/tasks/exporting-logs). + string destination = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "*" + } + ]; + + // Optional. An [advanced logs filter](/logging/docs/view/advanced-queries). The only + // exported log entries are those that are in the resource owning the sink and + // that match the filter. For example: + // + // logName="projects/[PROJECT_ID]/logs/[LOG_ID]" AND severity>=ERROR + string filter = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A description of this sink. + // The maximum length of the description is 8000 characters. + string description = 18 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If set to True, then this sink is disabled and it does not + // export any log entries. + bool disabled = 19 [(google.api.field_behavior) = OPTIONAL]; + + // Deprecated. The log entry format to use for this sink's exported log + // entries. The v2 format is used by default and cannot be changed. + VersionFormat output_version_format = 6 [deprecated = true]; + + // Output only. An IAM identity–a service account or group—under which Logging + // writes the exported log entries to the sink's destination. This field is + // set by [sinks.create][google.logging.v2.ConfigServiceV2.CreateSink] and + // [sinks.update][google.logging.v2.ConfigServiceV2.UpdateSink] based on the + // value of `unique_writer_identity` in those methods. + // + // Until you grant this identity write-access to the destination, log entry + // exports from this sink will fail. For more information, + // see [Granting Access for a + // Resource](/iam/docs/granting-roles-to-service-accounts#granting_access_to_a_service_account_for_a_resource). + // Consult the destination service's documentation to determine the + // appropriate IAM roles to assign to the identity. + string writer_identity = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. This field applies only to sinks owned by organizations and + // folders. If the field is false, the default, only the logs owned by the + // sink's parent resource are available for export. If the field is true, then + // logs from all the projects, folders, and billing accounts contained in the + // sink's parent resource are also available for export. Whether a particular + // log entry from the children is exported depends on the sink's filter + // expression. For example, if this field is true, then the filter + // `resource.type=gce_instance` would export all Compute Engine VM instance + // log entries from all projects in the sink's parent. To only export entries + // from certain child projects, filter on the project part of the log name: + // + // logName:("projects/test-project1/" OR "projects/test-project2/") AND + // resource.type=gce_instance + bool include_children = 9 [(google.api.field_behavior) = OPTIONAL]; + + // Destination dependent options. + oneof options { + // Optional. Options that affect sinks exporting data to BigQuery. + BigQueryOptions bigquery_options = 12 [(google.api.field_behavior) = OPTIONAL]; + } + + // Output only. The creation timestamp of the sink. + // + // This field may not be present for older sinks. + google.protobuf.Timestamp create_time = 13 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The last update timestamp of the sink. + // + // This field may not be present for older sinks. + google.protobuf.Timestamp update_time = 14 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Options that change functionality of a sink exporting data to BigQuery. +message BigQueryOptions { + // Optional. Whether to use [BigQuery's partition + // tables](/bigquery/docs/partitioned-tables). By default, Logging + // creates dated tables based on the log entries' timestamps, e.g. + // syslog_20170523. With partitioned tables the date suffix is no longer + // present and [special query + // syntax](/bigquery/docs/querying-partitioned-tables) has to be used instead. + // In both cases, tables are sharded based on UTC timezone. + bool use_partitioned_tables = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. True if new timestamp column based partitioning is in use, + // false if legacy ingestion-time partitioning is in use. + // All new sinks will have this field set true and will use timestamp column + // based partitioning. If use_partitioned_tables is false, this value has no + // meaning and will be false. Legacy sinks using partitioned tables will have + // this field set to false. + bool uses_timestamp_column_partitioning = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// LogBucket lifecycle states (Beta). +enum LifecycleState { + // Unspecified state. This is only used/useful for distinguishing + // unset values. + LIFECYCLE_STATE_UNSPECIFIED = 0; + + // The normal and active state. + ACTIVE = 1; + + // The bucket has been marked for deletion by the user. + DELETE_REQUESTED = 2; +} + +// The parameters to `ListBuckets` (Beta). +message ListBucketsRequest { + // Required. The parent resource whose buckets are to be listed: + // + // "projects/[PROJECT_ID]/locations/[LOCATION_ID]" + // "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]" + // "folders/[FOLDER_ID]/locations/[LOCATION_ID]" + // + // Note: The locations portion of the resource must be specified, but + // supplying the character `-` in place of [LOCATION_ID] will return all + // buckets. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "logging.googleapis.com/LogBucket" + }]; + + // Optional. If present, then retrieve the next batch of results from the + // preceding call to this method. `pageToken` must be the value of + // `nextPageToken` from the previous response. The values of other method + // parameters should be identical to those in the previous call. + string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maximum number of results to return from this request. + // Non-positive values are ignored. The presence of `nextPageToken` in the + // response indicates that more results might be available. + int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response from ListBuckets (Beta). +message ListBucketsResponse { + // A list of buckets. + repeated LogBucket buckets = 1; + + // If there might be more results than appear in this response, then + // `nextPageToken` is included. To get the next set of results, call the same + // method again using the value of `nextPageToken` as `pageToken`. + string next_page_token = 2; +} + +// The parameters to `UpdateBucket` (Beta). +message UpdateBucketRequest { + // Required. The full resource name of the bucket to update. + // + // "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + // "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + // "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + // + // Example: + // `"projects/my-project-id/locations/my-location/buckets/my-bucket-id"`. Also + // requires permission "resourcemanager.projects.updateLiens" to set the + // locked property + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "logging.googleapis.com/LogBucket" + } + ]; + + // Required. The updated bucket. + LogBucket bucket = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. Field mask that specifies the fields in `bucket` that need an update. A + // bucket field will be overwritten if, and only if, it is in the update + // mask. `name` and output only fields cannot be updated. + // + // For a detailed `FieldMask` definition, see + // https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask + // + // Example: `updateMask=retention_days`. + google.protobuf.FieldMask update_mask = 4 [(google.api.field_behavior) = REQUIRED]; +} + +// The parameters to `GetBucket` (Beta). +message GetBucketRequest { + // Required. The resource name of the bucket: + // + // "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + // "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + // "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + // + // Example: + // `"projects/my-project-id/locations/my-location/buckets/my-bucket-id"`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "logging.googleapis.com/LogBucket" + } + ]; +} + +// The parameters to `ListSinks`. +message ListSinksRequest { + // Required. The parent resource whose sinks are to be listed: + // + // "projects/[PROJECT_ID]" + // "organizations/[ORGANIZATION_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]" + // "folders/[FOLDER_ID]" + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "logging.googleapis.com/LogSink" + } + ]; + + // Optional. If present, then retrieve the next batch of results from the + // preceding call to this method. `pageToken` must be the value of + // `nextPageToken` from the previous response. The values of other method + // parameters should be identical to those in the previous call. + string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maximum number of results to return from this request. + // Non-positive values are ignored. The presence of `nextPageToken` in the + // response indicates that more results might be available. + int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Result returned from `ListSinks`. +message ListSinksResponse { + // A list of sinks. + repeated LogSink sinks = 1; + + // If there might be more results than appear in this response, then + // `nextPageToken` is included. To get the next set of results, call the same + // method again using the value of `nextPageToken` as `pageToken`. + string next_page_token = 2; +} + +// The parameters to `GetSink`. +message GetSinkRequest { + // Required. The resource name of the sink: + // + // "projects/[PROJECT_ID]/sinks/[SINK_ID]" + // "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" + // "folders/[FOLDER_ID]/sinks/[SINK_ID]" + // + // Example: `"projects/my-project-id/sinks/my-sink-id"`. + string sink_name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "logging.googleapis.com/LogSink" + } + ]; +} + +// The parameters to `CreateSink`. +message CreateSinkRequest { + // Required. The resource in which to create the sink: + // + // "projects/[PROJECT_ID]" + // "organizations/[ORGANIZATION_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]" + // "folders/[FOLDER_ID]" + // + // Examples: `"projects/my-logging-project"`, `"organizations/123456789"`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "logging.googleapis.com/LogSink" + } + ]; + + // Required. The new sink, whose `name` parameter is a sink identifier that + // is not already in use. + LogSink sink = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Determines the kind of IAM identity returned as `writer_identity` + // in the new sink. If this value is omitted or set to false, and if the + // sink's parent is a project, then the value returned as `writer_identity` is + // the same group or service account used by Logging before the addition of + // writer identities to this API. The sink's destination must be in the same + // project as the sink itself. + // + // If this field is set to true, or if the sink is owned by a non-project + // resource such as an organization, then the value of `writer_identity` will + // be a unique service account used only for exports from the new sink. For + // more information, see `writer_identity` in [LogSink][google.logging.v2.LogSink]. + bool unique_writer_identity = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// The parameters to `UpdateSink`. +message UpdateSinkRequest { + // Required. The full resource name of the sink to update, including the parent + // resource and the sink identifier: + // + // "projects/[PROJECT_ID]/sinks/[SINK_ID]" + // "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" + // "folders/[FOLDER_ID]/sinks/[SINK_ID]" + // + // Example: `"projects/my-project-id/sinks/my-sink-id"`. + string sink_name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "logging.googleapis.com/LogSink" + } + ]; + + // Required. The updated sink, whose name is the same identifier that appears as part + // of `sink_name`. + LogSink sink = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. See [sinks.create][google.logging.v2.ConfigServiceV2.CreateSink] + // for a description of this field. When updating a sink, the effect of this + // field on the value of `writer_identity` in the updated sink depends on both + // the old and new values of this field: + // + // + If the old and new values of this field are both false or both true, + // then there is no change to the sink's `writer_identity`. + // + If the old value is false and the new value is true, then + // `writer_identity` is changed to a unique service account. + // + It is an error if the old value is true and the new value is + // set to false or defaulted to false. + bool unique_writer_identity = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Field mask that specifies the fields in `sink` that need + // an update. A sink field will be overwritten if, and only if, it is + // in the update mask. `name` and output only fields cannot be updated. + // + // An empty updateMask is temporarily treated as using the following mask + // for backwards compatibility purposes: + // destination,filter,includeChildren + // At some point in the future, behavior will be removed and specifying an + // empty updateMask will be an error. + // + // For a detailed `FieldMask` definition, see + // https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask + // + // Example: `updateMask=filter`. + google.protobuf.FieldMask update_mask = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// The parameters to `DeleteSink`. +message DeleteSinkRequest { + // Required. The full resource name of the sink to delete, including the parent + // resource and the sink identifier: + // + // "projects/[PROJECT_ID]/sinks/[SINK_ID]" + // "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" + // "folders/[FOLDER_ID]/sinks/[SINK_ID]" + // + // Example: `"projects/my-project-id/sinks/my-sink-id"`. + string sink_name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "logging.googleapis.com/LogSink" + } + ]; +} + +// Specifies a set of log entries that are not to be stored in +// Logging. If your GCP resource receives a large volume of logs, you can +// use exclusions to reduce your chargeable logs. Exclusions are +// processed after log sinks, so you can export log entries before they are +// excluded. Note that organization-level and folder-level exclusions don't +// apply to child resources, and that you can't exclude audit log entries. +message LogExclusion { + option (google.api.resource) = { + type: "logging.googleapis.com/LogExclusion" + pattern: "projects/{project}/exclusions/{exclusion}" + pattern: "organizations/{organization}/exclusions/{exclusion}" + pattern: "folders/{folder}/exclusions/{exclusion}" + pattern: "billingAccounts/{billing_account}/exclusions/{exclusion}" + }; + + // Required. A client-assigned identifier, such as `"load-balancer-exclusion"`. + // Identifiers are limited to 100 characters and can include only letters, + // digits, underscores, hyphens, and periods. First character has to be + // alphanumeric. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. A description of this exclusion. + string description = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Required. An [advanced logs filter](/logging/docs/view/advanced-queries) + // that matches the log entries to be excluded. By using the + // [sample function](/logging/docs/view/advanced-queries#sample), + // you can exclude less than 100% of the matching log entries. + // For example, the following query matches 99% of low-severity log + // entries from Google Cloud Storage buckets: + // + // `"resource.type=gcs_bucket severity=ERROR" + // + // The maximum length of the filter is 20000 characters. + string filter = 3 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The metric descriptor associated with the logs-based metric. + // If unspecified, it uses a default metric descriptor with a DELTA metric + // kind, INT64 value type, with no labels and a unit of "1". Such a metric + // counts the number of log entries matching the `filter` expression. + // + // The `name`, `type`, and `description` fields in the `metric_descriptor` + // are output only, and is constructed using the `name` and `description` + // field in the LogMetric. + // + // To create a logs-based metric that records a distribution of log values, a + // DELTA metric kind with a DISTRIBUTION value type must be used along with + // a `value_extractor` expression in the LogMetric. + // + // Each label in the metric descriptor must have a matching label + // name as the key and an extractor expression as the value in the + // `label_extractors` map. + // + // The `metric_kind` and `value_type` fields in the `metric_descriptor` cannot + // be updated once initially configured. New labels can be added in the + // `metric_descriptor`, but existing labels cannot be modified except for + // their description. + google.api.MetricDescriptor metric_descriptor = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A `value_extractor` is required when using a distribution + // logs-based metric to extract the values to record from a log entry. + // Two functions are supported for value extraction: `EXTRACT(field)` or + // `REGEXP_EXTRACT(field, regex)`. The argument are: + // 1. field: The name of the log entry field from which the value is to be + // extracted. + // 2. regex: A regular expression using the Google RE2 syntax + // (https://github.com/google/re2/wiki/Syntax) with a single capture + // group to extract data from the specified log entry field. The value + // of the field is converted to a string before applying the regex. + // It is an error to specify a regex that does not include exactly one + // capture group. + // + // The result of the extraction must be convertible to a double type, as the + // distribution always records double values. If either the extraction or + // the conversion to double fails, then those values are not recorded in the + // distribution. + // + // Example: `REGEXP_EXTRACT(jsonPayload.request, ".*quantity=(\d+).*")` + string value_extractor = 6 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A map from a label key string to an extractor expression which is + // used to extract data from a log entry field and assign as the label value. + // Each label key specified in the LabelDescriptor must have an associated + // extractor expression in this map. The syntax of the extractor expression + // is the same as for the `value_extractor` field. + // + // The extracted value is converted to the type defined in the label + // descriptor. If the either the extraction or the type conversion fails, + // the label will have a default value. The default value for a string + // label is an empty string, for an integer label its 0, and for a boolean + // label its `false`. + // + // Note that there are upper bounds on the maximum number of labels and the + // number of active time series that are allowed in a project. + map label_extractors = 7 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The `bucket_options` are required when the logs-based metric is + // using a DISTRIBUTION value type and it describes the bucket boundaries + // used to create a histogram of the extracted values. + google.api.Distribution.BucketOptions bucket_options = 8 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The creation timestamp of the metric. + // + // This field may not be present for older metrics. + google.protobuf.Timestamp create_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The last update timestamp of the metric. + // + // This field may not be present for older metrics. + google.protobuf.Timestamp update_time = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Deprecated. The API version that created or updated this metric. + // The v2 format is used by default and cannot be changed. + ApiVersion version = 4 [deprecated = true]; +} + +// The parameters to ListLogMetrics. +message ListLogMetricsRequest { + // Required. The name of the project containing the metrics: + // + // "projects/[PROJECT_ID]" + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Optional. If present, then retrieve the next batch of results from the + // preceding call to this method. `pageToken` must be the value of + // `nextPageToken` from the previous response. The values of other method + // parameters should be identical to those in the previous call. + string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maximum number of results to return from this request. + // Non-positive values are ignored. The presence of `nextPageToken` in the + // response indicates that more results might be available. + int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Result returned from ListLogMetrics. +message ListLogMetricsResponse { + // A list of logs-based metrics. + repeated LogMetric metrics = 1; + + // If there might be more results than appear in this response, then + // `nextPageToken` is included. To get the next set of results, call this + // method again using the value of `nextPageToken` as `pageToken`. + string next_page_token = 2; +} + +// The parameters to GetLogMetric. +message GetLogMetricRequest { + // Required. The resource name of the desired metric: + // + // "projects/[PROJECT_ID]/metrics/[METRIC_ID]" + string metric_name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "logging.googleapis.com/LogMetric" + } + ]; +} + +// The parameters to CreateLogMetric. +message CreateLogMetricRequest { + // Required. The resource name of the project in which to create the metric: + // + // "projects/[PROJECT_ID]" + // + // The new metric must be provided in the request. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "logging.googleapis.com/LogMetric" + } + ]; + + // Required. The new logs-based metric, which must not have an identifier that + // already exists. + LogMetric metric = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The parameters to UpdateLogMetric. +message UpdateLogMetricRequest { + // Required. The resource name of the metric to update: + // + // "projects/[PROJECT_ID]/metrics/[METRIC_ID]" + // + // The updated metric must be provided in the request and it's + // `name` field must be the same as `[METRIC_ID]` If the metric + // does not exist in `[PROJECT_ID]`, then a new metric is created. + string metric_name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "logging.googleapis.com/LogMetric" + } + ]; + + // Required. The updated metric. + LogMetric metric = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The parameters to DeleteLogMetric. +message DeleteLogMetricRequest { + // Required. The resource name of the metric to delete: + // + // "projects/[PROJECT_ID]/metrics/[METRIC_ID]" + string metric_name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "logging.googleapis.com/LogMetric" + } + ]; +} diff --git a/baselines/logging/src/index.ts.baseline b/baselines/logging/src/index.ts.baseline new file mode 100644 index 000000000..327c2f6e6 --- /dev/null +++ b/baselines/logging/src/index.ts.baseline @@ -0,0 +1,28 @@ +// Copyright 2020 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v2 from './v2'; +const ConfigServiceV2Client = v2.ConfigServiceV2Client; +const LoggingServiceV2Client = v2.LoggingServiceV2Client; +const MetricsServiceV2Client = v2.MetricsServiceV2Client; +export {v2, ConfigServiceV2Client, LoggingServiceV2Client, MetricsServiceV2Client}; +// For compatibility with JavaScript libraries we need to provide this default export: +// tslint:disable-next-line no-default-export +export default {v2, ConfigServiceV2Client, LoggingServiceV2Client, MetricsServiceV2Client}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/baselines/logging/src/v2/config_service_v2_client.ts.baseline b/baselines/logging/src/v2/config_service_v2_client.ts.baseline new file mode 100644 index 000000000..736f83900 --- /dev/null +++ b/baselines/logging/src/v2/config_service_v2_client.ts.baseline @@ -0,0 +1,2576 @@ +// Copyright 2020 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as gax from 'google-gax'; +import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, PaginationResponse} from 'google-gax'; +import * as path from 'path'; + +import { Transform } from 'stream'; +import * as protosTypes from '../../protos/protos'; +import * as gapicConfig from './config_service_v2_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for configuring sinks used to route log entries. + * @class + * @memberof v2 + */ +export class ConfigServiceV2Client { + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; + private _innerApiCalls: {[name: string]: Function}; + private _pathTemplates: {[name: string]: gax.PathTemplate}; + private _terminated = false; + private _opts: ClientOptions; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + configServiceV2Stub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ConfigServiceV2Client. + * + * @param {object} [options] - The configuration object. See the subsequent + * parameters for more details. + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + */ + + constructor(opts?: ClientOptions) { + // Ensure that options include the service address and port. + const staticMembers = this.constructor as typeof ConfigServiceV2Client; + const servicePath = opts && opts.servicePath ? + opts.servicePath : + ((opts && opts.apiEndpoint) ? opts.apiEndpoint : + staticMembers.servicePath); + const port = opts && opts.port ? opts.port : staticMembers.port; + + if (!opts) { + opts = {servicePath, port}; + } + opts.servicePath = opts.servicePath || servicePath; + opts.port = opts.port || port; + opts.clientConfig = opts.clientConfig || {}; + + const isBrowser = (typeof window !== 'undefined'); + if (isBrowser){ + opts.fallback = true; + } + // If we are in browser, we are already using fallback because of the + // "browser" field in package.json. + // But if we were explicitly requested to use fallback, let's do it now. + this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options + // sent to the client. + opts.scopes = (this.constructor as typeof ConfigServiceV2Client).scopes; + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + + const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); + this._protos = this._gaxGrpc.loadProto( + opts.fallback ? + require("../../protos/protos.json") : + nodejsProtoPath + ); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this._pathTemplates = { + billingAccountCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/cmekSettings' + ), + billingAccountExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/exclusions/{exclusion}' + ), + billingAccountLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}' + ), + billingAccountLogPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/logs/{log}' + ), + billingAccountSinkPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/sinks/{sink}' + ), + folderCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/cmekSettings' + ), + folderExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/exclusions/{exclusion}' + ), + folderLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/locations/{location}/buckets/{bucket}' + ), + folderLogPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/logs/{log}' + ), + folderSinkPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/sinks/{sink}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + logMetricPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/metrics/{metric}' + ), + organizationCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/cmekSettings' + ), + organizationExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/exclusions/{exclusion}' + ), + organizationLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/buckets/{bucket}' + ), + organizationLogPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/logs/{log}' + ), + organizationSinkPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/sinks/{sink}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + projectCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/cmekSettings' + ), + projectExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/exclusions/{exclusion}' + ), + projectLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/buckets/{bucket}' + ), + projectLogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/logs/{log}' + ), + projectSinkPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/sinks/{sink}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this._descriptors.page = { + listBuckets: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'buckets'), + listSinks: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'sinks'), + listExclusions: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'exclusions') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.logging.v2.ConfigServiceV2', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this._innerApiCalls = {}; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.configServiceV2Stub) { + return this.configServiceV2Stub; + } + + // Put together the "service stub" for + // google.logging.v2.ConfigServiceV2. + this.configServiceV2Stub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.logging.v2.ConfigServiceV2') : + // tslint:disable-next-line no-any + (this._protos as any).google.logging.v2.ConfigServiceV2, + this._opts) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const configServiceV2StubMethods = + ['listBuckets', 'getBucket', 'updateBucket', 'listSinks', 'getSink', 'createSink', 'updateSink', 'deleteSink', 'listExclusions', 'getExclusion', 'createExclusion', 'updateExclusion', 'deleteExclusion', 'getCmekSettings', 'updateCmekSettings']; + + for (const methodName of configServiceV2StubMethods) { + const innerCallPromise = this.configServiceV2Stub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + return stub[methodName].apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const apiCall = this._gaxModule.createApiCall( + innerCallPromise, + this._defaults[methodName], + this._descriptors.page[methodName] || + this._descriptors.stream[methodName] || + this._descriptors.longrunning[methodName] + ); + + this._innerApiCalls[methodName] = ( + argument: {}, + callOptions?: CallOptions, + callback?: APICallback + ) => { + return apiCall(argument, callOptions, callback); + }; + } + + return this.configServiceV2Stub; + } + + /** + * The DNS address for this API service. + */ + static get servicePath() { + return 'logging.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'logging.googleapis.com'; + } + + /** + * The port for this API service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + */ + static get scopes() { + return [ + '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' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @param {function(Error, string)} callback - the callback to + * be called with the current project Id. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + getBucket( + request: protosTypes.google.logging.v2.IGetBucketRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.logging.v2.ILogBucket, + protosTypes.google.logging.v2.IGetBucketRequest|undefined, {}|undefined + ]>; + getBucket( + request: protosTypes.google.logging.v2.IGetBucketRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.logging.v2.ILogBucket, + protosTypes.google.logging.v2.IGetBucketRequest|undefined, + {}|undefined>): void; +/** + * Gets a bucket (Beta). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the bucket: + * + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * + * Example: + * `"projects/my-project-id/locations/my-location/buckets/my-bucket-id"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LogBucket]{@link google.logging.v2.LogBucket}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getBucket( + request: protosTypes.google.logging.v2.IGetBucketRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.logging.v2.ILogBucket, + protosTypes.google.logging.v2.IGetBucketRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.logging.v2.ILogBucket, + protosTypes.google.logging.v2.IGetBucketRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.logging.v2.ILogBucket, + protosTypes.google.logging.v2.IGetBucketRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this._innerApiCalls.getBucket(request, options, callback); + } + updateBucket( + request: protosTypes.google.logging.v2.IUpdateBucketRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.logging.v2.ILogBucket, + protosTypes.google.logging.v2.IUpdateBucketRequest|undefined, {}|undefined + ]>; + updateBucket( + request: protosTypes.google.logging.v2.IUpdateBucketRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.logging.v2.ILogBucket, + protosTypes.google.logging.v2.IUpdateBucketRequest|undefined, + {}|undefined>): void; +/** + * Updates a bucket. This method replaces the following fields in the + * existing bucket with values from the new bucket: `retention_period` + * + * If the retention period is decreased and the bucket is locked, + * FAILED_PRECONDITION will be returned. + * + * If the bucket has a LifecycleState of DELETE_REQUESTED, FAILED_PRECONDITION + * will be returned. + * + * A buckets region may not be modified after it is created. + * This method is in Beta. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full resource name of the bucket to update. + * + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * + * Example: + * `"projects/my-project-id/locations/my-location/buckets/my-bucket-id"`. Also + * requires permission "resourcemanager.projects.updateLiens" to set the + * locked property + * @param {google.logging.v2.LogBucket} request.bucket + * Required. The updated bucket. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Field mask that specifies the fields in `bucket` that need an update. A + * bucket field will be overwritten if, and only if, it is in the update + * mask. `name` and output only fields cannot be updated. + * + * For a detailed `FieldMask` definition, see + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask + * + * Example: `updateMask=retention_days`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LogBucket]{@link google.logging.v2.LogBucket}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + updateBucket( + request: protosTypes.google.logging.v2.IUpdateBucketRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.logging.v2.ILogBucket, + protosTypes.google.logging.v2.IUpdateBucketRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.logging.v2.ILogBucket, + protosTypes.google.logging.v2.IUpdateBucketRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.logging.v2.ILogBucket, + protosTypes.google.logging.v2.IUpdateBucketRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this._innerApiCalls.updateBucket(request, options, callback); + } + getSink( + request: protosTypes.google.logging.v2.IGetSinkRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.logging.v2.ILogSink, + protosTypes.google.logging.v2.IGetSinkRequest|undefined, {}|undefined + ]>; + getSink( + request: protosTypes.google.logging.v2.IGetSinkRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.logging.v2.ILogSink, + protosTypes.google.logging.v2.IGetSinkRequest|undefined, + {}|undefined>): void; +/** + * Gets a sink. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.sinkName + * Required. The resource name of the sink: + * + * "projects/[PROJECT_ID]/sinks/[SINK_ID]" + * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" + * "folders/[FOLDER_ID]/sinks/[SINK_ID]" + * + * Example: `"projects/my-project-id/sinks/my-sink-id"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LogSink]{@link google.logging.v2.LogSink}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getSink( + request: protosTypes.google.logging.v2.IGetSinkRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.logging.v2.ILogSink, + protosTypes.google.logging.v2.IGetSinkRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.logging.v2.ILogSink, + protosTypes.google.logging.v2.IGetSinkRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.logging.v2.ILogSink, + protosTypes.google.logging.v2.IGetSinkRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'sink_name': request.sinkName || '', + }); + this.initialize(); + return this._innerApiCalls.getSink(request, options, callback); + } + createSink( + request: protosTypes.google.logging.v2.ICreateSinkRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.logging.v2.ILogSink, + protosTypes.google.logging.v2.ICreateSinkRequest|undefined, {}|undefined + ]>; + createSink( + request: protosTypes.google.logging.v2.ICreateSinkRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.logging.v2.ILogSink, + protosTypes.google.logging.v2.ICreateSinkRequest|undefined, + {}|undefined>): void; +/** + * Creates a sink that exports specified log entries to a destination. The + * export of newly-ingested log entries begins immediately, unless the sink's + * `writer_identity` is not permitted to write to the destination. A sink can + * export log entries only from the resource owning the sink. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource in which to create the sink: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * + * Examples: `"projects/my-logging-project"`, `"organizations/123456789"`. + * @param {google.logging.v2.LogSink} request.sink + * Required. The new sink, whose `name` parameter is a sink identifier that + * is not already in use. + * @param {boolean} [request.uniqueWriterIdentity] + * Optional. Determines the kind of IAM identity returned as `writer_identity` + * in the new sink. If this value is omitted or set to false, and if the + * sink's parent is a project, then the value returned as `writer_identity` is + * the same group or service account used by Logging before the addition of + * writer identities to this API. The sink's destination must be in the same + * project as the sink itself. + * + * If this field is set to true, or if the sink is owned by a non-project + * resource such as an organization, then the value of `writer_identity` will + * be a unique service account used only for exports from the new sink. For + * more information, see `writer_identity` in {@link google.logging.v2.LogSink|LogSink}. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LogSink]{@link google.logging.v2.LogSink}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + createSink( + request: protosTypes.google.logging.v2.ICreateSinkRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.logging.v2.ILogSink, + protosTypes.google.logging.v2.ICreateSinkRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.logging.v2.ILogSink, + protosTypes.google.logging.v2.ICreateSinkRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.logging.v2.ILogSink, + protosTypes.google.logging.v2.ICreateSinkRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this._innerApiCalls.createSink(request, options, callback); + } + updateSink( + request: protosTypes.google.logging.v2.IUpdateSinkRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.logging.v2.ILogSink, + protosTypes.google.logging.v2.IUpdateSinkRequest|undefined, {}|undefined + ]>; + updateSink( + request: protosTypes.google.logging.v2.IUpdateSinkRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.logging.v2.ILogSink, + protosTypes.google.logging.v2.IUpdateSinkRequest|undefined, + {}|undefined>): void; +/** + * Updates a sink. This method replaces the following fields in the existing + * sink with values from the new sink: `destination`, and `filter`. + * + * The updated sink might also have a new `writer_identity`; see the + * `unique_writer_identity` field. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.sinkName + * Required. The full resource name of the sink to update, including the parent + * resource and the sink identifier: + * + * "projects/[PROJECT_ID]/sinks/[SINK_ID]" + * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" + * "folders/[FOLDER_ID]/sinks/[SINK_ID]" + * + * Example: `"projects/my-project-id/sinks/my-sink-id"`. + * @param {google.logging.v2.LogSink} request.sink + * Required. The updated sink, whose name is the same identifier that appears as part + * of `sink_name`. + * @param {boolean} [request.uniqueWriterIdentity] + * Optional. See {@link google.logging.v2.ConfigServiceV2.CreateSink|sinks.create} + * for a description of this field. When updating a sink, the effect of this + * field on the value of `writer_identity` in the updated sink depends on both + * the old and new values of this field: + * + * + If the old and new values of this field are both false or both true, + * then there is no change to the sink's `writer_identity`. + * + If the old value is false and the new value is true, then + * `writer_identity` is changed to a unique service account. + * + It is an error if the old value is true and the new value is + * set to false or defaulted to false. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask that specifies the fields in `sink` that need + * an update. A sink field will be overwritten if, and only if, it is + * in the update mask. `name` and output only fields cannot be updated. + * + * An empty updateMask is temporarily treated as using the following mask + * for backwards compatibility purposes: + * destination,filter,includeChildren + * At some point in the future, behavior will be removed and specifying an + * empty updateMask will be an error. + * + * For a detailed `FieldMask` definition, see + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask + * + * Example: `updateMask=filter`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LogSink]{@link google.logging.v2.LogSink}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + updateSink( + request: protosTypes.google.logging.v2.IUpdateSinkRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.logging.v2.ILogSink, + protosTypes.google.logging.v2.IUpdateSinkRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.logging.v2.ILogSink, + protosTypes.google.logging.v2.IUpdateSinkRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.logging.v2.ILogSink, + protosTypes.google.logging.v2.IUpdateSinkRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'sink_name': request.sinkName || '', + }); + this.initialize(); + return this._innerApiCalls.updateSink(request, options, callback); + } + deleteSink( + request: protosTypes.google.logging.v2.IDeleteSinkRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.logging.v2.IDeleteSinkRequest|undefined, {}|undefined + ]>; + deleteSink( + request: protosTypes.google.logging.v2.IDeleteSinkRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.logging.v2.IDeleteSinkRequest|undefined, + {}|undefined>): void; +/** + * Deletes a sink. If the sink has a unique `writer_identity`, then that + * service account is also deleted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.sinkName + * Required. The full resource name of the sink to delete, including the parent + * resource and the sink identifier: + * + * "projects/[PROJECT_ID]/sinks/[SINK_ID]" + * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" + * "folders/[FOLDER_ID]/sinks/[SINK_ID]" + * + * Example: `"projects/my-project-id/sinks/my-sink-id"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + deleteSink( + request: protosTypes.google.logging.v2.IDeleteSinkRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.logging.v2.IDeleteSinkRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.logging.v2.IDeleteSinkRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.logging.v2.IDeleteSinkRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'sink_name': request.sinkName || '', + }); + this.initialize(); + return this._innerApiCalls.deleteSink(request, options, callback); + } + getExclusion( + request: protosTypes.google.logging.v2.IGetExclusionRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.logging.v2.ILogExclusion, + protosTypes.google.logging.v2.IGetExclusionRequest|undefined, {}|undefined + ]>; + getExclusion( + request: protosTypes.google.logging.v2.IGetExclusionRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.logging.v2.ILogExclusion, + protosTypes.google.logging.v2.IGetExclusionRequest|undefined, + {}|undefined>): void; +/** + * Gets the description of an exclusion. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of an existing exclusion: + * + * "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" + * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" + * "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" + * + * Example: `"projects/my-project-id/exclusions/my-exclusion-id"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LogExclusion]{@link google.logging.v2.LogExclusion}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getExclusion( + request: protosTypes.google.logging.v2.IGetExclusionRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.logging.v2.ILogExclusion, + protosTypes.google.logging.v2.IGetExclusionRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.logging.v2.ILogExclusion, + protosTypes.google.logging.v2.IGetExclusionRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.logging.v2.ILogExclusion, + protosTypes.google.logging.v2.IGetExclusionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this._innerApiCalls.getExclusion(request, options, callback); + } + createExclusion( + request: protosTypes.google.logging.v2.ICreateExclusionRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.logging.v2.ILogExclusion, + protosTypes.google.logging.v2.ICreateExclusionRequest|undefined, {}|undefined + ]>; + createExclusion( + request: protosTypes.google.logging.v2.ICreateExclusionRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.logging.v2.ILogExclusion, + protosTypes.google.logging.v2.ICreateExclusionRequest|undefined, + {}|undefined>): void; +/** + * Creates a new exclusion in a specified parent resource. + * Only log entries belonging to that resource can be excluded. + * You can have up to 10 exclusions in a resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource in which to create the exclusion: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * + * Examples: `"projects/my-logging-project"`, `"organizations/123456789"`. + * @param {google.logging.v2.LogExclusion} request.exclusion + * Required. The new exclusion, whose `name` parameter is an exclusion name + * that is not already used in the parent resource. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LogExclusion]{@link google.logging.v2.LogExclusion}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + createExclusion( + request: protosTypes.google.logging.v2.ICreateExclusionRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.logging.v2.ILogExclusion, + protosTypes.google.logging.v2.ICreateExclusionRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.logging.v2.ILogExclusion, + protosTypes.google.logging.v2.ICreateExclusionRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.logging.v2.ILogExclusion, + protosTypes.google.logging.v2.ICreateExclusionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this._innerApiCalls.createExclusion(request, options, callback); + } + updateExclusion( + request: protosTypes.google.logging.v2.IUpdateExclusionRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.logging.v2.ILogExclusion, + protosTypes.google.logging.v2.IUpdateExclusionRequest|undefined, {}|undefined + ]>; + updateExclusion( + request: protosTypes.google.logging.v2.IUpdateExclusionRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.logging.v2.ILogExclusion, + protosTypes.google.logging.v2.IUpdateExclusionRequest|undefined, + {}|undefined>): void; +/** + * Changes one or more properties of an existing exclusion. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the exclusion to update: + * + * "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" + * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" + * "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" + * + * Example: `"projects/my-project-id/exclusions/my-exclusion-id"`. + * @param {google.logging.v2.LogExclusion} request.exclusion + * Required. New values for the existing exclusion. Only the fields specified in + * `update_mask` are relevant. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. A non-empty list of fields to change in the existing exclusion. New values + * for the fields are taken from the corresponding fields in the + * {@link google.logging.v2.LogExclusion|LogExclusion} included in this request. Fields not mentioned in + * `update_mask` are not changed and are ignored in the request. + * + * For example, to change the filter and description of an exclusion, + * specify an `update_mask` of `"filter,description"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LogExclusion]{@link google.logging.v2.LogExclusion}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + updateExclusion( + request: protosTypes.google.logging.v2.IUpdateExclusionRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.logging.v2.ILogExclusion, + protosTypes.google.logging.v2.IUpdateExclusionRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.logging.v2.ILogExclusion, + protosTypes.google.logging.v2.IUpdateExclusionRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.logging.v2.ILogExclusion, + protosTypes.google.logging.v2.IUpdateExclusionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this._innerApiCalls.updateExclusion(request, options, callback); + } + deleteExclusion( + request: protosTypes.google.logging.v2.IDeleteExclusionRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.logging.v2.IDeleteExclusionRequest|undefined, {}|undefined + ]>; + deleteExclusion( + request: protosTypes.google.logging.v2.IDeleteExclusionRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.logging.v2.IDeleteExclusionRequest|undefined, + {}|undefined>): void; +/** + * Deletes an exclusion. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of an existing exclusion to delete: + * + * "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" + * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" + * "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" + * + * Example: `"projects/my-project-id/exclusions/my-exclusion-id"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + deleteExclusion( + request: protosTypes.google.logging.v2.IDeleteExclusionRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.logging.v2.IDeleteExclusionRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.logging.v2.IDeleteExclusionRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.logging.v2.IDeleteExclusionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this._innerApiCalls.deleteExclusion(request, options, callback); + } + getCmekSettings( + request: protosTypes.google.logging.v2.IGetCmekSettingsRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.logging.v2.ICmekSettings, + protosTypes.google.logging.v2.IGetCmekSettingsRequest|undefined, {}|undefined + ]>; + getCmekSettings( + request: protosTypes.google.logging.v2.IGetCmekSettingsRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.logging.v2.ICmekSettings, + protosTypes.google.logging.v2.IGetCmekSettingsRequest|undefined, + {}|undefined>): void; +/** + * Gets the Logs Router CMEK settings for the given resource. + * + * Note: CMEK for the Logs Router can currently only be configured for GCP + * organizations. Once configured, it applies to all projects and folders in + * the GCP organization. + * + * See [Enabling CMEK for Logs + * Router](/logging/docs/routing/managed-encryption) for more information. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource for which to retrieve CMEK settings. + * + * "projects/[PROJECT_ID]/cmekSettings" + * "organizations/[ORGANIZATION_ID]/cmekSettings" + * "billingAccounts/[BILLING_ACCOUNT_ID]/cmekSettings" + * "folders/[FOLDER_ID]/cmekSettings" + * + * Example: `"organizations/12345/cmekSettings"`. + * + * Note: CMEK for the Logs Router can currently only be configured for GCP + * organizations. Once configured, it applies to all projects and folders in + * the GCP organization. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CmekSettings]{@link google.logging.v2.CmekSettings}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getCmekSettings( + request: protosTypes.google.logging.v2.IGetCmekSettingsRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.logging.v2.ICmekSettings, + protosTypes.google.logging.v2.IGetCmekSettingsRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.logging.v2.ICmekSettings, + protosTypes.google.logging.v2.IGetCmekSettingsRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.logging.v2.ICmekSettings, + protosTypes.google.logging.v2.IGetCmekSettingsRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this._innerApiCalls.getCmekSettings(request, options, callback); + } + updateCmekSettings( + request: protosTypes.google.logging.v2.IUpdateCmekSettingsRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.logging.v2.ICmekSettings, + protosTypes.google.logging.v2.IUpdateCmekSettingsRequest|undefined, {}|undefined + ]>; + updateCmekSettings( + request: protosTypes.google.logging.v2.IUpdateCmekSettingsRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.logging.v2.ICmekSettings, + protosTypes.google.logging.v2.IUpdateCmekSettingsRequest|undefined, + {}|undefined>): void; +/** + * Updates the Logs Router CMEK settings for the given resource. + * + * Note: CMEK for the Logs Router can currently only be configured for GCP + * organizations. Once configured, it applies to all projects and folders in + * the GCP organization. + * + * {@link google.logging.v2.ConfigServiceV2.UpdateCmekSettings|UpdateCmekSettings} + * will fail if 1) `kms_key_name` is invalid, or 2) the associated service + * account does not have the required + * `roles/cloudkms.cryptoKeyEncrypterDecrypter` role assigned for the key, or + * 3) access to the key is disabled. + * + * See [Enabling CMEK for Logs + * Router](/logging/docs/routing/managed-encryption) for more information. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the CMEK settings to update. + * + * "projects/[PROJECT_ID]/cmekSettings" + * "organizations/[ORGANIZATION_ID]/cmekSettings" + * "billingAccounts/[BILLING_ACCOUNT_ID]/cmekSettings" + * "folders/[FOLDER_ID]/cmekSettings" + * + * Example: `"organizations/12345/cmekSettings"`. + * + * Note: CMEK for the Logs Router can currently only be configured for GCP + * organizations. Once configured, it applies to all projects and folders in + * the GCP organization. + * @param {google.logging.v2.CmekSettings} request.cmekSettings + * Required. The CMEK settings to update. + * + * See [Enabling CMEK for Logs + * Router](/logging/docs/routing/managed-encryption) for more information. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask identifying which fields from `cmek_settings` should + * be updated. A field will be overwritten if and only if it is in the update + * mask. Output only fields cannot be updated. + * + * See {@link google.protobuf.FieldMask|FieldMask} for more information. + * + * Example: `"updateMask=kmsKeyName"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CmekSettings]{@link google.logging.v2.CmekSettings}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + updateCmekSettings( + request: protosTypes.google.logging.v2.IUpdateCmekSettingsRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.logging.v2.ICmekSettings, + protosTypes.google.logging.v2.IUpdateCmekSettingsRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.logging.v2.ICmekSettings, + protosTypes.google.logging.v2.IUpdateCmekSettingsRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.logging.v2.ICmekSettings, + protosTypes.google.logging.v2.IUpdateCmekSettingsRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this._innerApiCalls.updateCmekSettings(request, options, callback); + } + + listBuckets( + request: protosTypes.google.logging.v2.IListBucketsRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.logging.v2.ILogBucket[], + protosTypes.google.logging.v2.IListBucketsRequest|null, + protosTypes.google.logging.v2.IListBucketsResponse + ]>; + listBuckets( + request: protosTypes.google.logging.v2.IListBucketsRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.logging.v2.ILogBucket[], + protosTypes.google.logging.v2.IListBucketsRequest|null, + protosTypes.google.logging.v2.IListBucketsResponse>): void; +/** + * Lists buckets (Beta). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource whose buckets are to be listed: + * + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]" + * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]" + * + * Note: The locations portion of the resource must be specified, but + * supplying the character `-` in place of [LOCATION_ID] will return all + * buckets. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [LogBucket]{@link google.logging.v2.LogBucket}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [LogBucket]{@link google.logging.v2.LogBucket} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListBucketsRequest]{@link google.logging.v2.ListBucketsRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListBucketsResponse]{@link google.logging.v2.ListBucketsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listBuckets( + request: protosTypes.google.logging.v2.IListBucketsRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.logging.v2.ILogBucket[], + protosTypes.google.logging.v2.IListBucketsRequest|null, + protosTypes.google.logging.v2.IListBucketsResponse>, + callback?: Callback< + protosTypes.google.logging.v2.ILogBucket[], + protosTypes.google.logging.v2.IListBucketsRequest|null, + protosTypes.google.logging.v2.IListBucketsResponse>): + Promise<[ + protosTypes.google.logging.v2.ILogBucket[], + protosTypes.google.logging.v2.IListBucketsRequest|null, + protosTypes.google.logging.v2.IListBucketsResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this._innerApiCalls.listBuckets(request, options, callback); + } + +/** + * Equivalent to {@link listBuckets}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listBuckets} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource whose buckets are to be listed: + * + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]" + * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]" + * + * Note: The locations portion of the resource must be specified, but + * supplying the character `-` in place of [LOCATION_ID] will return all + * buckets. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [LogBucket]{@link google.logging.v2.LogBucket} on 'data' event. + */ + listBucketsStream( + request?: protosTypes.google.logging.v2.IListBucketsRequest, + options?: gax.CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this._descriptors.page.listBuckets.createStream( + this._innerApiCalls.listBuckets as gax.GaxCall, + request, + callSettings + ); + } + listSinks( + request: protosTypes.google.logging.v2.IListSinksRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.logging.v2.ILogSink[], + protosTypes.google.logging.v2.IListSinksRequest|null, + protosTypes.google.logging.v2.IListSinksResponse + ]>; + listSinks( + request: protosTypes.google.logging.v2.IListSinksRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.logging.v2.ILogSink[], + protosTypes.google.logging.v2.IListSinksRequest|null, + protosTypes.google.logging.v2.IListSinksResponse>): void; +/** + * Lists sinks. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource whose sinks are to be listed: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [LogSink]{@link google.logging.v2.LogSink}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [LogSink]{@link google.logging.v2.LogSink} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListSinksRequest]{@link google.logging.v2.ListSinksRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListSinksResponse]{@link google.logging.v2.ListSinksResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listSinks( + request: protosTypes.google.logging.v2.IListSinksRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.logging.v2.ILogSink[], + protosTypes.google.logging.v2.IListSinksRequest|null, + protosTypes.google.logging.v2.IListSinksResponse>, + callback?: Callback< + protosTypes.google.logging.v2.ILogSink[], + protosTypes.google.logging.v2.IListSinksRequest|null, + protosTypes.google.logging.v2.IListSinksResponse>): + Promise<[ + protosTypes.google.logging.v2.ILogSink[], + protosTypes.google.logging.v2.IListSinksRequest|null, + protosTypes.google.logging.v2.IListSinksResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this._innerApiCalls.listSinks(request, options, callback); + } + +/** + * Equivalent to {@link listSinks}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listSinks} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource whose sinks are to be listed: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [LogSink]{@link google.logging.v2.LogSink} on 'data' event. + */ + listSinksStream( + request?: protosTypes.google.logging.v2.IListSinksRequest, + options?: gax.CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this._descriptors.page.listSinks.createStream( + this._innerApiCalls.listSinks as gax.GaxCall, + request, + callSettings + ); + } + listExclusions( + request: protosTypes.google.logging.v2.IListExclusionsRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.logging.v2.ILogExclusion[], + protosTypes.google.logging.v2.IListExclusionsRequest|null, + protosTypes.google.logging.v2.IListExclusionsResponse + ]>; + listExclusions( + request: protosTypes.google.logging.v2.IListExclusionsRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.logging.v2.ILogExclusion[], + protosTypes.google.logging.v2.IListExclusionsRequest|null, + protosTypes.google.logging.v2.IListExclusionsResponse>): void; +/** + * Lists all the exclusions in a parent resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource whose exclusions are to be listed. + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [LogExclusion]{@link google.logging.v2.LogExclusion}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [LogExclusion]{@link google.logging.v2.LogExclusion} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListExclusionsRequest]{@link google.logging.v2.ListExclusionsRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListExclusionsResponse]{@link google.logging.v2.ListExclusionsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listExclusions( + request: protosTypes.google.logging.v2.IListExclusionsRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.logging.v2.ILogExclusion[], + protosTypes.google.logging.v2.IListExclusionsRequest|null, + protosTypes.google.logging.v2.IListExclusionsResponse>, + callback?: Callback< + protosTypes.google.logging.v2.ILogExclusion[], + protosTypes.google.logging.v2.IListExclusionsRequest|null, + protosTypes.google.logging.v2.IListExclusionsResponse>): + Promise<[ + protosTypes.google.logging.v2.ILogExclusion[], + protosTypes.google.logging.v2.IListExclusionsRequest|null, + protosTypes.google.logging.v2.IListExclusionsResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this._innerApiCalls.listExclusions(request, options, callback); + } + +/** + * Equivalent to {@link listExclusions}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listExclusions} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource whose exclusions are to be listed. + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [LogExclusion]{@link google.logging.v2.LogExclusion} on 'data' event. + */ + listExclusionsStream( + request?: protosTypes.google.logging.v2.IListExclusionsRequest, + options?: gax.CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this._descriptors.page.listExclusions.createStream( + this._innerApiCalls.listExclusions as gax.GaxCall, + request, + callSettings + ); + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified billingAccountCmekSettings resource name string. + * + * @param {string} billing_account + * @returns {string} Resource name string. + */ + billingAccountCmekSettingsPath(billingAccount:string) { + return this._pathTemplates.billingAccountCmekSettingsPathTemplate.render({ + billing_account: billingAccount, + }); + } + + /** + * Parse the billing_account from BillingAccountCmekSettings resource. + * + * @param {string} billingAccountCmekSettingsName + * A fully-qualified path representing billing_account_cmekSettings resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountCmekSettingsName(billingAccountCmekSettingsName: string) { + return this._pathTemplates.billingAccountCmekSettingsPathTemplate.match(billingAccountCmekSettingsName).billing_account; + } + + /** + * Return a fully-qualified billingAccountExclusion resource name string. + * + * @param {string} billing_account + * @param {string} exclusion + * @returns {string} Resource name string. + */ + billingAccountExclusionPath(billingAccount:string,exclusion:string) { + return this._pathTemplates.billingAccountExclusionPathTemplate.render({ + billing_account: billingAccount, + exclusion: exclusion, + }); + } + + /** + * Parse the billing_account from BillingAccountExclusion resource. + * + * @param {string} billingAccountExclusionName + * A fully-qualified path representing billing_account_exclusion resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountExclusionName(billingAccountExclusionName: string) { + return this._pathTemplates.billingAccountExclusionPathTemplate.match(billingAccountExclusionName).billing_account; + } + + /** + * Parse the exclusion from BillingAccountExclusion resource. + * + * @param {string} billingAccountExclusionName + * A fully-qualified path representing billing_account_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromBillingAccountExclusionName(billingAccountExclusionName: string) { + return this._pathTemplates.billingAccountExclusionPathTemplate.match(billingAccountExclusionName).exclusion; + } + + /** + * Return a fully-qualified billingAccountLocationBucket resource name string. + * + * @param {string} billing_account + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + billingAccountLocationBucketPath(billingAccount:string,location:string,bucket:string) { + return this._pathTemplates.billingAccountLocationBucketPathTemplate.render({ + billing_account: billingAccount, + location: location, + bucket: bucket, + }); + } + + /** + * Parse the billing_account from BillingAccountLocationBucket resource. + * + * @param {string} billingAccountLocationBucketName + * A fully-qualified path representing billing_account_location_bucket resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountLocationBucketName(billingAccountLocationBucketName: string) { + return this._pathTemplates.billingAccountLocationBucketPathTemplate.match(billingAccountLocationBucketName).billing_account; + } + + /** + * Parse the location from BillingAccountLocationBucket resource. + * + * @param {string} billingAccountLocationBucketName + * A fully-qualified path representing billing_account_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBillingAccountLocationBucketName(billingAccountLocationBucketName: string) { + return this._pathTemplates.billingAccountLocationBucketPathTemplate.match(billingAccountLocationBucketName).location; + } + + /** + * Parse the bucket from BillingAccountLocationBucket resource. + * + * @param {string} billingAccountLocationBucketName + * A fully-qualified path representing billing_account_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromBillingAccountLocationBucketName(billingAccountLocationBucketName: string) { + return this._pathTemplates.billingAccountLocationBucketPathTemplate.match(billingAccountLocationBucketName).bucket; + } + + /** + * Return a fully-qualified billingAccountLog resource name string. + * + * @param {string} billing_account + * @param {string} log + * @returns {string} Resource name string. + */ + billingAccountLogPath(billingAccount:string,log:string) { + return this._pathTemplates.billingAccountLogPathTemplate.render({ + billing_account: billingAccount, + log: log, + }); + } + + /** + * Parse the billing_account from BillingAccountLog resource. + * + * @param {string} billingAccountLogName + * A fully-qualified path representing billing_account_log resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountLogName(billingAccountLogName: string) { + return this._pathTemplates.billingAccountLogPathTemplate.match(billingAccountLogName).billing_account; + } + + /** + * Parse the log from BillingAccountLog resource. + * + * @param {string} billingAccountLogName + * A fully-qualified path representing billing_account_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromBillingAccountLogName(billingAccountLogName: string) { + return this._pathTemplates.billingAccountLogPathTemplate.match(billingAccountLogName).log; + } + + /** + * Return a fully-qualified billingAccountSink resource name string. + * + * @param {string} billing_account + * @param {string} sink + * @returns {string} Resource name string. + */ + billingAccountSinkPath(billingAccount:string,sink:string) { + return this._pathTemplates.billingAccountSinkPathTemplate.render({ + billing_account: billingAccount, + sink: sink, + }); + } + + /** + * Parse the billing_account from BillingAccountSink resource. + * + * @param {string} billingAccountSinkName + * A fully-qualified path representing billing_account_sink resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountSinkName(billingAccountSinkName: string) { + return this._pathTemplates.billingAccountSinkPathTemplate.match(billingAccountSinkName).billing_account; + } + + /** + * Parse the sink from BillingAccountSink resource. + * + * @param {string} billingAccountSinkName + * A fully-qualified path representing billing_account_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromBillingAccountSinkName(billingAccountSinkName: string) { + return this._pathTemplates.billingAccountSinkPathTemplate.match(billingAccountSinkName).sink; + } + + /** + * Return a fully-qualified folderCmekSettings resource name string. + * + * @param {string} folder + * @returns {string} Resource name string. + */ + folderCmekSettingsPath(folder:string) { + return this._pathTemplates.folderCmekSettingsPathTemplate.render({ + folder: folder, + }); + } + + /** + * Parse the folder from FolderCmekSettings resource. + * + * @param {string} folderCmekSettingsName + * A fully-qualified path representing folder_cmekSettings resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderCmekSettingsName(folderCmekSettingsName: string) { + return this._pathTemplates.folderCmekSettingsPathTemplate.match(folderCmekSettingsName).folder; + } + + /** + * Return a fully-qualified folderExclusion resource name string. + * + * @param {string} folder + * @param {string} exclusion + * @returns {string} Resource name string. + */ + folderExclusionPath(folder:string,exclusion:string) { + return this._pathTemplates.folderExclusionPathTemplate.render({ + folder: folder, + exclusion: exclusion, + }); + } + + /** + * Parse the folder from FolderExclusion resource. + * + * @param {string} folderExclusionName + * A fully-qualified path representing folder_exclusion resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderExclusionName(folderExclusionName: string) { + return this._pathTemplates.folderExclusionPathTemplate.match(folderExclusionName).folder; + } + + /** + * Parse the exclusion from FolderExclusion resource. + * + * @param {string} folderExclusionName + * A fully-qualified path representing folder_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromFolderExclusionName(folderExclusionName: string) { + return this._pathTemplates.folderExclusionPathTemplate.match(folderExclusionName).exclusion; + } + + /** + * Return a fully-qualified folderLocationBucket resource name string. + * + * @param {string} folder + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + folderLocationBucketPath(folder:string,location:string,bucket:string) { + return this._pathTemplates.folderLocationBucketPathTemplate.render({ + folder: folder, + location: location, + bucket: bucket, + }); + } + + /** + * Parse the folder from FolderLocationBucket resource. + * + * @param {string} folderLocationBucketName + * A fully-qualified path representing folder_location_bucket resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderLocationBucketName(folderLocationBucketName: string) { + return this._pathTemplates.folderLocationBucketPathTemplate.match(folderLocationBucketName).folder; + } + + /** + * Parse the location from FolderLocationBucket resource. + * + * @param {string} folderLocationBucketName + * A fully-qualified path representing folder_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromFolderLocationBucketName(folderLocationBucketName: string) { + return this._pathTemplates.folderLocationBucketPathTemplate.match(folderLocationBucketName).location; + } + + /** + * Parse the bucket from FolderLocationBucket resource. + * + * @param {string} folderLocationBucketName + * A fully-qualified path representing folder_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromFolderLocationBucketName(folderLocationBucketName: string) { + return this._pathTemplates.folderLocationBucketPathTemplate.match(folderLocationBucketName).bucket; + } + + /** + * Return a fully-qualified folderLog resource name string. + * + * @param {string} folder + * @param {string} log + * @returns {string} Resource name string. + */ + folderLogPath(folder:string,log:string) { + return this._pathTemplates.folderLogPathTemplate.render({ + folder: folder, + log: log, + }); + } + + /** + * Parse the folder from FolderLog resource. + * + * @param {string} folderLogName + * A fully-qualified path representing folder_log resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderLogName(folderLogName: string) { + return this._pathTemplates.folderLogPathTemplate.match(folderLogName).folder; + } + + /** + * Parse the log from FolderLog resource. + * + * @param {string} folderLogName + * A fully-qualified path representing folder_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromFolderLogName(folderLogName: string) { + return this._pathTemplates.folderLogPathTemplate.match(folderLogName).log; + } + + /** + * Return a fully-qualified folderSink resource name string. + * + * @param {string} folder + * @param {string} sink + * @returns {string} Resource name string. + */ + folderSinkPath(folder:string,sink:string) { + return this._pathTemplates.folderSinkPathTemplate.render({ + folder: folder, + sink: sink, + }); + } + + /** + * Parse the folder from FolderSink resource. + * + * @param {string} folderSinkName + * A fully-qualified path representing folder_sink resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderSinkName(folderSinkName: string) { + return this._pathTemplates.folderSinkPathTemplate.match(folderSinkName).folder; + } + + /** + * Parse the sink from FolderSink resource. + * + * @param {string} folderSinkName + * A fully-qualified path representing folder_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromFolderSinkName(folderSinkName: string) { + return this._pathTemplates.folderSinkPathTemplate.match(folderSinkName).sink; + } + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this._pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this._pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this._pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified logMetric resource name string. + * + * @param {string} project + * @param {string} metric + * @returns {string} Resource name string. + */ + logMetricPath(project:string,metric:string) { + return this._pathTemplates.logMetricPathTemplate.render({ + project: project, + metric: metric, + }); + } + + /** + * Parse the project from LogMetric resource. + * + * @param {string} logMetricName + * A fully-qualified path representing LogMetric resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLogMetricName(logMetricName: string) { + return this._pathTemplates.logMetricPathTemplate.match(logMetricName).project; + } + + /** + * Parse the metric from LogMetric resource. + * + * @param {string} logMetricName + * A fully-qualified path representing LogMetric resource. + * @returns {string} A string representing the metric. + */ + matchMetricFromLogMetricName(logMetricName: string) { + return this._pathTemplates.logMetricPathTemplate.match(logMetricName).metric; + } + + /** + * Return a fully-qualified organizationCmekSettings resource name string. + * + * @param {string} organization + * @returns {string} Resource name string. + */ + organizationCmekSettingsPath(organization:string) { + return this._pathTemplates.organizationCmekSettingsPathTemplate.render({ + organization: organization, + }); + } + + /** + * Parse the organization from OrganizationCmekSettings resource. + * + * @param {string} organizationCmekSettingsName + * A fully-qualified path representing organization_cmekSettings resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationCmekSettingsName(organizationCmekSettingsName: string) { + return this._pathTemplates.organizationCmekSettingsPathTemplate.match(organizationCmekSettingsName).organization; + } + + /** + * Return a fully-qualified organizationExclusion resource name string. + * + * @param {string} organization + * @param {string} exclusion + * @returns {string} Resource name string. + */ + organizationExclusionPath(organization:string,exclusion:string) { + return this._pathTemplates.organizationExclusionPathTemplate.render({ + organization: organization, + exclusion: exclusion, + }); + } + + /** + * Parse the organization from OrganizationExclusion resource. + * + * @param {string} organizationExclusionName + * A fully-qualified path representing organization_exclusion resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationExclusionName(organizationExclusionName: string) { + return this._pathTemplates.organizationExclusionPathTemplate.match(organizationExclusionName).organization; + } + + /** + * Parse the exclusion from OrganizationExclusion resource. + * + * @param {string} organizationExclusionName + * A fully-qualified path representing organization_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromOrganizationExclusionName(organizationExclusionName: string) { + return this._pathTemplates.organizationExclusionPathTemplate.match(organizationExclusionName).exclusion; + } + + /** + * Return a fully-qualified organizationLocationBucket resource name string. + * + * @param {string} organization + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + organizationLocationBucketPath(organization:string,location:string,bucket:string) { + return this._pathTemplates.organizationLocationBucketPathTemplate.render({ + organization: organization, + location: location, + bucket: bucket, + }); + } + + /** + * Parse the organization from OrganizationLocationBucket resource. + * + * @param {string} organizationLocationBucketName + * A fully-qualified path representing organization_location_bucket resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLocationBucketName(organizationLocationBucketName: string) { + return this._pathTemplates.organizationLocationBucketPathTemplate.match(organizationLocationBucketName).organization; + } + + /** + * Parse the location from OrganizationLocationBucket resource. + * + * @param {string} organizationLocationBucketName + * A fully-qualified path representing organization_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOrganizationLocationBucketName(organizationLocationBucketName: string) { + return this._pathTemplates.organizationLocationBucketPathTemplate.match(organizationLocationBucketName).location; + } + + /** + * Parse the bucket from OrganizationLocationBucket resource. + * + * @param {string} organizationLocationBucketName + * A fully-qualified path representing organization_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromOrganizationLocationBucketName(organizationLocationBucketName: string) { + return this._pathTemplates.organizationLocationBucketPathTemplate.match(organizationLocationBucketName).bucket; + } + + /** + * Return a fully-qualified organizationLog resource name string. + * + * @param {string} organization + * @param {string} log + * @returns {string} Resource name string. + */ + organizationLogPath(organization:string,log:string) { + return this._pathTemplates.organizationLogPathTemplate.render({ + organization: organization, + log: log, + }); + } + + /** + * Parse the organization from OrganizationLog resource. + * + * @param {string} organizationLogName + * A fully-qualified path representing organization_log resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLogName(organizationLogName: string) { + return this._pathTemplates.organizationLogPathTemplate.match(organizationLogName).organization; + } + + /** + * Parse the log from OrganizationLog resource. + * + * @param {string} organizationLogName + * A fully-qualified path representing organization_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromOrganizationLogName(organizationLogName: string) { + return this._pathTemplates.organizationLogPathTemplate.match(organizationLogName).log; + } + + /** + * Return a fully-qualified organizationSink resource name string. + * + * @param {string} organization + * @param {string} sink + * @returns {string} Resource name string. + */ + organizationSinkPath(organization:string,sink:string) { + return this._pathTemplates.organizationSinkPathTemplate.render({ + organization: organization, + sink: sink, + }); + } + + /** + * Parse the organization from OrganizationSink resource. + * + * @param {string} organizationSinkName + * A fully-qualified path representing organization_sink resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationSinkName(organizationSinkName: string) { + return this._pathTemplates.organizationSinkPathTemplate.match(organizationSinkName).organization; + } + + /** + * Parse the sink from OrganizationSink resource. + * + * @param {string} organizationSinkName + * A fully-qualified path representing organization_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromOrganizationSinkName(organizationSinkName: string) { + return this._pathTemplates.organizationSinkPathTemplate.match(organizationSinkName).sink; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this._pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this._pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified projectCmekSettings resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectCmekSettingsPath(project:string) { + return this._pathTemplates.projectCmekSettingsPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from ProjectCmekSettings resource. + * + * @param {string} projectCmekSettingsName + * A fully-qualified path representing project_cmekSettings resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectCmekSettingsName(projectCmekSettingsName: string) { + return this._pathTemplates.projectCmekSettingsPathTemplate.match(projectCmekSettingsName).project; + } + + /** + * Return a fully-qualified projectExclusion resource name string. + * + * @param {string} project + * @param {string} exclusion + * @returns {string} Resource name string. + */ + projectExclusionPath(project:string,exclusion:string) { + return this._pathTemplates.projectExclusionPathTemplate.render({ + project: project, + exclusion: exclusion, + }); + } + + /** + * Parse the project from ProjectExclusion resource. + * + * @param {string} projectExclusionName + * A fully-qualified path representing project_exclusion resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectExclusionName(projectExclusionName: string) { + return this._pathTemplates.projectExclusionPathTemplate.match(projectExclusionName).project; + } + + /** + * Parse the exclusion from ProjectExclusion resource. + * + * @param {string} projectExclusionName + * A fully-qualified path representing project_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromProjectExclusionName(projectExclusionName: string) { + return this._pathTemplates.projectExclusionPathTemplate.match(projectExclusionName).exclusion; + } + + /** + * Return a fully-qualified projectLocationBucket resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + projectLocationBucketPath(project:string,location:string,bucket:string) { + return this._pathTemplates.projectLocationBucketPathTemplate.render({ + project: project, + location: location, + bucket: bucket, + }); + } + + /** + * Parse the project from ProjectLocationBucket resource. + * + * @param {string} projectLocationBucketName + * A fully-qualified path representing project_location_bucket resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationBucketName(projectLocationBucketName: string) { + return this._pathTemplates.projectLocationBucketPathTemplate.match(projectLocationBucketName).project; + } + + /** + * Parse the location from ProjectLocationBucket resource. + * + * @param {string} projectLocationBucketName + * A fully-qualified path representing project_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationBucketName(projectLocationBucketName: string) { + return this._pathTemplates.projectLocationBucketPathTemplate.match(projectLocationBucketName).location; + } + + /** + * Parse the bucket from ProjectLocationBucket resource. + * + * @param {string} projectLocationBucketName + * A fully-qualified path representing project_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromProjectLocationBucketName(projectLocationBucketName: string) { + return this._pathTemplates.projectLocationBucketPathTemplate.match(projectLocationBucketName).bucket; + } + + /** + * Return a fully-qualified projectLog resource name string. + * + * @param {string} project + * @param {string} log + * @returns {string} Resource name string. + */ + projectLogPath(project:string,log:string) { + return this._pathTemplates.projectLogPathTemplate.render({ + project: project, + log: log, + }); + } + + /** + * Parse the project from ProjectLog resource. + * + * @param {string} projectLogName + * A fully-qualified path representing project_log resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLogName(projectLogName: string) { + return this._pathTemplates.projectLogPathTemplate.match(projectLogName).project; + } + + /** + * Parse the log from ProjectLog resource. + * + * @param {string} projectLogName + * A fully-qualified path representing project_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromProjectLogName(projectLogName: string) { + return this._pathTemplates.projectLogPathTemplate.match(projectLogName).log; + } + + /** + * Return a fully-qualified projectSink resource name string. + * + * @param {string} project + * @param {string} sink + * @returns {string} Resource name string. + */ + projectSinkPath(project:string,sink:string) { + return this._pathTemplates.projectSinkPathTemplate.render({ + project: project, + sink: sink, + }); + } + + /** + * Parse the project from ProjectSink resource. + * + * @param {string} projectSinkName + * A fully-qualified path representing project_sink resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectSinkName(projectSinkName: string) { + return this._pathTemplates.projectSinkPathTemplate.match(projectSinkName).project; + } + + /** + * Parse the sink from ProjectSink resource. + * + * @param {string} projectSinkName + * A fully-qualified path representing project_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromProjectSinkName(projectSinkName: string) { + return this._pathTemplates.projectSinkPathTemplate.match(projectSinkName).sink; + } + + /** + * Terminate the GRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + */ + close(): Promise { + this.initialize(); + if (!this._terminated) { + return this.configServiceV2Stub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/baselines/logging/src/v2/config_service_v2_client_config.json.baseline b/baselines/logging/src/v2/config_service_v2_client_config.json.baseline new file mode 100644 index 000000000..b459ce1fe --- /dev/null +++ b/baselines/logging/src/v2/config_service_v2_client_config.json.baseline @@ -0,0 +1,86 @@ +{ + "interfaces": { + "google.logging.v2.ConfigServiceV2": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListBuckets": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetBucket": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateBucket": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListSinks": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetSink": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateSink": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateSink": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteSink": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListExclusions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetExclusion": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateExclusion": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateExclusion": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteExclusion": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetCmekSettings": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateCmekSettings": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/baselines/logging/src/v2/config_service_v2_proto_list.json.baseline b/baselines/logging/src/v2/config_service_v2_proto_list.json.baseline new file mode 100644 index 000000000..3103c1e58 --- /dev/null +++ b/baselines/logging/src/v2/config_service_v2_proto_list.json.baseline @@ -0,0 +1,6 @@ +[ + "../../protos/google/logging/v2/log_entry.proto", + "../../protos/google/logging/v2/logging.proto", + "../../protos/google/logging/v2/logging_config.proto", + "../../protos/google/logging/v2/logging_metrics.proto" +] diff --git a/baselines/logging/src/v2/index.ts.baseline b/baselines/logging/src/v2/index.ts.baseline new file mode 100644 index 000000000..9ceaa29b6 --- /dev/null +++ b/baselines/logging/src/v2/index.ts.baseline @@ -0,0 +1,19 @@ +// Copyright 2020 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {ConfigServiceV2Client} from './config_service_v2_client';export {LoggingServiceV2Client} from './logging_service_v2_client';export {MetricsServiceV2Client} from './metrics_service_v2_client'; diff --git a/baselines/logging/src/v2/logging_service_v2_client.ts.baseline b/baselines/logging/src/v2/logging_service_v2_client.ts.baseline new file mode 100644 index 000000000..5ba88cbd3 --- /dev/null +++ b/baselines/logging/src/v2/logging_service_v2_client.ts.baseline @@ -0,0 +1,1806 @@ +// Copyright 2020 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as gax from 'google-gax'; +import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, PaginationResponse} from 'google-gax'; +import * as path from 'path'; + +import { Transform } from 'stream'; +import * as protosTypes from '../../protos/protos'; +import * as gapicConfig from './logging_service_v2_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for ingesting and querying logs. + * @class + * @memberof v2 + */ +export class LoggingServiceV2Client { + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; + private _innerApiCalls: {[name: string]: Function}; + private _pathTemplates: {[name: string]: gax.PathTemplate}; + private _terminated = false; + private _opts: ClientOptions; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + loggingServiceV2Stub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of LoggingServiceV2Client. + * + * @param {object} [options] - The configuration object. See the subsequent + * parameters for more details. + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + */ + + constructor(opts?: ClientOptions) { + // Ensure that options include the service address and port. + const staticMembers = this.constructor as typeof LoggingServiceV2Client; + const servicePath = opts && opts.servicePath ? + opts.servicePath : + ((opts && opts.apiEndpoint) ? opts.apiEndpoint : + staticMembers.servicePath); + const port = opts && opts.port ? opts.port : staticMembers.port; + + if (!opts) { + opts = {servicePath, port}; + } + opts.servicePath = opts.servicePath || servicePath; + opts.port = opts.port || port; + opts.clientConfig = opts.clientConfig || {}; + + const isBrowser = (typeof window !== 'undefined'); + if (isBrowser){ + opts.fallback = true; + } + // If we are in browser, we are already using fallback because of the + // "browser" field in package.json. + // But if we were explicitly requested to use fallback, let's do it now. + this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options + // sent to the client. + opts.scopes = (this.constructor as typeof LoggingServiceV2Client).scopes; + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + + const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); + this._protos = this._gaxGrpc.loadProto( + opts.fallback ? + require("../../protos/protos.json") : + nodejsProtoPath + ); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this._pathTemplates = { + billingAccountCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/cmekSettings' + ), + billingAccountExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/exclusions/{exclusion}' + ), + billingAccountLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}' + ), + billingAccountLogPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/logs/{log}' + ), + billingAccountSinkPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/sinks/{sink}' + ), + folderCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/cmekSettings' + ), + folderExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/exclusions/{exclusion}' + ), + folderLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/locations/{location}/buckets/{bucket}' + ), + folderLogPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/logs/{log}' + ), + folderSinkPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/sinks/{sink}' + ), + logMetricPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/metrics/{metric}' + ), + organizationCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/cmekSettings' + ), + organizationExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/exclusions/{exclusion}' + ), + organizationLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/buckets/{bucket}' + ), + organizationLogPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/logs/{log}' + ), + organizationSinkPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/sinks/{sink}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + projectCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/cmekSettings' + ), + projectExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/exclusions/{exclusion}' + ), + projectLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/buckets/{bucket}' + ), + projectLogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/logs/{log}' + ), + projectSinkPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/sinks/{sink}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this._descriptors.page = { + listLogEntries: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'entries'), + listMonitoredResourceDescriptors: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'resourceDescriptors'), + listLogs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'logNames') + }; + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const protoFilesRoot = opts.fallback? + this._gaxModule.protobuf.Root.fromJSON(require("../../protos/protos.json")) : + this._gaxModule.protobuf.loadSync(nodejsProtoPath); + + // Some methods on this API support automatically batching + // requests; denote this. + + this._descriptors.batching = { + WriteLogEntries: new this._gaxModule.BundleDescriptor( + 'entries', + ['log_name','resource','labels'],null, + gax.createByteLengthFunction( + // tslint:disable-next-line no-any + protoFilesRoot.lookupType('google.logging.v2.LogEntry') as any + ) + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.logging.v2.LoggingServiceV2', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this._innerApiCalls = {}; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.loggingServiceV2Stub) { + return this.loggingServiceV2Stub; + } + + // Put together the "service stub" for + // google.logging.v2.LoggingServiceV2. + this.loggingServiceV2Stub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.logging.v2.LoggingServiceV2') : + // tslint:disable-next-line no-any + (this._protos as any).google.logging.v2.LoggingServiceV2, + this._opts) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const loggingServiceV2StubMethods = + ['deleteLog', 'writeLogEntries', 'listLogEntries', 'listMonitoredResourceDescriptors', 'listLogs']; + + for (const methodName of loggingServiceV2StubMethods) { + const innerCallPromise = this.loggingServiceV2Stub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + return stub[methodName].apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const apiCall = this._gaxModule.createApiCall( + innerCallPromise, + this._defaults[methodName], + this._descriptors.page[methodName] || + this._descriptors.stream[methodName] || + this._descriptors.longrunning[methodName] + ); + + this._innerApiCalls[methodName] = ( + argument: {}, + callOptions?: CallOptions, + callback?: APICallback + ) => { + return apiCall(argument, callOptions, callback); + }; + } + + return this.loggingServiceV2Stub; + } + + /** + * The DNS address for this API service. + */ + static get servicePath() { + return 'logging.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'logging.googleapis.com'; + } + + /** + * The port for this API service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + */ + static get scopes() { + return [ + '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' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @param {function(Error, string)} callback - the callback to + * be called with the current project Id. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + deleteLog( + request: protosTypes.google.logging.v2.IDeleteLogRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.logging.v2.IDeleteLogRequest|undefined, {}|undefined + ]>; + deleteLog( + request: protosTypes.google.logging.v2.IDeleteLogRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.logging.v2.IDeleteLogRequest|undefined, + {}|undefined>): void; +/** + * Deletes all the log entries in a log. The log reappears if it receives new + * entries. Log entries written shortly before the delete operation might not + * be deleted. Entries received after the delete operation with a timestamp + * before the operation will be deleted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.logName + * Required. The resource name of the log to delete: + * + * "projects/[PROJECT_ID]/logs/[LOG_ID]" + * "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" + * "folders/[FOLDER_ID]/logs/[LOG_ID]" + * + * `[LOG_ID]` must be URL-encoded. For example, + * `"projects/my-project-id/logs/syslog"`, + * `"organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity"`. + * For more information about log names, see + * {@link google.logging.v2.LogEntry|LogEntry}. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + deleteLog( + request: protosTypes.google.logging.v2.IDeleteLogRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.logging.v2.IDeleteLogRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.logging.v2.IDeleteLogRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.logging.v2.IDeleteLogRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'log_name': request.logName || '', + }); + this.initialize(); + return this._innerApiCalls.deleteLog(request, options, callback); + } + writeLogEntries( + request: protosTypes.google.logging.v2.IWriteLogEntriesRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.logging.v2.IWriteLogEntriesResponse, + protosTypes.google.logging.v2.IWriteLogEntriesRequest|undefined, {}|undefined + ]>; + writeLogEntries( + request: protosTypes.google.logging.v2.IWriteLogEntriesRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.logging.v2.IWriteLogEntriesResponse, + protosTypes.google.logging.v2.IWriteLogEntriesRequest|undefined, + {}|undefined>): void; +/** + * Writes log entries to Logging. This API method is the + * only way to send log entries to Logging. This method + * is used, directly or indirectly, by the Logging agent + * (fluentd) and all logging libraries configured to use Logging. + * A single request may contain log entries for a maximum of 1000 + * different resources (projects, organizations, billing accounts or + * folders) + * + * @param {Object} request + * The request object that will be sent. + * @param {string} [request.logName] + * Optional. A default log resource name that is assigned to all log entries + * in `entries` that do not specify a value for `log_name`: + * + * "projects/[PROJECT_ID]/logs/[LOG_ID]" + * "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" + * "folders/[FOLDER_ID]/logs/[LOG_ID]" + * + * `[LOG_ID]` must be URL-encoded. For example: + * + * "projects/my-project-id/logs/syslog" + * "organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity" + * + * The permission `logging.logEntries.create` is needed on each project, + * organization, billing account, or folder that is receiving new log + * entries, whether the resource is specified in `logName` or in an + * individual log entry. + * @param {google.api.MonitoredResource} [request.resource] + * Optional. A default monitored resource object that is assigned to all log + * entries in `entries` that do not specify a value for `resource`. Example: + * + * { "type": "gce_instance", + * "labels": { + * "zone": "us-central1-a", "instance_id": "00000000000000000000" }} + * + * See {@link google.logging.v2.LogEntry|LogEntry}. + * @param {number[]} [request.labels] + * Optional. Default labels that are added to the `labels` field of all log + * entries in `entries`. If a log entry already has a label with the same key + * as a label in this parameter, then the log entry's label is not changed. + * See {@link google.logging.v2.LogEntry|LogEntry}. + * @param {number[]} request.entries + * Required. The log entries to send to Logging. The order of log + * entries in this list does not matter. Values supplied in this method's + * `log_name`, `resource`, and `labels` fields are copied into those log + * entries in this list that do not include values for their corresponding + * fields. For more information, see the + * {@link google.logging.v2.LogEntry|LogEntry} type. + * + * If the `timestamp` or `insert_id` fields are missing in log entries, then + * this method supplies the current time or a unique identifier, respectively. + * The supplied values are chosen so that, among the log entries that did not + * supply their own values, the entries earlier in the list will sort before + * the entries later in the list. See the `entries.list` method. + * + * Log entries with timestamps that are more than the + * [logs retention period](/logging/quota-policy) in the past or more than + * 24 hours in the future will not be available when calling `entries.list`. + * However, those log entries can still be + * [exported with LogSinks](/logging/docs/api/tasks/exporting-logs). + * + * To improve throughput and to avoid exceeding the + * [quota limit](/logging/quota-policy) for calls to `entries.write`, + * you should try to include several log entries in this list, + * rather than calling this method for each individual log entry. + * @param {boolean} [request.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, then the response status is the error associated + * with one of the failed entries and the response includes error details + * keyed by the entries' zero-based index in the `entries.write` method. + * @param {boolean} [request.dryRun] + * Optional. If true, the request should expect normal response, but the + * entries won't be persisted nor exported. Useful for checking whether the + * logging API endpoints are working properly before sending valuable data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [WriteLogEntriesResponse]{@link google.logging.v2.WriteLogEntriesResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + writeLogEntries( + request: protosTypes.google.logging.v2.IWriteLogEntriesRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.logging.v2.IWriteLogEntriesResponse, + protosTypes.google.logging.v2.IWriteLogEntriesRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.logging.v2.IWriteLogEntriesResponse, + protosTypes.google.logging.v2.IWriteLogEntriesRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.logging.v2.IWriteLogEntriesResponse, + protosTypes.google.logging.v2.IWriteLogEntriesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + this.initialize(); + return this._innerApiCalls.writeLogEntries(request, options, callback); + } + + listLogEntries( + request: protosTypes.google.logging.v2.IListLogEntriesRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.logging.v2.ILogEntry[], + protosTypes.google.logging.v2.IListLogEntriesRequest|null, + protosTypes.google.logging.v2.IListLogEntriesResponse + ]>; + listLogEntries( + request: protosTypes.google.logging.v2.IListLogEntriesRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.logging.v2.ILogEntry[], + protosTypes.google.logging.v2.IListLogEntriesRequest|null, + protosTypes.google.logging.v2.IListLogEntriesResponse>): void; +/** + * Lists log entries. Use this method to retrieve log entries that originated + * from a project/folder/organization/billing account. For ways to export log + * entries, see [Exporting Logs](/logging/docs/export). + * + * @param {Object} request + * The request object that will be sent. + * @param {string[]} request.resourceNames + * Required. Names of one or more parent resources from which to + * retrieve log entries: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * + * + * Projects listed in the `project_ids` field are added to this list. + * @param {string} [request.filter] + * Optional. A filter that chooses which log entries to return. See [Advanced + * Logs Queries](/logging/docs/view/advanced-queries). Only log entries that + * match the filter are returned. An empty filter matches all log entries in + * the resources listed in `resource_names`. Referencing a parent resource + * that is not listed in `resource_names` will cause the filter to return no + * results. + * The maximum length of the filter is 20000 characters. + * @param {string} [request.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 their `insert_id` values. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `next_page_token` in the + * response indicates that more results might be available. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `page_token` must be the value of + * `next_page_token` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [LogEntry]{@link google.logging.v2.LogEntry}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [LogEntry]{@link google.logging.v2.LogEntry} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListLogEntriesRequest]{@link google.logging.v2.ListLogEntriesRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListLogEntriesResponse]{@link google.logging.v2.ListLogEntriesResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listLogEntries( + request: protosTypes.google.logging.v2.IListLogEntriesRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.logging.v2.ILogEntry[], + protosTypes.google.logging.v2.IListLogEntriesRequest|null, + protosTypes.google.logging.v2.IListLogEntriesResponse>, + callback?: Callback< + protosTypes.google.logging.v2.ILogEntry[], + protosTypes.google.logging.v2.IListLogEntriesRequest|null, + protosTypes.google.logging.v2.IListLogEntriesResponse>): + Promise<[ + protosTypes.google.logging.v2.ILogEntry[], + protosTypes.google.logging.v2.IListLogEntriesRequest|null, + protosTypes.google.logging.v2.IListLogEntriesResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + this.initialize(); + return this._innerApiCalls.listLogEntries(request, options, callback); + } + +/** + * Equivalent to {@link listLogEntries}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listLogEntries} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string[]} request.resourceNames + * Required. Names of one or more parent resources from which to + * retrieve log entries: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * + * + * Projects listed in the `project_ids` field are added to this list. + * @param {string} [request.filter] + * Optional. A filter that chooses which log entries to return. See [Advanced + * Logs Queries](/logging/docs/view/advanced-queries). Only log entries that + * match the filter are returned. An empty filter matches all log entries in + * the resources listed in `resource_names`. Referencing a parent resource + * that is not listed in `resource_names` will cause the filter to return no + * results. + * The maximum length of the filter is 20000 characters. + * @param {string} [request.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 their `insert_id` values. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `next_page_token` in the + * response indicates that more results might be available. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `page_token` must be the value of + * `next_page_token` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [LogEntry]{@link google.logging.v2.LogEntry} on 'data' event. + */ + listLogEntriesStream( + request?: protosTypes.google.logging.v2.IListLogEntriesRequest, + options?: gax.CallOptions): + Transform{ + request = request || {}; + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this._descriptors.page.listLogEntries.createStream( + this._innerApiCalls.listLogEntries as gax.GaxCall, + request, + callSettings + ); + } + listMonitoredResourceDescriptors( + request: protosTypes.google.logging.v2.IListMonitoredResourceDescriptorsRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.api.IMonitoredResourceDescriptor[], + protosTypes.google.logging.v2.IListMonitoredResourceDescriptorsRequest|null, + protosTypes.google.logging.v2.IListMonitoredResourceDescriptorsResponse + ]>; + listMonitoredResourceDescriptors( + request: protosTypes.google.logging.v2.IListMonitoredResourceDescriptorsRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.api.IMonitoredResourceDescriptor[], + protosTypes.google.logging.v2.IListMonitoredResourceDescriptorsRequest|null, + protosTypes.google.logging.v2.IListMonitoredResourceDescriptorsResponse>): void; +/** + * Lists the descriptors for monitored resource types used by Logging. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListMonitoredResourceDescriptorsRequest]{@link google.logging.v2.ListMonitoredResourceDescriptorsRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListMonitoredResourceDescriptorsResponse]{@link google.logging.v2.ListMonitoredResourceDescriptorsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listMonitoredResourceDescriptors( + request: protosTypes.google.logging.v2.IListMonitoredResourceDescriptorsRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.api.IMonitoredResourceDescriptor[], + protosTypes.google.logging.v2.IListMonitoredResourceDescriptorsRequest|null, + protosTypes.google.logging.v2.IListMonitoredResourceDescriptorsResponse>, + callback?: Callback< + protosTypes.google.api.IMonitoredResourceDescriptor[], + protosTypes.google.logging.v2.IListMonitoredResourceDescriptorsRequest|null, + protosTypes.google.logging.v2.IListMonitoredResourceDescriptorsResponse>): + Promise<[ + protosTypes.google.api.IMonitoredResourceDescriptor[], + protosTypes.google.logging.v2.IListMonitoredResourceDescriptorsRequest|null, + protosTypes.google.logging.v2.IListMonitoredResourceDescriptorsResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + this.initialize(); + return this._innerApiCalls.listMonitoredResourceDescriptors(request, options, callback); + } + +/** + * Equivalent to {@link listMonitoredResourceDescriptors}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listMonitoredResourceDescriptors} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor} on 'data' event. + */ + listMonitoredResourceDescriptorsStream( + request?: protosTypes.google.logging.v2.IListMonitoredResourceDescriptorsRequest, + options?: gax.CallOptions): + Transform{ + request = request || {}; + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this._descriptors.page.listMonitoredResourceDescriptors.createStream( + this._innerApiCalls.listMonitoredResourceDescriptors as gax.GaxCall, + request, + callSettings + ); + } + listLogs( + request: protosTypes.google.logging.v2.IListLogsRequest, + options?: gax.CallOptions): + Promise<[ + string[], + protosTypes.google.logging.v2.IListLogsRequest|null, + protosTypes.google.logging.v2.IListLogsResponse + ]>; + listLogs( + request: protosTypes.google.logging.v2.IListLogsRequest, + options: gax.CallOptions, + callback: Callback< + string[], + protosTypes.google.logging.v2.IListLogsRequest|null, + protosTypes.google.logging.v2.IListLogsResponse>): void; +/** + * Lists the logs in projects, organizations, folders, or billing accounts. + * Only logs that have entries are listed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name that owns the logs: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of string. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of string that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListLogsRequest]{@link google.logging.v2.ListLogsRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListLogsResponse]{@link google.logging.v2.ListLogsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listLogs( + request: protosTypes.google.logging.v2.IListLogsRequest, + optionsOrCallback?: gax.CallOptions|Callback< + string[], + protosTypes.google.logging.v2.IListLogsRequest|null, + protosTypes.google.logging.v2.IListLogsResponse>, + callback?: Callback< + string[], + protosTypes.google.logging.v2.IListLogsRequest|null, + protosTypes.google.logging.v2.IListLogsResponse>): + Promise<[ + string[], + protosTypes.google.logging.v2.IListLogsRequest|null, + protosTypes.google.logging.v2.IListLogsResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this._innerApiCalls.listLogs(request, options, callback); + } + +/** + * Equivalent to {@link listLogs}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listLogs} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name that owns the logs: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing string on 'data' event. + */ + listLogsStream( + request?: protosTypes.google.logging.v2.IListLogsRequest, + options?: gax.CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this._descriptors.page.listLogs.createStream( + this._innerApiCalls.listLogs as gax.GaxCall, + request, + callSettings + ); + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified billingAccountCmekSettings resource name string. + * + * @param {string} billing_account + * @returns {string} Resource name string. + */ + billingAccountCmekSettingsPath(billingAccount:string) { + return this._pathTemplates.billingAccountCmekSettingsPathTemplate.render({ + billing_account: billingAccount, + }); + } + + /** + * Parse the billing_account from BillingAccountCmekSettings resource. + * + * @param {string} billingAccountCmekSettingsName + * A fully-qualified path representing billing_account_cmekSettings resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountCmekSettingsName(billingAccountCmekSettingsName: string) { + return this._pathTemplates.billingAccountCmekSettingsPathTemplate.match(billingAccountCmekSettingsName).billing_account; + } + + /** + * Return a fully-qualified billingAccountExclusion resource name string. + * + * @param {string} billing_account + * @param {string} exclusion + * @returns {string} Resource name string. + */ + billingAccountExclusionPath(billingAccount:string,exclusion:string) { + return this._pathTemplates.billingAccountExclusionPathTemplate.render({ + billing_account: billingAccount, + exclusion: exclusion, + }); + } + + /** + * Parse the billing_account from BillingAccountExclusion resource. + * + * @param {string} billingAccountExclusionName + * A fully-qualified path representing billing_account_exclusion resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountExclusionName(billingAccountExclusionName: string) { + return this._pathTemplates.billingAccountExclusionPathTemplate.match(billingAccountExclusionName).billing_account; + } + + /** + * Parse the exclusion from BillingAccountExclusion resource. + * + * @param {string} billingAccountExclusionName + * A fully-qualified path representing billing_account_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromBillingAccountExclusionName(billingAccountExclusionName: string) { + return this._pathTemplates.billingAccountExclusionPathTemplate.match(billingAccountExclusionName).exclusion; + } + + /** + * Return a fully-qualified billingAccountLocationBucket resource name string. + * + * @param {string} billing_account + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + billingAccountLocationBucketPath(billingAccount:string,location:string,bucket:string) { + return this._pathTemplates.billingAccountLocationBucketPathTemplate.render({ + billing_account: billingAccount, + location: location, + bucket: bucket, + }); + } + + /** + * Parse the billing_account from BillingAccountLocationBucket resource. + * + * @param {string} billingAccountLocationBucketName + * A fully-qualified path representing billing_account_location_bucket resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountLocationBucketName(billingAccountLocationBucketName: string) { + return this._pathTemplates.billingAccountLocationBucketPathTemplate.match(billingAccountLocationBucketName).billing_account; + } + + /** + * Parse the location from BillingAccountLocationBucket resource. + * + * @param {string} billingAccountLocationBucketName + * A fully-qualified path representing billing_account_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBillingAccountLocationBucketName(billingAccountLocationBucketName: string) { + return this._pathTemplates.billingAccountLocationBucketPathTemplate.match(billingAccountLocationBucketName).location; + } + + /** + * Parse the bucket from BillingAccountLocationBucket resource. + * + * @param {string} billingAccountLocationBucketName + * A fully-qualified path representing billing_account_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromBillingAccountLocationBucketName(billingAccountLocationBucketName: string) { + return this._pathTemplates.billingAccountLocationBucketPathTemplate.match(billingAccountLocationBucketName).bucket; + } + + /** + * Return a fully-qualified billingAccountLog resource name string. + * + * @param {string} billing_account + * @param {string} log + * @returns {string} Resource name string. + */ + billingAccountLogPath(billingAccount:string,log:string) { + return this._pathTemplates.billingAccountLogPathTemplate.render({ + billing_account: billingAccount, + log: log, + }); + } + + /** + * Parse the billing_account from BillingAccountLog resource. + * + * @param {string} billingAccountLogName + * A fully-qualified path representing billing_account_log resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountLogName(billingAccountLogName: string) { + return this._pathTemplates.billingAccountLogPathTemplate.match(billingAccountLogName).billing_account; + } + + /** + * Parse the log from BillingAccountLog resource. + * + * @param {string} billingAccountLogName + * A fully-qualified path representing billing_account_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromBillingAccountLogName(billingAccountLogName: string) { + return this._pathTemplates.billingAccountLogPathTemplate.match(billingAccountLogName).log; + } + + /** + * Return a fully-qualified billingAccountSink resource name string. + * + * @param {string} billing_account + * @param {string} sink + * @returns {string} Resource name string. + */ + billingAccountSinkPath(billingAccount:string,sink:string) { + return this._pathTemplates.billingAccountSinkPathTemplate.render({ + billing_account: billingAccount, + sink: sink, + }); + } + + /** + * Parse the billing_account from BillingAccountSink resource. + * + * @param {string} billingAccountSinkName + * A fully-qualified path representing billing_account_sink resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountSinkName(billingAccountSinkName: string) { + return this._pathTemplates.billingAccountSinkPathTemplate.match(billingAccountSinkName).billing_account; + } + + /** + * Parse the sink from BillingAccountSink resource. + * + * @param {string} billingAccountSinkName + * A fully-qualified path representing billing_account_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromBillingAccountSinkName(billingAccountSinkName: string) { + return this._pathTemplates.billingAccountSinkPathTemplate.match(billingAccountSinkName).sink; + } + + /** + * Return a fully-qualified folderCmekSettings resource name string. + * + * @param {string} folder + * @returns {string} Resource name string. + */ + folderCmekSettingsPath(folder:string) { + return this._pathTemplates.folderCmekSettingsPathTemplate.render({ + folder: folder, + }); + } + + /** + * Parse the folder from FolderCmekSettings resource. + * + * @param {string} folderCmekSettingsName + * A fully-qualified path representing folder_cmekSettings resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderCmekSettingsName(folderCmekSettingsName: string) { + return this._pathTemplates.folderCmekSettingsPathTemplate.match(folderCmekSettingsName).folder; + } + + /** + * Return a fully-qualified folderExclusion resource name string. + * + * @param {string} folder + * @param {string} exclusion + * @returns {string} Resource name string. + */ + folderExclusionPath(folder:string,exclusion:string) { + return this._pathTemplates.folderExclusionPathTemplate.render({ + folder: folder, + exclusion: exclusion, + }); + } + + /** + * Parse the folder from FolderExclusion resource. + * + * @param {string} folderExclusionName + * A fully-qualified path representing folder_exclusion resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderExclusionName(folderExclusionName: string) { + return this._pathTemplates.folderExclusionPathTemplate.match(folderExclusionName).folder; + } + + /** + * Parse the exclusion from FolderExclusion resource. + * + * @param {string} folderExclusionName + * A fully-qualified path representing folder_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromFolderExclusionName(folderExclusionName: string) { + return this._pathTemplates.folderExclusionPathTemplate.match(folderExclusionName).exclusion; + } + + /** + * Return a fully-qualified folderLocationBucket resource name string. + * + * @param {string} folder + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + folderLocationBucketPath(folder:string,location:string,bucket:string) { + return this._pathTemplates.folderLocationBucketPathTemplate.render({ + folder: folder, + location: location, + bucket: bucket, + }); + } + + /** + * Parse the folder from FolderLocationBucket resource. + * + * @param {string} folderLocationBucketName + * A fully-qualified path representing folder_location_bucket resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderLocationBucketName(folderLocationBucketName: string) { + return this._pathTemplates.folderLocationBucketPathTemplate.match(folderLocationBucketName).folder; + } + + /** + * Parse the location from FolderLocationBucket resource. + * + * @param {string} folderLocationBucketName + * A fully-qualified path representing folder_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromFolderLocationBucketName(folderLocationBucketName: string) { + return this._pathTemplates.folderLocationBucketPathTemplate.match(folderLocationBucketName).location; + } + + /** + * Parse the bucket from FolderLocationBucket resource. + * + * @param {string} folderLocationBucketName + * A fully-qualified path representing folder_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromFolderLocationBucketName(folderLocationBucketName: string) { + return this._pathTemplates.folderLocationBucketPathTemplate.match(folderLocationBucketName).bucket; + } + + /** + * Return a fully-qualified folderLog resource name string. + * + * @param {string} folder + * @param {string} log + * @returns {string} Resource name string. + */ + folderLogPath(folder:string,log:string) { + return this._pathTemplates.folderLogPathTemplate.render({ + folder: folder, + log: log, + }); + } + + /** + * Parse the folder from FolderLog resource. + * + * @param {string} folderLogName + * A fully-qualified path representing folder_log resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderLogName(folderLogName: string) { + return this._pathTemplates.folderLogPathTemplate.match(folderLogName).folder; + } + + /** + * Parse the log from FolderLog resource. + * + * @param {string} folderLogName + * A fully-qualified path representing folder_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromFolderLogName(folderLogName: string) { + return this._pathTemplates.folderLogPathTemplate.match(folderLogName).log; + } + + /** + * Return a fully-qualified folderSink resource name string. + * + * @param {string} folder + * @param {string} sink + * @returns {string} Resource name string. + */ + folderSinkPath(folder:string,sink:string) { + return this._pathTemplates.folderSinkPathTemplate.render({ + folder: folder, + sink: sink, + }); + } + + /** + * Parse the folder from FolderSink resource. + * + * @param {string} folderSinkName + * A fully-qualified path representing folder_sink resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderSinkName(folderSinkName: string) { + return this._pathTemplates.folderSinkPathTemplate.match(folderSinkName).folder; + } + + /** + * Parse the sink from FolderSink resource. + * + * @param {string} folderSinkName + * A fully-qualified path representing folder_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromFolderSinkName(folderSinkName: string) { + return this._pathTemplates.folderSinkPathTemplate.match(folderSinkName).sink; + } + + /** + * Return a fully-qualified logMetric resource name string. + * + * @param {string} project + * @param {string} metric + * @returns {string} Resource name string. + */ + logMetricPath(project:string,metric:string) { + return this._pathTemplates.logMetricPathTemplate.render({ + project: project, + metric: metric, + }); + } + + /** + * Parse the project from LogMetric resource. + * + * @param {string} logMetricName + * A fully-qualified path representing LogMetric resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLogMetricName(logMetricName: string) { + return this._pathTemplates.logMetricPathTemplate.match(logMetricName).project; + } + + /** + * Parse the metric from LogMetric resource. + * + * @param {string} logMetricName + * A fully-qualified path representing LogMetric resource. + * @returns {string} A string representing the metric. + */ + matchMetricFromLogMetricName(logMetricName: string) { + return this._pathTemplates.logMetricPathTemplate.match(logMetricName).metric; + } + + /** + * Return a fully-qualified organizationCmekSettings resource name string. + * + * @param {string} organization + * @returns {string} Resource name string. + */ + organizationCmekSettingsPath(organization:string) { + return this._pathTemplates.organizationCmekSettingsPathTemplate.render({ + organization: organization, + }); + } + + /** + * Parse the organization from OrganizationCmekSettings resource. + * + * @param {string} organizationCmekSettingsName + * A fully-qualified path representing organization_cmekSettings resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationCmekSettingsName(organizationCmekSettingsName: string) { + return this._pathTemplates.organizationCmekSettingsPathTemplate.match(organizationCmekSettingsName).organization; + } + + /** + * Return a fully-qualified organizationExclusion resource name string. + * + * @param {string} organization + * @param {string} exclusion + * @returns {string} Resource name string. + */ + organizationExclusionPath(organization:string,exclusion:string) { + return this._pathTemplates.organizationExclusionPathTemplate.render({ + organization: organization, + exclusion: exclusion, + }); + } + + /** + * Parse the organization from OrganizationExclusion resource. + * + * @param {string} organizationExclusionName + * A fully-qualified path representing organization_exclusion resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationExclusionName(organizationExclusionName: string) { + return this._pathTemplates.organizationExclusionPathTemplate.match(organizationExclusionName).organization; + } + + /** + * Parse the exclusion from OrganizationExclusion resource. + * + * @param {string} organizationExclusionName + * A fully-qualified path representing organization_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromOrganizationExclusionName(organizationExclusionName: string) { + return this._pathTemplates.organizationExclusionPathTemplate.match(organizationExclusionName).exclusion; + } + + /** + * Return a fully-qualified organizationLocationBucket resource name string. + * + * @param {string} organization + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + organizationLocationBucketPath(organization:string,location:string,bucket:string) { + return this._pathTemplates.organizationLocationBucketPathTemplate.render({ + organization: organization, + location: location, + bucket: bucket, + }); + } + + /** + * Parse the organization from OrganizationLocationBucket resource. + * + * @param {string} organizationLocationBucketName + * A fully-qualified path representing organization_location_bucket resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLocationBucketName(organizationLocationBucketName: string) { + return this._pathTemplates.organizationLocationBucketPathTemplate.match(organizationLocationBucketName).organization; + } + + /** + * Parse the location from OrganizationLocationBucket resource. + * + * @param {string} organizationLocationBucketName + * A fully-qualified path representing organization_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOrganizationLocationBucketName(organizationLocationBucketName: string) { + return this._pathTemplates.organizationLocationBucketPathTemplate.match(organizationLocationBucketName).location; + } + + /** + * Parse the bucket from OrganizationLocationBucket resource. + * + * @param {string} organizationLocationBucketName + * A fully-qualified path representing organization_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromOrganizationLocationBucketName(organizationLocationBucketName: string) { + return this._pathTemplates.organizationLocationBucketPathTemplate.match(organizationLocationBucketName).bucket; + } + + /** + * Return a fully-qualified organizationLog resource name string. + * + * @param {string} organization + * @param {string} log + * @returns {string} Resource name string. + */ + organizationLogPath(organization:string,log:string) { + return this._pathTemplates.organizationLogPathTemplate.render({ + organization: organization, + log: log, + }); + } + + /** + * Parse the organization from OrganizationLog resource. + * + * @param {string} organizationLogName + * A fully-qualified path representing organization_log resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLogName(organizationLogName: string) { + return this._pathTemplates.organizationLogPathTemplate.match(organizationLogName).organization; + } + + /** + * Parse the log from OrganizationLog resource. + * + * @param {string} organizationLogName + * A fully-qualified path representing organization_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromOrganizationLogName(organizationLogName: string) { + return this._pathTemplates.organizationLogPathTemplate.match(organizationLogName).log; + } + + /** + * Return a fully-qualified organizationSink resource name string. + * + * @param {string} organization + * @param {string} sink + * @returns {string} Resource name string. + */ + organizationSinkPath(organization:string,sink:string) { + return this._pathTemplates.organizationSinkPathTemplate.render({ + organization: organization, + sink: sink, + }); + } + + /** + * Parse the organization from OrganizationSink resource. + * + * @param {string} organizationSinkName + * A fully-qualified path representing organization_sink resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationSinkName(organizationSinkName: string) { + return this._pathTemplates.organizationSinkPathTemplate.match(organizationSinkName).organization; + } + + /** + * Parse the sink from OrganizationSink resource. + * + * @param {string} organizationSinkName + * A fully-qualified path representing organization_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromOrganizationSinkName(organizationSinkName: string) { + return this._pathTemplates.organizationSinkPathTemplate.match(organizationSinkName).sink; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this._pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this._pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified projectCmekSettings resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectCmekSettingsPath(project:string) { + return this._pathTemplates.projectCmekSettingsPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from ProjectCmekSettings resource. + * + * @param {string} projectCmekSettingsName + * A fully-qualified path representing project_cmekSettings resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectCmekSettingsName(projectCmekSettingsName: string) { + return this._pathTemplates.projectCmekSettingsPathTemplate.match(projectCmekSettingsName).project; + } + + /** + * Return a fully-qualified projectExclusion resource name string. + * + * @param {string} project + * @param {string} exclusion + * @returns {string} Resource name string. + */ + projectExclusionPath(project:string,exclusion:string) { + return this._pathTemplates.projectExclusionPathTemplate.render({ + project: project, + exclusion: exclusion, + }); + } + + /** + * Parse the project from ProjectExclusion resource. + * + * @param {string} projectExclusionName + * A fully-qualified path representing project_exclusion resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectExclusionName(projectExclusionName: string) { + return this._pathTemplates.projectExclusionPathTemplate.match(projectExclusionName).project; + } + + /** + * Parse the exclusion from ProjectExclusion resource. + * + * @param {string} projectExclusionName + * A fully-qualified path representing project_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromProjectExclusionName(projectExclusionName: string) { + return this._pathTemplates.projectExclusionPathTemplate.match(projectExclusionName).exclusion; + } + + /** + * Return a fully-qualified projectLocationBucket resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + projectLocationBucketPath(project:string,location:string,bucket:string) { + return this._pathTemplates.projectLocationBucketPathTemplate.render({ + project: project, + location: location, + bucket: bucket, + }); + } + + /** + * Parse the project from ProjectLocationBucket resource. + * + * @param {string} projectLocationBucketName + * A fully-qualified path representing project_location_bucket resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationBucketName(projectLocationBucketName: string) { + return this._pathTemplates.projectLocationBucketPathTemplate.match(projectLocationBucketName).project; + } + + /** + * Parse the location from ProjectLocationBucket resource. + * + * @param {string} projectLocationBucketName + * A fully-qualified path representing project_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationBucketName(projectLocationBucketName: string) { + return this._pathTemplates.projectLocationBucketPathTemplate.match(projectLocationBucketName).location; + } + + /** + * Parse the bucket from ProjectLocationBucket resource. + * + * @param {string} projectLocationBucketName + * A fully-qualified path representing project_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromProjectLocationBucketName(projectLocationBucketName: string) { + return this._pathTemplates.projectLocationBucketPathTemplate.match(projectLocationBucketName).bucket; + } + + /** + * Return a fully-qualified projectLog resource name string. + * + * @param {string} project + * @param {string} log + * @returns {string} Resource name string. + */ + projectLogPath(project:string,log:string) { + return this._pathTemplates.projectLogPathTemplate.render({ + project: project, + log: log, + }); + } + + /** + * Parse the project from ProjectLog resource. + * + * @param {string} projectLogName + * A fully-qualified path representing project_log resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLogName(projectLogName: string) { + return this._pathTemplates.projectLogPathTemplate.match(projectLogName).project; + } + + /** + * Parse the log from ProjectLog resource. + * + * @param {string} projectLogName + * A fully-qualified path representing project_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromProjectLogName(projectLogName: string) { + return this._pathTemplates.projectLogPathTemplate.match(projectLogName).log; + } + + /** + * Return a fully-qualified projectSink resource name string. + * + * @param {string} project + * @param {string} sink + * @returns {string} Resource name string. + */ + projectSinkPath(project:string,sink:string) { + return this._pathTemplates.projectSinkPathTemplate.render({ + project: project, + sink: sink, + }); + } + + /** + * Parse the project from ProjectSink resource. + * + * @param {string} projectSinkName + * A fully-qualified path representing project_sink resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectSinkName(projectSinkName: string) { + return this._pathTemplates.projectSinkPathTemplate.match(projectSinkName).project; + } + + /** + * Parse the sink from ProjectSink resource. + * + * @param {string} projectSinkName + * A fully-qualified path representing project_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromProjectSinkName(projectSinkName: string) { + return this._pathTemplates.projectSinkPathTemplate.match(projectSinkName).sink; + } + + /** + * Terminate the GRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + */ + close(): Promise { + this.initialize(); + if (!this._terminated) { + return this.loggingServiceV2Stub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/baselines/logging/src/v2/logging_service_v2_client_config.json.baseline b/baselines/logging/src/v2/logging_service_v2_client_config.json.baseline new file mode 100644 index 000000000..12ab7c53b --- /dev/null +++ b/baselines/logging/src/v2/logging_service_v2_client_config.json.baseline @@ -0,0 +1,52 @@ +{ + "interfaces": { + "google.logging.v2.LoggingServiceV2": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "DeleteLog": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "WriteLogEntries": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default", + "bundling": { + "element_count_threshold": 1000, + "request_byte_threshold": 1048576, + "delay_threshold_millis": 50, + "element_count_limit": 1000000 + } + }, + "ListLogEntries": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListMonitoredResourceDescriptors": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListLogs": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/baselines/logging/src/v2/logging_service_v2_proto_list.json.baseline b/baselines/logging/src/v2/logging_service_v2_proto_list.json.baseline new file mode 100644 index 000000000..3103c1e58 --- /dev/null +++ b/baselines/logging/src/v2/logging_service_v2_proto_list.json.baseline @@ -0,0 +1,6 @@ +[ + "../../protos/google/logging/v2/log_entry.proto", + "../../protos/google/logging/v2/logging.proto", + "../../protos/google/logging/v2/logging_config.proto", + "../../protos/google/logging/v2/logging_metrics.proto" +] diff --git a/baselines/logging/src/v2/metrics_service_v2_client.ts.baseline b/baselines/logging/src/v2/metrics_service_v2_client.ts.baseline new file mode 100644 index 000000000..de193c6fd --- /dev/null +++ b/baselines/logging/src/v2/metrics_service_v2_client.ts.baseline @@ -0,0 +1,1544 @@ +// Copyright 2020 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as gax from 'google-gax'; +import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, PaginationResponse} from 'google-gax'; +import * as path from 'path'; + +import { Transform } from 'stream'; +import * as protosTypes from '../../protos/protos'; +import * as gapicConfig from './metrics_service_v2_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for configuring logs-based metrics. + * @class + * @memberof v2 + */ +export class MetricsServiceV2Client { + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; + private _innerApiCalls: {[name: string]: Function}; + private _pathTemplates: {[name: string]: gax.PathTemplate}; + private _terminated = false; + private _opts: ClientOptions; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + metricsServiceV2Stub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of MetricsServiceV2Client. + * + * @param {object} [options] - The configuration object. See the subsequent + * parameters for more details. + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + */ + + constructor(opts?: ClientOptions) { + // Ensure that options include the service address and port. + const staticMembers = this.constructor as typeof MetricsServiceV2Client; + const servicePath = opts && opts.servicePath ? + opts.servicePath : + ((opts && opts.apiEndpoint) ? opts.apiEndpoint : + staticMembers.servicePath); + const port = opts && opts.port ? opts.port : staticMembers.port; + + if (!opts) { + opts = {servicePath, port}; + } + opts.servicePath = opts.servicePath || servicePath; + opts.port = opts.port || port; + opts.clientConfig = opts.clientConfig || {}; + + const isBrowser = (typeof window !== 'undefined'); + if (isBrowser){ + opts.fallback = true; + } + // If we are in browser, we are already using fallback because of the + // "browser" field in package.json. + // But if we were explicitly requested to use fallback, let's do it now. + this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options + // sent to the client. + opts.scopes = (this.constructor as typeof MetricsServiceV2Client).scopes; + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + + const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); + this._protos = this._gaxGrpc.loadProto( + opts.fallback ? + require("../../protos/protos.json") : + nodejsProtoPath + ); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this._pathTemplates = { + billingAccountCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/cmekSettings' + ), + billingAccountExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/exclusions/{exclusion}' + ), + billingAccountLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}' + ), + billingAccountLogPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/logs/{log}' + ), + billingAccountSinkPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/sinks/{sink}' + ), + folderCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/cmekSettings' + ), + folderExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/exclusions/{exclusion}' + ), + folderLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/locations/{location}/buckets/{bucket}' + ), + folderLogPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/logs/{log}' + ), + folderSinkPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/sinks/{sink}' + ), + logMetricPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/metrics/{metric}' + ), + organizationCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/cmekSettings' + ), + organizationExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/exclusions/{exclusion}' + ), + organizationLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/buckets/{bucket}' + ), + organizationLogPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/logs/{log}' + ), + organizationSinkPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/sinks/{sink}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + projectCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/cmekSettings' + ), + projectExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/exclusions/{exclusion}' + ), + projectLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/buckets/{bucket}' + ), + projectLogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/logs/{log}' + ), + projectSinkPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/sinks/{sink}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this._descriptors.page = { + listLogMetrics: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'metrics') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.logging.v2.MetricsServiceV2', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this._innerApiCalls = {}; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.metricsServiceV2Stub) { + return this.metricsServiceV2Stub; + } + + // Put together the "service stub" for + // google.logging.v2.MetricsServiceV2. + this.metricsServiceV2Stub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.logging.v2.MetricsServiceV2') : + // tslint:disable-next-line no-any + (this._protos as any).google.logging.v2.MetricsServiceV2, + this._opts) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const metricsServiceV2StubMethods = + ['listLogMetrics', 'getLogMetric', 'createLogMetric', 'updateLogMetric', 'deleteLogMetric']; + + for (const methodName of metricsServiceV2StubMethods) { + const innerCallPromise = this.metricsServiceV2Stub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + return stub[methodName].apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const apiCall = this._gaxModule.createApiCall( + innerCallPromise, + this._defaults[methodName], + this._descriptors.page[methodName] || + this._descriptors.stream[methodName] || + this._descriptors.longrunning[methodName] + ); + + this._innerApiCalls[methodName] = ( + argument: {}, + callOptions?: CallOptions, + callback?: APICallback + ) => { + return apiCall(argument, callOptions, callback); + }; + } + + return this.metricsServiceV2Stub; + } + + /** + * The DNS address for this API service. + */ + static get servicePath() { + return 'logging.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'logging.googleapis.com'; + } + + /** + * The port for this API service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + */ + static get scopes() { + return [ + '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' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @param {function(Error, string)} callback - the callback to + * be called with the current project Id. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + getLogMetric( + request: protosTypes.google.logging.v2.IGetLogMetricRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.logging.v2.ILogMetric, + protosTypes.google.logging.v2.IGetLogMetricRequest|undefined, {}|undefined + ]>; + getLogMetric( + request: protosTypes.google.logging.v2.IGetLogMetricRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.logging.v2.ILogMetric, + protosTypes.google.logging.v2.IGetLogMetricRequest|undefined, + {}|undefined>): void; +/** + * Gets a logs-based metric. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.metricName + * Required. The resource name of the desired metric: + * + * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LogMetric]{@link google.logging.v2.LogMetric}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getLogMetric( + request: protosTypes.google.logging.v2.IGetLogMetricRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.logging.v2.ILogMetric, + protosTypes.google.logging.v2.IGetLogMetricRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.logging.v2.ILogMetric, + protosTypes.google.logging.v2.IGetLogMetricRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.logging.v2.ILogMetric, + protosTypes.google.logging.v2.IGetLogMetricRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'metric_name': request.metricName || '', + }); + this.initialize(); + return this._innerApiCalls.getLogMetric(request, options, callback); + } + createLogMetric( + request: protosTypes.google.logging.v2.ICreateLogMetricRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.logging.v2.ILogMetric, + protosTypes.google.logging.v2.ICreateLogMetricRequest|undefined, {}|undefined + ]>; + createLogMetric( + request: protosTypes.google.logging.v2.ICreateLogMetricRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.logging.v2.ILogMetric, + protosTypes.google.logging.v2.ICreateLogMetricRequest|undefined, + {}|undefined>): void; +/** + * Creates a logs-based metric. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the project in which to create the metric: + * + * "projects/[PROJECT_ID]" + * + * The new metric must be provided in the request. + * @param {google.logging.v2.LogMetric} request.metric + * Required. The new logs-based metric, which must not have an identifier that + * already exists. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LogMetric]{@link google.logging.v2.LogMetric}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + createLogMetric( + request: protosTypes.google.logging.v2.ICreateLogMetricRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.logging.v2.ILogMetric, + protosTypes.google.logging.v2.ICreateLogMetricRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.logging.v2.ILogMetric, + protosTypes.google.logging.v2.ICreateLogMetricRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.logging.v2.ILogMetric, + protosTypes.google.logging.v2.ICreateLogMetricRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this._innerApiCalls.createLogMetric(request, options, callback); + } + updateLogMetric( + request: protosTypes.google.logging.v2.IUpdateLogMetricRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.logging.v2.ILogMetric, + protosTypes.google.logging.v2.IUpdateLogMetricRequest|undefined, {}|undefined + ]>; + updateLogMetric( + request: protosTypes.google.logging.v2.IUpdateLogMetricRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.logging.v2.ILogMetric, + protosTypes.google.logging.v2.IUpdateLogMetricRequest|undefined, + {}|undefined>): void; +/** + * Creates or updates a logs-based metric. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.metricName + * Required. The resource name of the metric to update: + * + * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" + * + * The updated metric must be provided in the request and it's + * `name` field must be the same as `[METRIC_ID]` If the metric + * does not exist in `[PROJECT_ID]`, then a new metric is created. + * @param {google.logging.v2.LogMetric} request.metric + * Required. The updated metric. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LogMetric]{@link google.logging.v2.LogMetric}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + updateLogMetric( + request: protosTypes.google.logging.v2.IUpdateLogMetricRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.logging.v2.ILogMetric, + protosTypes.google.logging.v2.IUpdateLogMetricRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.logging.v2.ILogMetric, + protosTypes.google.logging.v2.IUpdateLogMetricRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.logging.v2.ILogMetric, + protosTypes.google.logging.v2.IUpdateLogMetricRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'metric_name': request.metricName || '', + }); + this.initialize(); + return this._innerApiCalls.updateLogMetric(request, options, callback); + } + deleteLogMetric( + request: protosTypes.google.logging.v2.IDeleteLogMetricRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.logging.v2.IDeleteLogMetricRequest|undefined, {}|undefined + ]>; + deleteLogMetric( + request: protosTypes.google.logging.v2.IDeleteLogMetricRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.logging.v2.IDeleteLogMetricRequest|undefined, + {}|undefined>): void; +/** + * Deletes a logs-based metric. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.metricName + * Required. The resource name of the metric to delete: + * + * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + deleteLogMetric( + request: protosTypes.google.logging.v2.IDeleteLogMetricRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.logging.v2.IDeleteLogMetricRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.logging.v2.IDeleteLogMetricRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.logging.v2.IDeleteLogMetricRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'metric_name': request.metricName || '', + }); + this.initialize(); + return this._innerApiCalls.deleteLogMetric(request, options, callback); + } + + listLogMetrics( + request: protosTypes.google.logging.v2.IListLogMetricsRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.logging.v2.ILogMetric[], + protosTypes.google.logging.v2.IListLogMetricsRequest|null, + protosTypes.google.logging.v2.IListLogMetricsResponse + ]>; + listLogMetrics( + request: protosTypes.google.logging.v2.IListLogMetricsRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.logging.v2.ILogMetric[], + protosTypes.google.logging.v2.IListLogMetricsRequest|null, + protosTypes.google.logging.v2.IListLogMetricsResponse>): void; +/** + * Lists logs-based metrics. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project containing the metrics: + * + * "projects/[PROJECT_ID]" + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [LogMetric]{@link google.logging.v2.LogMetric}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [LogMetric]{@link google.logging.v2.LogMetric} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListLogMetricsRequest]{@link google.logging.v2.ListLogMetricsRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListLogMetricsResponse]{@link google.logging.v2.ListLogMetricsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listLogMetrics( + request: protosTypes.google.logging.v2.IListLogMetricsRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.logging.v2.ILogMetric[], + protosTypes.google.logging.v2.IListLogMetricsRequest|null, + protosTypes.google.logging.v2.IListLogMetricsResponse>, + callback?: Callback< + protosTypes.google.logging.v2.ILogMetric[], + protosTypes.google.logging.v2.IListLogMetricsRequest|null, + protosTypes.google.logging.v2.IListLogMetricsResponse>): + Promise<[ + protosTypes.google.logging.v2.ILogMetric[], + protosTypes.google.logging.v2.IListLogMetricsRequest|null, + protosTypes.google.logging.v2.IListLogMetricsResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this._innerApiCalls.listLogMetrics(request, options, callback); + } + +/** + * Equivalent to {@link listLogMetrics}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listLogMetrics} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project containing the metrics: + * + * "projects/[PROJECT_ID]" + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [LogMetric]{@link google.logging.v2.LogMetric} on 'data' event. + */ + listLogMetricsStream( + request?: protosTypes.google.logging.v2.IListLogMetricsRequest, + options?: gax.CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this._descriptors.page.listLogMetrics.createStream( + this._innerApiCalls.listLogMetrics as gax.GaxCall, + request, + callSettings + ); + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified billingAccountCmekSettings resource name string. + * + * @param {string} billing_account + * @returns {string} Resource name string. + */ + billingAccountCmekSettingsPath(billingAccount:string) { + return this._pathTemplates.billingAccountCmekSettingsPathTemplate.render({ + billing_account: billingAccount, + }); + } + + /** + * Parse the billing_account from BillingAccountCmekSettings resource. + * + * @param {string} billingAccountCmekSettingsName + * A fully-qualified path representing billing_account_cmekSettings resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountCmekSettingsName(billingAccountCmekSettingsName: string) { + return this._pathTemplates.billingAccountCmekSettingsPathTemplate.match(billingAccountCmekSettingsName).billing_account; + } + + /** + * Return a fully-qualified billingAccountExclusion resource name string. + * + * @param {string} billing_account + * @param {string} exclusion + * @returns {string} Resource name string. + */ + billingAccountExclusionPath(billingAccount:string,exclusion:string) { + return this._pathTemplates.billingAccountExclusionPathTemplate.render({ + billing_account: billingAccount, + exclusion: exclusion, + }); + } + + /** + * Parse the billing_account from BillingAccountExclusion resource. + * + * @param {string} billingAccountExclusionName + * A fully-qualified path representing billing_account_exclusion resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountExclusionName(billingAccountExclusionName: string) { + return this._pathTemplates.billingAccountExclusionPathTemplate.match(billingAccountExclusionName).billing_account; + } + + /** + * Parse the exclusion from BillingAccountExclusion resource. + * + * @param {string} billingAccountExclusionName + * A fully-qualified path representing billing_account_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromBillingAccountExclusionName(billingAccountExclusionName: string) { + return this._pathTemplates.billingAccountExclusionPathTemplate.match(billingAccountExclusionName).exclusion; + } + + /** + * Return a fully-qualified billingAccountLocationBucket resource name string. + * + * @param {string} billing_account + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + billingAccountLocationBucketPath(billingAccount:string,location:string,bucket:string) { + return this._pathTemplates.billingAccountLocationBucketPathTemplate.render({ + billing_account: billingAccount, + location: location, + bucket: bucket, + }); + } + + /** + * Parse the billing_account from BillingAccountLocationBucket resource. + * + * @param {string} billingAccountLocationBucketName + * A fully-qualified path representing billing_account_location_bucket resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountLocationBucketName(billingAccountLocationBucketName: string) { + return this._pathTemplates.billingAccountLocationBucketPathTemplate.match(billingAccountLocationBucketName).billing_account; + } + + /** + * Parse the location from BillingAccountLocationBucket resource. + * + * @param {string} billingAccountLocationBucketName + * A fully-qualified path representing billing_account_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBillingAccountLocationBucketName(billingAccountLocationBucketName: string) { + return this._pathTemplates.billingAccountLocationBucketPathTemplate.match(billingAccountLocationBucketName).location; + } + + /** + * Parse the bucket from BillingAccountLocationBucket resource. + * + * @param {string} billingAccountLocationBucketName + * A fully-qualified path representing billing_account_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromBillingAccountLocationBucketName(billingAccountLocationBucketName: string) { + return this._pathTemplates.billingAccountLocationBucketPathTemplate.match(billingAccountLocationBucketName).bucket; + } + + /** + * Return a fully-qualified billingAccountLog resource name string. + * + * @param {string} billing_account + * @param {string} log + * @returns {string} Resource name string. + */ + billingAccountLogPath(billingAccount:string,log:string) { + return this._pathTemplates.billingAccountLogPathTemplate.render({ + billing_account: billingAccount, + log: log, + }); + } + + /** + * Parse the billing_account from BillingAccountLog resource. + * + * @param {string} billingAccountLogName + * A fully-qualified path representing billing_account_log resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountLogName(billingAccountLogName: string) { + return this._pathTemplates.billingAccountLogPathTemplate.match(billingAccountLogName).billing_account; + } + + /** + * Parse the log from BillingAccountLog resource. + * + * @param {string} billingAccountLogName + * A fully-qualified path representing billing_account_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromBillingAccountLogName(billingAccountLogName: string) { + return this._pathTemplates.billingAccountLogPathTemplate.match(billingAccountLogName).log; + } + + /** + * Return a fully-qualified billingAccountSink resource name string. + * + * @param {string} billing_account + * @param {string} sink + * @returns {string} Resource name string. + */ + billingAccountSinkPath(billingAccount:string,sink:string) { + return this._pathTemplates.billingAccountSinkPathTemplate.render({ + billing_account: billingAccount, + sink: sink, + }); + } + + /** + * Parse the billing_account from BillingAccountSink resource. + * + * @param {string} billingAccountSinkName + * A fully-qualified path representing billing_account_sink resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountSinkName(billingAccountSinkName: string) { + return this._pathTemplates.billingAccountSinkPathTemplate.match(billingAccountSinkName).billing_account; + } + + /** + * Parse the sink from BillingAccountSink resource. + * + * @param {string} billingAccountSinkName + * A fully-qualified path representing billing_account_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromBillingAccountSinkName(billingAccountSinkName: string) { + return this._pathTemplates.billingAccountSinkPathTemplate.match(billingAccountSinkName).sink; + } + + /** + * Return a fully-qualified folderCmekSettings resource name string. + * + * @param {string} folder + * @returns {string} Resource name string. + */ + folderCmekSettingsPath(folder:string) { + return this._pathTemplates.folderCmekSettingsPathTemplate.render({ + folder: folder, + }); + } + + /** + * Parse the folder from FolderCmekSettings resource. + * + * @param {string} folderCmekSettingsName + * A fully-qualified path representing folder_cmekSettings resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderCmekSettingsName(folderCmekSettingsName: string) { + return this._pathTemplates.folderCmekSettingsPathTemplate.match(folderCmekSettingsName).folder; + } + + /** + * Return a fully-qualified folderExclusion resource name string. + * + * @param {string} folder + * @param {string} exclusion + * @returns {string} Resource name string. + */ + folderExclusionPath(folder:string,exclusion:string) { + return this._pathTemplates.folderExclusionPathTemplate.render({ + folder: folder, + exclusion: exclusion, + }); + } + + /** + * Parse the folder from FolderExclusion resource. + * + * @param {string} folderExclusionName + * A fully-qualified path representing folder_exclusion resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderExclusionName(folderExclusionName: string) { + return this._pathTemplates.folderExclusionPathTemplate.match(folderExclusionName).folder; + } + + /** + * Parse the exclusion from FolderExclusion resource. + * + * @param {string} folderExclusionName + * A fully-qualified path representing folder_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromFolderExclusionName(folderExclusionName: string) { + return this._pathTemplates.folderExclusionPathTemplate.match(folderExclusionName).exclusion; + } + + /** + * Return a fully-qualified folderLocationBucket resource name string. + * + * @param {string} folder + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + folderLocationBucketPath(folder:string,location:string,bucket:string) { + return this._pathTemplates.folderLocationBucketPathTemplate.render({ + folder: folder, + location: location, + bucket: bucket, + }); + } + + /** + * Parse the folder from FolderLocationBucket resource. + * + * @param {string} folderLocationBucketName + * A fully-qualified path representing folder_location_bucket resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderLocationBucketName(folderLocationBucketName: string) { + return this._pathTemplates.folderLocationBucketPathTemplate.match(folderLocationBucketName).folder; + } + + /** + * Parse the location from FolderLocationBucket resource. + * + * @param {string} folderLocationBucketName + * A fully-qualified path representing folder_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromFolderLocationBucketName(folderLocationBucketName: string) { + return this._pathTemplates.folderLocationBucketPathTemplate.match(folderLocationBucketName).location; + } + + /** + * Parse the bucket from FolderLocationBucket resource. + * + * @param {string} folderLocationBucketName + * A fully-qualified path representing folder_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromFolderLocationBucketName(folderLocationBucketName: string) { + return this._pathTemplates.folderLocationBucketPathTemplate.match(folderLocationBucketName).bucket; + } + + /** + * Return a fully-qualified folderLog resource name string. + * + * @param {string} folder + * @param {string} log + * @returns {string} Resource name string. + */ + folderLogPath(folder:string,log:string) { + return this._pathTemplates.folderLogPathTemplate.render({ + folder: folder, + log: log, + }); + } + + /** + * Parse the folder from FolderLog resource. + * + * @param {string} folderLogName + * A fully-qualified path representing folder_log resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderLogName(folderLogName: string) { + return this._pathTemplates.folderLogPathTemplate.match(folderLogName).folder; + } + + /** + * Parse the log from FolderLog resource. + * + * @param {string} folderLogName + * A fully-qualified path representing folder_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromFolderLogName(folderLogName: string) { + return this._pathTemplates.folderLogPathTemplate.match(folderLogName).log; + } + + /** + * Return a fully-qualified folderSink resource name string. + * + * @param {string} folder + * @param {string} sink + * @returns {string} Resource name string. + */ + folderSinkPath(folder:string,sink:string) { + return this._pathTemplates.folderSinkPathTemplate.render({ + folder: folder, + sink: sink, + }); + } + + /** + * Parse the folder from FolderSink resource. + * + * @param {string} folderSinkName + * A fully-qualified path representing folder_sink resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderSinkName(folderSinkName: string) { + return this._pathTemplates.folderSinkPathTemplate.match(folderSinkName).folder; + } + + /** + * Parse the sink from FolderSink resource. + * + * @param {string} folderSinkName + * A fully-qualified path representing folder_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromFolderSinkName(folderSinkName: string) { + return this._pathTemplates.folderSinkPathTemplate.match(folderSinkName).sink; + } + + /** + * Return a fully-qualified logMetric resource name string. + * + * @param {string} project + * @param {string} metric + * @returns {string} Resource name string. + */ + logMetricPath(project:string,metric:string) { + return this._pathTemplates.logMetricPathTemplate.render({ + project: project, + metric: metric, + }); + } + + /** + * Parse the project from LogMetric resource. + * + * @param {string} logMetricName + * A fully-qualified path representing LogMetric resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLogMetricName(logMetricName: string) { + return this._pathTemplates.logMetricPathTemplate.match(logMetricName).project; + } + + /** + * Parse the metric from LogMetric resource. + * + * @param {string} logMetricName + * A fully-qualified path representing LogMetric resource. + * @returns {string} A string representing the metric. + */ + matchMetricFromLogMetricName(logMetricName: string) { + return this._pathTemplates.logMetricPathTemplate.match(logMetricName).metric; + } + + /** + * Return a fully-qualified organizationCmekSettings resource name string. + * + * @param {string} organization + * @returns {string} Resource name string. + */ + organizationCmekSettingsPath(organization:string) { + return this._pathTemplates.organizationCmekSettingsPathTemplate.render({ + organization: organization, + }); + } + + /** + * Parse the organization from OrganizationCmekSettings resource. + * + * @param {string} organizationCmekSettingsName + * A fully-qualified path representing organization_cmekSettings resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationCmekSettingsName(organizationCmekSettingsName: string) { + return this._pathTemplates.organizationCmekSettingsPathTemplate.match(organizationCmekSettingsName).organization; + } + + /** + * Return a fully-qualified organizationExclusion resource name string. + * + * @param {string} organization + * @param {string} exclusion + * @returns {string} Resource name string. + */ + organizationExclusionPath(organization:string,exclusion:string) { + return this._pathTemplates.organizationExclusionPathTemplate.render({ + organization: organization, + exclusion: exclusion, + }); + } + + /** + * Parse the organization from OrganizationExclusion resource. + * + * @param {string} organizationExclusionName + * A fully-qualified path representing organization_exclusion resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationExclusionName(organizationExclusionName: string) { + return this._pathTemplates.organizationExclusionPathTemplate.match(organizationExclusionName).organization; + } + + /** + * Parse the exclusion from OrganizationExclusion resource. + * + * @param {string} organizationExclusionName + * A fully-qualified path representing organization_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromOrganizationExclusionName(organizationExclusionName: string) { + return this._pathTemplates.organizationExclusionPathTemplate.match(organizationExclusionName).exclusion; + } + + /** + * Return a fully-qualified organizationLocationBucket resource name string. + * + * @param {string} organization + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + organizationLocationBucketPath(organization:string,location:string,bucket:string) { + return this._pathTemplates.organizationLocationBucketPathTemplate.render({ + organization: organization, + location: location, + bucket: bucket, + }); + } + + /** + * Parse the organization from OrganizationLocationBucket resource. + * + * @param {string} organizationLocationBucketName + * A fully-qualified path representing organization_location_bucket resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLocationBucketName(organizationLocationBucketName: string) { + return this._pathTemplates.organizationLocationBucketPathTemplate.match(organizationLocationBucketName).organization; + } + + /** + * Parse the location from OrganizationLocationBucket resource. + * + * @param {string} organizationLocationBucketName + * A fully-qualified path representing organization_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOrganizationLocationBucketName(organizationLocationBucketName: string) { + return this._pathTemplates.organizationLocationBucketPathTemplate.match(organizationLocationBucketName).location; + } + + /** + * Parse the bucket from OrganizationLocationBucket resource. + * + * @param {string} organizationLocationBucketName + * A fully-qualified path representing organization_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromOrganizationLocationBucketName(organizationLocationBucketName: string) { + return this._pathTemplates.organizationLocationBucketPathTemplate.match(organizationLocationBucketName).bucket; + } + + /** + * Return a fully-qualified organizationLog resource name string. + * + * @param {string} organization + * @param {string} log + * @returns {string} Resource name string. + */ + organizationLogPath(organization:string,log:string) { + return this._pathTemplates.organizationLogPathTemplate.render({ + organization: organization, + log: log, + }); + } + + /** + * Parse the organization from OrganizationLog resource. + * + * @param {string} organizationLogName + * A fully-qualified path representing organization_log resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLogName(organizationLogName: string) { + return this._pathTemplates.organizationLogPathTemplate.match(organizationLogName).organization; + } + + /** + * Parse the log from OrganizationLog resource. + * + * @param {string} organizationLogName + * A fully-qualified path representing organization_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromOrganizationLogName(organizationLogName: string) { + return this._pathTemplates.organizationLogPathTemplate.match(organizationLogName).log; + } + + /** + * Return a fully-qualified organizationSink resource name string. + * + * @param {string} organization + * @param {string} sink + * @returns {string} Resource name string. + */ + organizationSinkPath(organization:string,sink:string) { + return this._pathTemplates.organizationSinkPathTemplate.render({ + organization: organization, + sink: sink, + }); + } + + /** + * Parse the organization from OrganizationSink resource. + * + * @param {string} organizationSinkName + * A fully-qualified path representing organization_sink resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationSinkName(organizationSinkName: string) { + return this._pathTemplates.organizationSinkPathTemplate.match(organizationSinkName).organization; + } + + /** + * Parse the sink from OrganizationSink resource. + * + * @param {string} organizationSinkName + * A fully-qualified path representing organization_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromOrganizationSinkName(organizationSinkName: string) { + return this._pathTemplates.organizationSinkPathTemplate.match(organizationSinkName).sink; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this._pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this._pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified projectCmekSettings resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectCmekSettingsPath(project:string) { + return this._pathTemplates.projectCmekSettingsPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from ProjectCmekSettings resource. + * + * @param {string} projectCmekSettingsName + * A fully-qualified path representing project_cmekSettings resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectCmekSettingsName(projectCmekSettingsName: string) { + return this._pathTemplates.projectCmekSettingsPathTemplate.match(projectCmekSettingsName).project; + } + + /** + * Return a fully-qualified projectExclusion resource name string. + * + * @param {string} project + * @param {string} exclusion + * @returns {string} Resource name string. + */ + projectExclusionPath(project:string,exclusion:string) { + return this._pathTemplates.projectExclusionPathTemplate.render({ + project: project, + exclusion: exclusion, + }); + } + + /** + * Parse the project from ProjectExclusion resource. + * + * @param {string} projectExclusionName + * A fully-qualified path representing project_exclusion resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectExclusionName(projectExclusionName: string) { + return this._pathTemplates.projectExclusionPathTemplate.match(projectExclusionName).project; + } + + /** + * Parse the exclusion from ProjectExclusion resource. + * + * @param {string} projectExclusionName + * A fully-qualified path representing project_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromProjectExclusionName(projectExclusionName: string) { + return this._pathTemplates.projectExclusionPathTemplate.match(projectExclusionName).exclusion; + } + + /** + * Return a fully-qualified projectLocationBucket resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + projectLocationBucketPath(project:string,location:string,bucket:string) { + return this._pathTemplates.projectLocationBucketPathTemplate.render({ + project: project, + location: location, + bucket: bucket, + }); + } + + /** + * Parse the project from ProjectLocationBucket resource. + * + * @param {string} projectLocationBucketName + * A fully-qualified path representing project_location_bucket resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationBucketName(projectLocationBucketName: string) { + return this._pathTemplates.projectLocationBucketPathTemplate.match(projectLocationBucketName).project; + } + + /** + * Parse the location from ProjectLocationBucket resource. + * + * @param {string} projectLocationBucketName + * A fully-qualified path representing project_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationBucketName(projectLocationBucketName: string) { + return this._pathTemplates.projectLocationBucketPathTemplate.match(projectLocationBucketName).location; + } + + /** + * Parse the bucket from ProjectLocationBucket resource. + * + * @param {string} projectLocationBucketName + * A fully-qualified path representing project_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromProjectLocationBucketName(projectLocationBucketName: string) { + return this._pathTemplates.projectLocationBucketPathTemplate.match(projectLocationBucketName).bucket; + } + + /** + * Return a fully-qualified projectLog resource name string. + * + * @param {string} project + * @param {string} log + * @returns {string} Resource name string. + */ + projectLogPath(project:string,log:string) { + return this._pathTemplates.projectLogPathTemplate.render({ + project: project, + log: log, + }); + } + + /** + * Parse the project from ProjectLog resource. + * + * @param {string} projectLogName + * A fully-qualified path representing project_log resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLogName(projectLogName: string) { + return this._pathTemplates.projectLogPathTemplate.match(projectLogName).project; + } + + /** + * Parse the log from ProjectLog resource. + * + * @param {string} projectLogName + * A fully-qualified path representing project_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromProjectLogName(projectLogName: string) { + return this._pathTemplates.projectLogPathTemplate.match(projectLogName).log; + } + + /** + * Return a fully-qualified projectSink resource name string. + * + * @param {string} project + * @param {string} sink + * @returns {string} Resource name string. + */ + projectSinkPath(project:string,sink:string) { + return this._pathTemplates.projectSinkPathTemplate.render({ + project: project, + sink: sink, + }); + } + + /** + * Parse the project from ProjectSink resource. + * + * @param {string} projectSinkName + * A fully-qualified path representing project_sink resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectSinkName(projectSinkName: string) { + return this._pathTemplates.projectSinkPathTemplate.match(projectSinkName).project; + } + + /** + * Parse the sink from ProjectSink resource. + * + * @param {string} projectSinkName + * A fully-qualified path representing project_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromProjectSinkName(projectSinkName: string) { + return this._pathTemplates.projectSinkPathTemplate.match(projectSinkName).sink; + } + + /** + * Terminate the GRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + */ + close(): Promise { + this.initialize(); + if (!this._terminated) { + return this.metricsServiceV2Stub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/baselines/logging/src/v2/metrics_service_v2_client_config.json.baseline b/baselines/logging/src/v2/metrics_service_v2_client_config.json.baseline new file mode 100644 index 000000000..83f2b5c07 --- /dev/null +++ b/baselines/logging/src/v2/metrics_service_v2_client_config.json.baseline @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.logging.v2.MetricsServiceV2": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListLogMetrics": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetLogMetric": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateLogMetric": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateLogMetric": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteLogMetric": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/baselines/logging/src/v2/metrics_service_v2_proto_list.json.baseline b/baselines/logging/src/v2/metrics_service_v2_proto_list.json.baseline new file mode 100644 index 000000000..3103c1e58 --- /dev/null +++ b/baselines/logging/src/v2/metrics_service_v2_proto_list.json.baseline @@ -0,0 +1,6 @@ +[ + "../../protos/google/logging/v2/log_entry.proto", + "../../protos/google/logging/v2/logging.proto", + "../../protos/google/logging/v2/logging_config.proto", + "../../protos/google/logging/v2/logging_metrics.proto" +] diff --git a/baselines/logging/system-test/fixtures/sample/src/index.js.baseline b/baselines/logging/system-test/fixtures/sample/src/index.js.baseline new file mode 100644 index 000000000..9867bffad --- /dev/null +++ b/baselines/logging/system-test/fixtures/sample/src/index.js.baseline @@ -0,0 +1,29 @@ +// Copyright 2020 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const logging = require('logging'); + +function main() { + const configServiceV2Client = new logging.ConfigServiceV2Client(); + const loggingServiceV2Client = new logging.LoggingServiceV2Client(); + const metricsServiceV2Client = new logging.MetricsServiceV2Client(); +} + +main(); diff --git a/baselines/logging/system-test/fixtures/sample/src/index.ts.baseline b/baselines/logging/system-test/fixtures/sample/src/index.ts.baseline new file mode 100644 index 000000000..aa3614297 --- /dev/null +++ b/baselines/logging/system-test/fixtures/sample/src/index.ts.baseline @@ -0,0 +1,27 @@ +// Copyright 2020 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {ConfigServiceV2Client, LoggingServiceV2Client, MetricsServiceV2Client} from 'logging'; + +function main() { + const configServiceV2Client = new ConfigServiceV2Client(); + const loggingServiceV2Client = new LoggingServiceV2Client(); + const metricsServiceV2Client = new MetricsServiceV2Client(); +} + +main(); diff --git a/baselines/logging/system-test/install.ts.baseline b/baselines/logging/system-test/install.ts.baseline new file mode 100644 index 000000000..5e4ed6364 --- /dev/null +++ b/baselines/logging/system-test/install.ts.baseline @@ -0,0 +1,49 @@ +// Copyright 2020 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; + +describe('typescript consumer tests', () => { + + it('should have correct type signature for typescript users', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), // path to your module. + sample: { + description: 'typescript based user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); // will throw upon error. + }); + + it('should have correct type signature for javascript users', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), // path to your module. + sample: { + description: 'typescript based user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); // will throw upon error. + }); + +}); diff --git a/baselines/logging/test/gapic-config_service_v2-v2.ts.baseline b/baselines/logging/test/gapic-config_service_v2-v2.ts.baseline new file mode 100644 index 000000000..ddd3f1692 --- /dev/null +++ b/baselines/logging/test/gapic-config_service_v2-v2.ts.baseline @@ -0,0 +1,877 @@ +// Copyright 2020 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protosTypes from '../protos/protos'; +import * as assert from 'assert'; +import { describe, it } from 'mocha'; +const configservicev2Module = require('../src'); + + +const FAKE_STATUS_CODE = 1; +class FakeError{ + name: string; + message: string; + code: number; + constructor(n: number){ + this.name = 'fakeName'; + this.message = 'fake message'; + this.code = n; + } +} +const error = new FakeError(FAKE_STATUS_CODE); +export interface Callback { + (err: FakeError|null, response?: {} | null): void; +} + +export class Operation{ + constructor(){}; + promise() {}; +} +function mockSimpleGrpcMethod(expectedRequest: {}, response: {} | null, error: FakeError | null) { + return (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, expectedRequest); + if (error) { + callback(error); + } else if (response) { + callback(null, response); + } else { + callback(null); + } + }; +} +describe('v2.ConfigServiceV2Client', () => { + it('has servicePath', () => { + const servicePath = configservicev2Module.v2.ConfigServiceV2Client.servicePath; + assert(servicePath); + }); + it('has apiEndpoint', () => { + const apiEndpoint = configservicev2Module.v2.ConfigServiceV2Client.apiEndpoint; + assert(apiEndpoint); + }); + it('has port', () => { + const port = configservicev2Module.v2.ConfigServiceV2Client.port; + assert(port); + assert(typeof port === 'number'); + }); + it('should create a client with no option', () => { + const client = new configservicev2Module.v2.ConfigServiceV2Client(); + assert(client); + }); + it('should create a client with gRPC fallback', () => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + fallback: true, + }); + assert(client); + }); + it('has initialize method and supports deferred initialization', async () => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.configServiceV2Stub, undefined); + await client.initialize(); + assert(client.configServiceV2Stub); + }); + it('has close method', () => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.close(); + }); + describe('getBucket', () => { + it('invokes getBucket without error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IGetBucketRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getBucket = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.getBucket(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes getBucket with error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IGetBucketRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getBucket = mockSimpleGrpcMethod( + request, + null, + error + ); + client.getBucket(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('updateBucket', () => { + it('invokes updateBucket without error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IUpdateBucketRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.updateBucket = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.updateBucket(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes updateBucket with error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IUpdateBucketRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.updateBucket = mockSimpleGrpcMethod( + request, + null, + error + ); + client.updateBucket(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('getSink', () => { + it('invokes getSink without error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IGetSinkRequest = {}; + request.sinkName = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getSink = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.getSink(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes getSink with error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IGetSinkRequest = {}; + request.sinkName = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getSink = mockSimpleGrpcMethod( + request, + null, + error + ); + client.getSink(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('createSink', () => { + it('invokes createSink without error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.ICreateSinkRequest = {}; + request.parent = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createSink = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.createSink(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes createSink with error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.ICreateSinkRequest = {}; + request.parent = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createSink = mockSimpleGrpcMethod( + request, + null, + error + ); + client.createSink(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('updateSink', () => { + it('invokes updateSink without error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IUpdateSinkRequest = {}; + request.sinkName = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.updateSink = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.updateSink(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes updateSink with error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IUpdateSinkRequest = {}; + request.sinkName = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.updateSink = mockSimpleGrpcMethod( + request, + null, + error + ); + client.updateSink(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('deleteSink', () => { + it('invokes deleteSink without error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IDeleteSinkRequest = {}; + request.sinkName = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteSink = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.deleteSink(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes deleteSink with error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IDeleteSinkRequest = {}; + request.sinkName = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteSink = mockSimpleGrpcMethod( + request, + null, + error + ); + client.deleteSink(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('getExclusion', () => { + it('invokes getExclusion without error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IGetExclusionRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getExclusion = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.getExclusion(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes getExclusion with error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IGetExclusionRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getExclusion = mockSimpleGrpcMethod( + request, + null, + error + ); + client.getExclusion(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('createExclusion', () => { + it('invokes createExclusion without error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.ICreateExclusionRequest = {}; + request.parent = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createExclusion = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.createExclusion(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes createExclusion with error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.ICreateExclusionRequest = {}; + request.parent = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createExclusion = mockSimpleGrpcMethod( + request, + null, + error + ); + client.createExclusion(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('updateExclusion', () => { + it('invokes updateExclusion without error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IUpdateExclusionRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.updateExclusion = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.updateExclusion(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes updateExclusion with error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IUpdateExclusionRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.updateExclusion = mockSimpleGrpcMethod( + request, + null, + error + ); + client.updateExclusion(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('deleteExclusion', () => { + it('invokes deleteExclusion without error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IDeleteExclusionRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteExclusion = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.deleteExclusion(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes deleteExclusion with error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IDeleteExclusionRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteExclusion = mockSimpleGrpcMethod( + request, + null, + error + ); + client.deleteExclusion(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('getCmekSettings', () => { + it('invokes getCmekSettings without error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IGetCmekSettingsRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getCmekSettings = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.getCmekSettings(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes getCmekSettings with error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IGetCmekSettingsRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getCmekSettings = mockSimpleGrpcMethod( + request, + null, + error + ); + client.getCmekSettings(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('updateCmekSettings', () => { + it('invokes updateCmekSettings without error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IUpdateCmekSettingsRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.updateCmekSettings = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.updateCmekSettings(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes updateCmekSettings with error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IUpdateCmekSettingsRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.updateCmekSettings = mockSimpleGrpcMethod( + request, + null, + error + ); + client.updateCmekSettings(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('listBuckets', () => { + it('invokes listBuckets without error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IListBucketsRequest = {}; + request.parent = ''; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listBuckets = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + client.listBuckets(request, (err: FakeError, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + }); + describe('listBucketsStream', () => { + it('invokes listBucketsStream without error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IListBucketsRequest = {}; + request.parent = ''; + // Mock response + const expectedResponse = {response: 'data'}; + // Mock Grpc layer + client._innerApiCalls.listBuckets = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + const stream = client.listBucketsStream(request, {}).on('data', (response: {}) =>{ + assert.deepStrictEqual(response, expectedResponse); + done(); + }).on('error', (err: FakeError) => { + done(err); + }); + stream.write(expectedResponse); + }); + }); + describe('listSinks', () => { + it('invokes listSinks without error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IListSinksRequest = {}; + request.parent = ''; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listSinks = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + client.listSinks(request, (err: FakeError, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + }); + describe('listSinksStream', () => { + it('invokes listSinksStream without error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IListSinksRequest = {}; + request.parent = ''; + // Mock response + const expectedResponse = {response: 'data'}; + // Mock Grpc layer + client._innerApiCalls.listSinks = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + const stream = client.listSinksStream(request, {}).on('data', (response: {}) =>{ + assert.deepStrictEqual(response, expectedResponse); + done(); + }).on('error', (err: FakeError) => { + done(err); + }); + stream.write(expectedResponse); + }); + }); + describe('listExclusions', () => { + it('invokes listExclusions without error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IListExclusionsRequest = {}; + request.parent = ''; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listExclusions = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + client.listExclusions(request, (err: FakeError, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + }); + describe('listExclusionsStream', () => { + it('invokes listExclusionsStream without error', done => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IListExclusionsRequest = {}; + request.parent = ''; + // Mock response + const expectedResponse = {response: 'data'}; + // Mock Grpc layer + client._innerApiCalls.listExclusions = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + const stream = client.listExclusionsStream(request, {}).on('data', (response: {}) =>{ + assert.deepStrictEqual(response, expectedResponse); + done(); + }).on('error', (err: FakeError) => { + done(err); + }); + stream.write(expectedResponse); + }); + }); +}); diff --git a/baselines/logging/test/gapic-logging_service_v2-v2.ts.baseline b/baselines/logging/test/gapic-logging_service_v2-v2.ts.baseline new file mode 100644 index 000000000..7e8aa388e --- /dev/null +++ b/baselines/logging/test/gapic-logging_service_v2-v2.ts.baseline @@ -0,0 +1,351 @@ +// Copyright 2020 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protosTypes from '../protos/protos'; +import * as assert from 'assert'; +import { describe, it } from 'mocha'; +const loggingservicev2Module = require('../src'); + + +const FAKE_STATUS_CODE = 1; +class FakeError{ + name: string; + message: string; + code: number; + constructor(n: number){ + this.name = 'fakeName'; + this.message = 'fake message'; + this.code = n; + } +} +const error = new FakeError(FAKE_STATUS_CODE); +export interface Callback { + (err: FakeError|null, response?: {} | null): void; +} + +export class Operation{ + constructor(){}; + promise() {}; +} +function mockSimpleGrpcMethod(expectedRequest: {}, response: {} | null, error: FakeError | null) { + return (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, expectedRequest); + if (error) { + callback(error); + } else if (response) { + callback(null, response); + } else { + callback(null); + } + }; +} +describe('v2.LoggingServiceV2Client', () => { + it('has servicePath', () => { + const servicePath = loggingservicev2Module.v2.LoggingServiceV2Client.servicePath; + assert(servicePath); + }); + it('has apiEndpoint', () => { + const apiEndpoint = loggingservicev2Module.v2.LoggingServiceV2Client.apiEndpoint; + assert(apiEndpoint); + }); + it('has port', () => { + const port = loggingservicev2Module.v2.LoggingServiceV2Client.port; + assert(port); + assert(typeof port === 'number'); + }); + it('should create a client with no option', () => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client(); + assert(client); + }); + it('should create a client with gRPC fallback', () => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + fallback: true, + }); + assert(client); + }); + it('has initialize method and supports deferred initialization', async () => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.loggingServiceV2Stub, undefined); + await client.initialize(); + assert(client.loggingServiceV2Stub); + }); + it('has close method', () => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.close(); + }); + describe('deleteLog', () => { + it('invokes deleteLog without error', done => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IDeleteLogRequest = {}; + request.logName = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteLog = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.deleteLog(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes deleteLog with error', done => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IDeleteLogRequest = {}; + request.logName = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteLog = mockSimpleGrpcMethod( + request, + null, + error + ); + client.deleteLog(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('writeLogEntries', () => { + it('invokes writeLogEntries without error', done => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IWriteLogEntriesRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.writeLogEntries = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.writeLogEntries(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes writeLogEntries with error', done => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IWriteLogEntriesRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.writeLogEntries = mockSimpleGrpcMethod( + request, + null, + error + ); + client.writeLogEntries(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('listLogEntries', () => { + it('invokes listLogEntries without error', done => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IListLogEntriesRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listLogEntries = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + client.listLogEntries(request, (err: FakeError, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + }); + describe('listLogEntriesStream', () => { + it('invokes listLogEntriesStream without error', done => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IListLogEntriesRequest = {}; + // Mock response + const expectedResponse = {response: 'data'}; + // Mock Grpc layer + client._innerApiCalls.listLogEntries = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + const stream = client.listLogEntriesStream(request, {}).on('data', (response: {}) =>{ + assert.deepStrictEqual(response, expectedResponse); + done(); + }).on('error', (err: FakeError) => { + done(err); + }); + stream.write(expectedResponse); + }); + }); + describe('listMonitoredResourceDescriptors', () => { + it('invokes listMonitoredResourceDescriptors without error', done => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IListMonitoredResourceDescriptorsRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listMonitoredResourceDescriptors = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + client.listMonitoredResourceDescriptors(request, (err: FakeError, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + }); + describe('listMonitoredResourceDescriptorsStream', () => { + it('invokes listMonitoredResourceDescriptorsStream without error', done => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IListMonitoredResourceDescriptorsRequest = {}; + // Mock response + const expectedResponse = {response: 'data'}; + // Mock Grpc layer + client._innerApiCalls.listMonitoredResourceDescriptors = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + const stream = client.listMonitoredResourceDescriptorsStream(request, {}).on('data', (response: {}) =>{ + assert.deepStrictEqual(response, expectedResponse); + done(); + }).on('error', (err: FakeError) => { + done(err); + }); + stream.write(expectedResponse); + }); + }); + describe('listLogs', () => { + it('invokes listLogs without error', done => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IListLogsRequest = {}; + request.parent = ''; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listLogs = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + client.listLogs(request, (err: FakeError, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + }); + describe('listLogsStream', () => { + it('invokes listLogsStream without error', done => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IListLogsRequest = {}; + request.parent = ''; + // Mock response + const expectedResponse = {response: 'data'}; + // Mock Grpc layer + client._innerApiCalls.listLogs = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + const stream = client.listLogsStream(request, {}).on('data', (response: {}) =>{ + assert.deepStrictEqual(response, expectedResponse); + done(); + }).on('error', (err: FakeError) => { + done(err); + }); + stream.write(expectedResponse); + }); + }); +}); diff --git a/baselines/logging/test/gapic-metrics_service_v2-v2.ts.baseline b/baselines/logging/test/gapic-metrics_service_v2-v2.ts.baseline new file mode 100644 index 000000000..2770246ca --- /dev/null +++ b/baselines/logging/test/gapic-metrics_service_v2-v2.ts.baseline @@ -0,0 +1,357 @@ +// Copyright 2020 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protosTypes from '../protos/protos'; +import * as assert from 'assert'; +import { describe, it } from 'mocha'; +const metricsservicev2Module = require('../src'); + + +const FAKE_STATUS_CODE = 1; +class FakeError{ + name: string; + message: string; + code: number; + constructor(n: number){ + this.name = 'fakeName'; + this.message = 'fake message'; + this.code = n; + } +} +const error = new FakeError(FAKE_STATUS_CODE); +export interface Callback { + (err: FakeError|null, response?: {} | null): void; +} + +export class Operation{ + constructor(){}; + promise() {}; +} +function mockSimpleGrpcMethod(expectedRequest: {}, response: {} | null, error: FakeError | null) { + return (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, expectedRequest); + if (error) { + callback(error); + } else if (response) { + callback(null, response); + } else { + callback(null); + } + }; +} +describe('v2.MetricsServiceV2Client', () => { + it('has servicePath', () => { + const servicePath = metricsservicev2Module.v2.MetricsServiceV2Client.servicePath; + assert(servicePath); + }); + it('has apiEndpoint', () => { + const apiEndpoint = metricsservicev2Module.v2.MetricsServiceV2Client.apiEndpoint; + assert(apiEndpoint); + }); + it('has port', () => { + const port = metricsservicev2Module.v2.MetricsServiceV2Client.port; + assert(port); + assert(typeof port === 'number'); + }); + it('should create a client with no option', () => { + const client = new metricsservicev2Module.v2.MetricsServiceV2Client(); + assert(client); + }); + it('should create a client with gRPC fallback', () => { + const client = new metricsservicev2Module.v2.MetricsServiceV2Client({ + fallback: true, + }); + assert(client); + }); + it('has initialize method and supports deferred initialization', async () => { + const client = new metricsservicev2Module.v2.MetricsServiceV2Client({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.metricsServiceV2Stub, undefined); + await client.initialize(); + assert(client.metricsServiceV2Stub); + }); + it('has close method', () => { + const client = new metricsservicev2Module.v2.MetricsServiceV2Client({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.close(); + }); + describe('getLogMetric', () => { + it('invokes getLogMetric without error', done => { + const client = new metricsservicev2Module.v2.MetricsServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IGetLogMetricRequest = {}; + request.metricName = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getLogMetric = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.getLogMetric(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes getLogMetric with error', done => { + const client = new metricsservicev2Module.v2.MetricsServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IGetLogMetricRequest = {}; + request.metricName = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getLogMetric = mockSimpleGrpcMethod( + request, + null, + error + ); + client.getLogMetric(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('createLogMetric', () => { + it('invokes createLogMetric without error', done => { + const client = new metricsservicev2Module.v2.MetricsServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.ICreateLogMetricRequest = {}; + request.parent = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createLogMetric = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.createLogMetric(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes createLogMetric with error', done => { + const client = new metricsservicev2Module.v2.MetricsServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.ICreateLogMetricRequest = {}; + request.parent = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createLogMetric = mockSimpleGrpcMethod( + request, + null, + error + ); + client.createLogMetric(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('updateLogMetric', () => { + it('invokes updateLogMetric without error', done => { + const client = new metricsservicev2Module.v2.MetricsServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IUpdateLogMetricRequest = {}; + request.metricName = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.updateLogMetric = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.updateLogMetric(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes updateLogMetric with error', done => { + const client = new metricsservicev2Module.v2.MetricsServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IUpdateLogMetricRequest = {}; + request.metricName = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.updateLogMetric = mockSimpleGrpcMethod( + request, + null, + error + ); + client.updateLogMetric(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('deleteLogMetric', () => { + it('invokes deleteLogMetric without error', done => { + const client = new metricsservicev2Module.v2.MetricsServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IDeleteLogMetricRequest = {}; + request.metricName = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteLogMetric = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.deleteLogMetric(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes deleteLogMetric with error', done => { + const client = new metricsservicev2Module.v2.MetricsServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IDeleteLogMetricRequest = {}; + request.metricName = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteLogMetric = mockSimpleGrpcMethod( + request, + null, + error + ); + client.deleteLogMetric(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('listLogMetrics', () => { + it('invokes listLogMetrics without error', done => { + const client = new metricsservicev2Module.v2.MetricsServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IListLogMetricsRequest = {}; + request.parent = ''; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listLogMetrics = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + client.listLogMetrics(request, (err: FakeError, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + }); + describe('listLogMetricsStream', () => { + it('invokes listLogMetricsStream without error', done => { + const client = new metricsservicev2Module.v2.MetricsServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Initialize client before mocking + client.initialize(); + // Mock request + const request: protosTypes.google.logging.v2.IListLogMetricsRequest = {}; + request.parent = ''; + // Mock response + const expectedResponse = {response: 'data'}; + // Mock Grpc layer + client._innerApiCalls.listLogMetrics = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + const stream = client.listLogMetricsStream(request, {}).on('data', (response: {}) =>{ + assert.deepStrictEqual(response, expectedResponse); + done(); + }).on('error', (err: FakeError) => { + done(err); + }); + stream.write(expectedResponse); + }); + }); +}); diff --git a/baselines/logging/tsconfig.json.baseline b/baselines/logging/tsconfig.json.baseline new file mode 100644 index 000000000..613d35597 --- /dev/null +++ b/baselines/logging/tsconfig.json.baseline @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2016", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/baselines/logging/tslint.json.baseline b/baselines/logging/tslint.json.baseline new file mode 100644 index 000000000..617dc975b --- /dev/null +++ b/baselines/logging/tslint.json.baseline @@ -0,0 +1,3 @@ +{ + "extends": "gts/tslint.json" +} diff --git a/baselines/logging/webpack.config.js.baseline b/baselines/logging/webpack.config.js.baseline new file mode 100644 index 000000000..1ecebd876 --- /dev/null +++ b/baselines/logging/webpack.config.js.baseline @@ -0,0 +1,64 @@ +// Copyright 2020 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 +// +// https://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. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'LoggingService', + filename: './logging-service.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/baselines/monitoring/src/v3/alert_policy_service_client.ts.baseline b/baselines/monitoring/src/v3/alert_policy_service_client.ts.baseline index 65fe628e8..5b2d8348f 100644 --- a/baselines/monitoring/src/v3/alert_policy_service_client.ts.baseline +++ b/baselines/monitoring/src/v3/alert_policy_service_client.ts.baseline @@ -40,7 +40,7 @@ const version = require('../../../package.json').version; * @memberof v3 */ export class AlertPolicyServiceClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; private _innerApiCalls: {[name: string]: Function}; private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; diff --git a/baselines/monitoring/src/v3/group_service_client.ts.baseline b/baselines/monitoring/src/v3/group_service_client.ts.baseline index 9bc5e4684..070e368bb 100644 --- a/baselines/monitoring/src/v3/group_service_client.ts.baseline +++ b/baselines/monitoring/src/v3/group_service_client.ts.baseline @@ -43,7 +43,7 @@ const version = require('../../../package.json').version; * @memberof v3 */ export class GroupServiceClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; private _innerApiCalls: {[name: string]: Function}; private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; diff --git a/baselines/monitoring/src/v3/metric_service_client.ts.baseline b/baselines/monitoring/src/v3/metric_service_client.ts.baseline index 7c4ba58b0..8d77d5347 100644 --- a/baselines/monitoring/src/v3/metric_service_client.ts.baseline +++ b/baselines/monitoring/src/v3/metric_service_client.ts.baseline @@ -33,7 +33,7 @@ const version = require('../../../package.json').version; * @memberof v3 */ export class MetricServiceClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; private _innerApiCalls: {[name: string]: Function}; private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; diff --git a/baselines/monitoring/src/v3/notification_channel_service_client.ts.baseline b/baselines/monitoring/src/v3/notification_channel_service_client.ts.baseline index ffe47ac29..404effcfa 100644 --- a/baselines/monitoring/src/v3/notification_channel_service_client.ts.baseline +++ b/baselines/monitoring/src/v3/notification_channel_service_client.ts.baseline @@ -33,7 +33,7 @@ const version = require('../../../package.json').version; * @memberof v3 */ export class NotificationChannelServiceClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; private _innerApiCalls: {[name: string]: Function}; private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; diff --git a/baselines/monitoring/src/v3/service_monitoring_service_client.ts.baseline b/baselines/monitoring/src/v3/service_monitoring_service_client.ts.baseline index 5fd269548..b6ad5afc5 100644 --- a/baselines/monitoring/src/v3/service_monitoring_service_client.ts.baseline +++ b/baselines/monitoring/src/v3/service_monitoring_service_client.ts.baseline @@ -35,7 +35,7 @@ const version = require('../../../package.json').version; * @memberof v3 */ export class ServiceMonitoringServiceClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; private _innerApiCalls: {[name: string]: Function}; private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; diff --git a/baselines/monitoring/src/v3/uptime_check_service_client.ts.baseline b/baselines/monitoring/src/v3/uptime_check_service_client.ts.baseline index 9498eb2c2..676ceb339 100644 --- a/baselines/monitoring/src/v3/uptime_check_service_client.ts.baseline +++ b/baselines/monitoring/src/v3/uptime_check_service_client.ts.baseline @@ -39,7 +39,7 @@ const version = require('../../../package.json').version; * @memberof v3 */ export class UptimeCheckServiceClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; private _innerApiCalls: {[name: string]: Function}; private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; diff --git a/baselines/redis/src/v1beta1/cloud_redis_client.ts.baseline b/baselines/redis/src/v1beta1/cloud_redis_client.ts.baseline index 455930277..878ed3dcc 100644 --- a/baselines/redis/src/v1beta1/cloud_redis_client.ts.baseline +++ b/baselines/redis/src/v1beta1/cloud_redis_client.ts.baseline @@ -46,7 +46,7 @@ const version = require('../../../package.json').version; * @memberof v1beta1 */ export class CloudRedisClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; private _innerApiCalls: {[name: string]: Function}; private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; diff --git a/baselines/showcase/src/v1beta1/echo_client.ts.baseline b/baselines/showcase/src/v1beta1/echo_client.ts.baseline index 7c9f1cc0b..57ccbd3bc 100644 --- a/baselines/showcase/src/v1beta1/echo_client.ts.baseline +++ b/baselines/showcase/src/v1beta1/echo_client.ts.baseline @@ -36,7 +36,7 @@ const version = require('../../../package.json').version; * @memberof v1beta1 */ export class EchoClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; private _innerApiCalls: {[name: string]: Function}; private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; diff --git a/baselines/showcase/src/v1beta1/identity_client.ts.baseline b/baselines/showcase/src/v1beta1/identity_client.ts.baseline index b3edf3441..066b2650e 100644 --- a/baselines/showcase/src/v1beta1/identity_client.ts.baseline +++ b/baselines/showcase/src/v1beta1/identity_client.ts.baseline @@ -32,7 +32,7 @@ const version = require('../../../package.json').version; * @memberof v1beta1 */ export class IdentityClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; private _innerApiCalls: {[name: string]: Function}; private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; diff --git a/baselines/showcase/src/v1beta1/messaging_client.ts.baseline b/baselines/showcase/src/v1beta1/messaging_client.ts.baseline index 7c21f8e28..94c5aa9cc 100644 --- a/baselines/showcase/src/v1beta1/messaging_client.ts.baseline +++ b/baselines/showcase/src/v1beta1/messaging_client.ts.baseline @@ -35,7 +35,7 @@ const version = require('../../../package.json').version; * @memberof v1beta1 */ export class MessagingClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; private _innerApiCalls: {[name: string]: Function}; private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; diff --git a/baselines/showcase/src/v1beta1/testing_client.ts.baseline b/baselines/showcase/src/v1beta1/testing_client.ts.baseline index c0adac96b..26e2cc804 100644 --- a/baselines/showcase/src/v1beta1/testing_client.ts.baseline +++ b/baselines/showcase/src/v1beta1/testing_client.ts.baseline @@ -33,7 +33,7 @@ const version = require('../../../package.json').version; * @memberof v1beta1 */ export class TestingClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; private _innerApiCalls: {[name: string]: Function}; private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; diff --git a/baselines/texttospeech/src/v1/text_to_speech_client.ts.baseline b/baselines/texttospeech/src/v1/text_to_speech_client.ts.baseline index b12883e78..22caa170f 100644 --- a/baselines/texttospeech/src/v1/text_to_speech_client.ts.baseline +++ b/baselines/texttospeech/src/v1/text_to_speech_client.ts.baseline @@ -31,7 +31,7 @@ const version = require('../../../package.json').version; * @memberof v1 */ export class TextToSpeechClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; private _innerApiCalls: {[name: string]: Function}; private _terminated = false; private _opts: ClientOptions; diff --git a/baselines/translate/src/v3beta1/translation_service_client.ts.baseline b/baselines/translate/src/v3beta1/translation_service_client.ts.baseline index 5853793dc..2a15f3bd7 100644 --- a/baselines/translate/src/v3beta1/translation_service_client.ts.baseline +++ b/baselines/translate/src/v3beta1/translation_service_client.ts.baseline @@ -32,7 +32,7 @@ const version = require('../../../package.json').version; * @memberof v3beta1 */ export class TranslationServiceClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; private _innerApiCalls: {[name: string]: Function}; private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; diff --git a/package.json b/package.json index 126ac5b4a..5af6dfe52 100644 --- a/package.json +++ b/package.json @@ -39,9 +39,11 @@ "postpack": "cd templates/typescript_gapic && mv package.json.njk package.json && ln -s package.json package.json.njk" }, "dependencies": { + "@types/js-yaml": "^3.12.2", "file-system": "^2.2.2", "fs-extra": "^8.1.0", "get-stdin": "^7.0.0", + "js-yaml": "^3.13.1", "google-gax": "^1.15.1", "nunjucks": "^3.2.1", "object-hash": "^2.0.3", diff --git a/templates/typescript_gapic/src/$version/$service_client.ts.njk b/templates/typescript_gapic/src/$version/$service_client.ts.njk index d43c4a19b..ac98763f0 100644 --- a/templates/typescript_gapic/src/$version/$service_client.ts.njk +++ b/templates/typescript_gapic/src/$version/$service_client.ts.njk @@ -39,7 +39,7 @@ const version = require('../../../package.json').version; * @memberof {{ api.naming.version }} */ export class {{ service.name }}Client { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; private _innerApiCalls: {[name: string]: Function}; {%- if (service.pathTemplates.length > 0) %} private _pathTemplates: {[name: string]: gax.PathTemplate}; @@ -185,7 +185,7 @@ export class {{ service.name }}Client { {%- endfor %} }; {%- endif %} -{%- if (service.longRunning.length > 0) %} +{%- if (service.longRunning.length > 0) or (service.bundleConfigs.length > 0) %} // This API contains "long-running operations", which return a // an Operation object that allows for tracking of the operation, @@ -193,7 +193,8 @@ export class {{ service.name }}Client { const protoFilesRoot = opts.fallback? this._gaxModule.protobuf.Root.fromJSON(require("../../protos/protos.json")) : this._gaxModule.protobuf.loadSync(nodejsProtoPath); - +{% endif %} +{%- if service.longRunning.length > 0 %} this.operationsClient = this._gaxModule.lro({ auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined @@ -218,6 +219,31 @@ export class {{ service.name }}Client { }; {%- endif %} +{%- if (service.bundleConfigs.length > 0) %} + // Some methods on this API support automatically batching + // requests; denote this. + + this._descriptors.batching = { +{%- for method in service.bundleConfigsMethods %} + {{ method.name }}: new this._gaxModule.BundleDescriptor( + '{{ method.bundleConfig.batchDescriptor.batched_field }}', + [ +{%- set pagingJoiner = joiner() -%} +{%- for field in method.bundleConfig.batchDescriptor.discriminator_fields -%} + {{- pagingJoiner() -}} + '{{ field }}' +{%- endfor -%} + ], + {{- method.bundleConfig.batchDescriptor.subresponse_field }}, + gax.createByteLengthFunction( + // tslint:disable-next-line no-any + protoFilesRoot.lookupType('{{ method.bundleConfig.repeatedField }}') as any + ) + ), + }; +{%- endfor %} +{%- endif %} + // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( '{{ api.naming.protoPackage }}.{{ service.name }}', gapicConfig as gax.ClientConfig, diff --git a/templates/typescript_gapic/src/$version/$service_client_config.json.njk b/templates/typescript_gapic/src/$version/$service_client_config.json.njk index 01ac3c292..20d83b5d4 100644 --- a/templates/typescript_gapic/src/$version/$service_client_config.json.njk +++ b/templates/typescript_gapic/src/$version/$service_client_config.json.njk @@ -46,6 +46,18 @@ limitations under the License. "retry_codes_name": "{{ method.retryableCodesName }}" {{- optionComma() }} "retry_params_name": "{{ method.retryParamsName }}" +{%- if method.bundleConfig %} + {{- optionComma() }} + "bundling": { + "element_count_threshold": {{ method.bundleConfig.thresholds.element_count_threshold }} + {{- optionComma() }} + "request_byte_threshold": {{ method.bundleConfig.thresholds.request_byte_threshold }} + {{- optionComma() }} + "delay_threshold_millis": {{ method.bundleConfig.thresholds.delay_threshold_millis }} + {{- optionComma() }} + "element_count_limit": {{ method.bundleConfig.thresholds.element_count_limit }} + } +{%- endif %} } {%- endfor %} } diff --git a/test-fixtures/protos/google/logging/v2/log_entry.proto b/test-fixtures/protos/google/logging/v2/log_entry.proto new file mode 100644 index 000000000..ba8a08ff2 --- /dev/null +++ b/test-fixtures/protos/google/logging/v2/log_entry.proto @@ -0,0 +1,210 @@ +// 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.logging.v2; + +import "google/api/field_behavior.proto"; +import "google/api/monitored_resource.proto"; +import "google/api/resource.proto"; +import "google/logging/type/http_request.proto"; +import "google/logging/type/log_severity.proto"; +import "google/protobuf/any.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/api/annotations.proto"; + +option cc_enable_arenas = true; +option csharp_namespace = "Google.Cloud.Logging.V2"; +option go_package = "google.golang.org/genproto/googleapis/logging/v2;logging"; +option java_multiple_files = true; +option java_outer_classname = "LogEntryProto"; +option java_package = "com.google.logging.v2"; +option php_namespace = "Google\\Cloud\\Logging\\V2"; + +// An individual entry in a log. +// +// +message LogEntry { + option (google.api.resource) = { + type: "logging.googleapis.com/Log" + pattern: "projects/{project}/logs/{log}" + pattern: "organizations/{organization}/logs/{log}" + pattern: "folders/{folder}/logs/{log}" + pattern: "billingAccounts/{billing_account}/logs/{log}" + name_field: "log_name" + }; + + // Required. The resource name of the log to which this log entry belongs: + // + // "projects/[PROJECT_ID]/logs/[LOG_ID]" + // "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" + // "folders/[FOLDER_ID]/logs/[LOG_ID]" + // + // A project number may be used in place of PROJECT_ID. The project number is + // translated to its corresponding PROJECT_ID internally and the `log_name` + // field will contain PROJECT_ID in queries and exports. + // + // `[LOG_ID]` must be URL-encoded within `log_name`. Example: + // `"organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity"`. + // `[LOG_ID]` must be less than 512 characters long and can only include the + // following characters: upper and lower case alphanumeric characters, + // forward-slash, underscore, hyphen, and period. + // + // For backward compatibility, if `log_name` begins with a forward-slash, such + // as `/projects/...`, then the log entry is ingested as usual but the + // forward-slash is removed. Listing the log entry will not show the leading + // slash and filtering for a log name with a leading slash will never return + // any results. + string log_name = 12 [(google.api.field_behavior) = REQUIRED]; + + // Required. The monitored resource that produced this log entry. + // + // Example: a log entry that reports a database error would be associated with + // the monitored resource designating the particular database that reported + // the error. + google.api.MonitoredResource resource = 8 [(google.api.field_behavior) = REQUIRED]; + + // The log entry payload, which can be one of multiple types. + oneof payload { + // The log entry payload, represented as a protocol buffer. Some Google + // Cloud Platform services use this field for their log entry payloads. + // + // The following protocol buffer types are supported; user-defined types + // are not supported: + // + // "type.googleapis.com/google.cloud.audit.AuditLog" + // "type.googleapis.com/google.appengine.logging.v1.RequestLog" + 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 json_payload = 6; + } + + // Optional. The time the event described by the log entry occurred. This time is used + // to compute the log entry's age and to enforce the logs retention period. + // If this field is omitted in a new log entry, then Logging assigns it the + // current time. Timestamps have nanosecond accuracy, but trailing zeros in + // the fractional seconds might be omitted when the timestamp is displayed. + // + // Incoming log entries should have timestamps that are no more than the [logs + // retention period](/logging/quotas) in the past, and no more than 24 hours + // in the future. Log entries outside those time boundaries will not be + // available when calling `entries.list`, but those log entries can still be + // [exported with LogSinks](/logging/docs/api/tasks/exporting-logs). + google.protobuf.Timestamp timestamp = 9 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The time the log entry was received by Logging. + google.protobuf.Timestamp receive_timestamp = 24 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. The severity of the log entry. The default value is `LogSeverity.DEFAULT`. + google.logging.type.LogSeverity severity = 10 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A unique identifier for the log entry. If you provide a value, then + // Logging considers other log entries in the same project, with the same + // `timestamp`, and with the same `insert_id` to be duplicates which are + // removed in a single query result. However, there are no guarantees of + // de-duplication in the export of logs. + // + // If the `insert_id` is omitted when writing a log entry, the Logging API + // assigns its own unique identifier in this field. + // + // In queries, the `insert_id` is also used to order log entries that have + // the same `log_name` and `timestamp` values. + string insert_id = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Information about the HTTP request associated with this log entry, if + // applicable. + google.logging.type.HttpRequest http_request = 7 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A set of user-defined (key, value) data that provides additional + // information about the log entry. + map labels = 11 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Information about an operation associated with the log entry, if + // applicable. + LogEntryOperation operation = 15 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Resource name of the trace associated with the log entry, if any. If it + // contains a relative resource name, the name is assumed to be relative to + // `//tracing.googleapis.com`. Example: + // `projects/my-projectid/traces/06796866738c859f2f19b7cfb3214824` + string trace = 22 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The span ID within the trace associated with the log entry. + // + // For Trace spans, this is the same format that the Trace API v2 uses: a + // 16-character hexadecimal encoding of an 8-byte array, such as + // `000000000000004a`. + string span_id = 27 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The sampling decision of the trace associated with the log entry. + // + // True means that the trace resource name in the `trace` field was sampled + // for storage in a trace backend. False means that the trace was not sampled + // for storage when this log entry was written, or the sampling decision was + // unknown at the time. A non-sampled `trace` value is still useful as a + // request correlation identifier. The default is False. + bool trace_sampled = 30 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Source code location information associated with the log entry, if any. + LogEntrySourceLocation source_location = 23 [(google.api.field_behavior) = OPTIONAL]; +} + +// Additional information about a potentially long-running operation with which +// a log entry is associated. +message LogEntryOperation { + // Optional. An arbitrary operation identifier. Log entries with the same + // identifier are assumed to be part of the same operation. + string id = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. An arbitrary producer identifier. The combination of `id` and + // `producer` must be globally unique. Examples for `producer`: + // `"MyDivision.MyBigCompany.com"`, `"github.com/MyProject/MyApplication"`. + string producer = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Set this to True if this is the first log entry in the operation. + bool first = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Set this to True if this is the last log entry in the operation. + bool last = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Additional information about the source code location that produced the log +// entry. +message LogEntrySourceLocation { + // Optional. Source file name. Depending on the runtime environment, this + // might be a simple name or a fully-qualified name. + string file = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Line within the source file. 1-based; 0 indicates no line number + // available. + int64 line = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Human-readable name of the function or method being invoked, with + // optional context such as the class or package name. This information may be + // used in contexts such as the logs viewer, where a file and line number are + // less meaningful. The format can vary by language. For example: + // `qual.if.ied.Class.method` (Java), `dir/package.func` (Go), `function` + // (Python). + string function = 3 [(google.api.field_behavior) = OPTIONAL]; +} diff --git a/test-fixtures/protos/google/logging/v2/logging.proto b/test-fixtures/protos/google/logging/v2/logging.proto new file mode 100644 index 000000000..00af178c3 --- /dev/null +++ b/test-fixtures/protos/google/logging/v2/logging.proto @@ -0,0 +1,375 @@ +// 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.logging.v2; + +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/monitored_resource.proto"; +import "google/api/resource.proto"; +import "google/logging/v2/log_entry.proto"; +import "google/logging/v2/logging_config.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/api/annotations.proto"; + +option cc_enable_arenas = true; +option csharp_namespace = "Google.Cloud.Logging.V2"; +option go_package = "google.golang.org/genproto/googleapis/logging/v2;logging"; +option java_multiple_files = true; +option java_outer_classname = "LoggingProto"; +option java_package = "com.google.logging.v2"; +option php_namespace = "Google\\Cloud\\Logging\\V2"; + +// Service for ingesting and querying logs. +service LoggingServiceV2 { + option (google.api.default_host) = "logging.googleapis.com"; + option (google.api.oauth_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"; + + // Deletes all the log entries in a log. The log reappears if it receives new + // entries. Log entries written shortly before the delete operation might not + // be deleted. Entries received after the delete operation with a timestamp + // before the operation will be deleted. + rpc DeleteLog(DeleteLogRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2/{log_name=projects/*/logs/*}" + additional_bindings { + delete: "/v2/{log_name=*/*/logs/*}" + } + additional_bindings { + delete: "/v2/{log_name=organizations/*/logs/*}" + } + additional_bindings { + delete: "/v2/{log_name=folders/*/logs/*}" + } + additional_bindings { + delete: "/v2/{log_name=billingAccounts/*/logs/*}" + } + }; + option (google.api.method_signature) = "log_name"; + } + + // Writes log entries to Logging. This API method is the + // only way to send log entries to Logging. This method + // is used, directly or indirectly, by the Logging agent + // (fluentd) and all logging libraries configured to use Logging. + // A single request may contain log entries for a maximum of 1000 + // different resources (projects, organizations, billing accounts or + // folders) + rpc WriteLogEntries(WriteLogEntriesRequest) returns (WriteLogEntriesResponse) { + option (google.api.http) = { + post: "/v2/entries:write" + body: "*" + }; + option (google.api.method_signature) = "log_name,resource,labels,entries"; + } + + // Lists log entries. Use this method to retrieve log entries that originated + // from a project/folder/organization/billing account. For ways to export log + // entries, see [Exporting Logs](/logging/docs/export). + rpc ListLogEntries(ListLogEntriesRequest) returns (ListLogEntriesResponse) { + option (google.api.http) = { + post: "/v2/entries:list" + body: "*" + }; + option (google.api.method_signature) = "resource_names,filter,order_by"; + } + + // Lists the descriptors for monitored resource types used by Logging. + rpc ListMonitoredResourceDescriptors(ListMonitoredResourceDescriptorsRequest) returns (ListMonitoredResourceDescriptorsResponse) { + option (google.api.http) = { + get: "/v2/monitoredResourceDescriptors" + }; + } + + // Lists the logs in projects, organizations, folders, or billing accounts. + // Only logs that have entries are listed. + rpc ListLogs(ListLogsRequest) returns (ListLogsResponse) { + option (google.api.http) = { + get: "/v2/{parent=*/*}/logs" + additional_bindings { + get: "/v2/{parent=projects/*}/logs" + } + additional_bindings { + get: "/v2/{parent=organizations/*}/logs" + } + additional_bindings { + get: "/v2/{parent=folders/*}/logs" + } + additional_bindings { + get: "/v2/{parent=billingAccounts/*}/logs" + } + }; + option (google.api.method_signature) = "parent"; + } +} + +// The parameters to DeleteLog. +message DeleteLogRequest { + // Required. The resource name of the log to delete: + // + // "projects/[PROJECT_ID]/logs/[LOG_ID]" + // "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" + // "folders/[FOLDER_ID]/logs/[LOG_ID]" + // + // `[LOG_ID]` must be URL-encoded. For example, + // `"projects/my-project-id/logs/syslog"`, + // `"organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity"`. + // For more information about log names, see + // [LogEntry][google.logging.v2.LogEntry]. + string log_name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "logging.googleapis.com/Log" + } + ]; +} + +// The parameters to WriteLogEntries. +message WriteLogEntriesRequest { + // Optional. A default log resource name that is assigned to all log entries + // in `entries` that do not specify a value for `log_name`: + // + // "projects/[PROJECT_ID]/logs/[LOG_ID]" + // "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" + // "folders/[FOLDER_ID]/logs/[LOG_ID]" + // + // `[LOG_ID]` must be URL-encoded. For example: + // + // "projects/my-project-id/logs/syslog" + // "organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity" + // + // The permission `logging.logEntries.create` is needed on each project, + // organization, billing account, or folder that is receiving new log + // entries, whether the resource is specified in `logName` or in an + // individual log entry. + string log_name = 1 [ + (google.api.field_behavior) = OPTIONAL, + (google.api.resource_reference) = { + type: "logging.googleapis.com/Log" + } + ]; + + // Optional. A default monitored resource object that is assigned to all log + // entries in `entries` that do not specify a value for `resource`. Example: + // + // { "type": "gce_instance", + // "labels": { + // "zone": "us-central1-a", "instance_id": "00000000000000000000" }} + // + // See [LogEntry][google.logging.v2.LogEntry]. + google.api.MonitoredResource resource = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Default labels that are added to the `labels` field of all log + // entries in `entries`. If a log entry already has a label with the same key + // as a label in this parameter, then the log entry's label is not changed. + // See [LogEntry][google.logging.v2.LogEntry]. + map labels = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Required. The log entries to send to Logging. The order of log + // entries in this list does not matter. Values supplied in this method's + // `log_name`, `resource`, and `labels` fields are copied into those log + // entries in this list that do not include values for their corresponding + // fields. For more information, see the + // [LogEntry][google.logging.v2.LogEntry] type. + // + // If the `timestamp` or `insert_id` fields are missing in log entries, then + // this method supplies the current time or a unique identifier, respectively. + // The supplied values are chosen so that, among the log entries that did not + // supply their own values, the entries earlier in the list will sort before + // the entries later in the list. See the `entries.list` method. + // + // Log entries with timestamps that are more than the + // [logs retention period](/logging/quota-policy) in the past or more than + // 24 hours in the future will not be available when calling `entries.list`. + // However, those log entries can still be + // [exported with LogSinks](/logging/docs/api/tasks/exporting-logs). + // + // To improve throughput and to avoid exceeding the + // [quota limit](/logging/quota-policy) for calls to `entries.write`, + // you should try to include several log entries in this list, + // rather than calling this method for each individual log entry. + repeated LogEntry entries = 4 [(google.api.field_behavior) = REQUIRED]; + + // 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, then the response status is the error associated + // with one of the failed entries and the response includes error details + // keyed by the entries' zero-based index in the `entries.write` method. + bool partial_success = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If true, the request should expect normal response, but the + // entries won't be persisted nor exported. Useful for checking whether the + // logging API endpoints are working properly before sending valuable data. + bool dry_run = 6 [(google.api.field_behavior) = OPTIONAL]; +} + +// Result returned from WriteLogEntries. +message WriteLogEntriesResponse {} + +// Error details for WriteLogEntries with partial success. +message WriteLogEntriesPartialErrors { + // When `WriteLogEntriesRequest.partial_success` is true, records the error + // status for entries that were not written due to a permanent error, keyed + // by the entry's zero-based index in `WriteLogEntriesRequest.entries`. + // + // Failed requests for which no entries are written will not include + // per-entry errors. + map log_entry_errors = 1; +} + +// The parameters to `ListLogEntries`. +message ListLogEntriesRequest { + // Required. Names of one or more parent resources from which to + // retrieve log entries: + // + // "projects/[PROJECT_ID]" + // "organizations/[ORGANIZATION_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]" + // "folders/[FOLDER_ID]" + // + // + // Projects listed in the `project_ids` field are added to this list. + repeated string resource_names = 8 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "logging.googleapis.com/Log" + } + ]; + + // Optional. A filter that chooses which log entries to return. See [Advanced + // Logs Queries](/logging/docs/view/advanced-queries). Only log entries that + // match the filter are returned. An empty filter matches all log entries in + // the resources listed in `resource_names`. Referencing a parent resource + // that is not listed in `resource_names` will cause the filter to return no + // results. + // The maximum length of the filter is 20000 characters. + string filter = 2 [(google.api.field_behavior) = OPTIONAL]; + + // 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 their `insert_id` values. + string order_by = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maximum number of results to return from this request. + // Non-positive values are ignored. The presence of `next_page_token` in the + // response indicates that more results might be available. + int32 page_size = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If present, then retrieve the next batch of results from the + // preceding call to this method. `page_token` must be the value of + // `next_page_token` from the previous response. The values of other method + // parameters should be identical to those in the previous call. + string page_token = 5 [(google.api.field_behavior) = OPTIONAL]; +} + +// Result returned from `ListLogEntries`. +message ListLogEntriesResponse { + // A list of log entries. If `entries` is empty, `nextPageToken` may still be + // returned, indicating that more entries may exist. See `nextPageToken` for + // more information. + repeated LogEntry entries = 1; + + // If there might be more results than those appearing in this response, then + // `nextPageToken` is included. To get the next set of results, call this + // method again using the value of `nextPageToken` as `pageToken`. + // + // If a value for `next_page_token` appears and the `entries` field is empty, + // it means that the search found no log entries so far but it did not have + // time to search all the possible log entries. Retry the method with this + // value for `page_token` to continue the search. Alternatively, consider + // speeding up the search by changing your filter to specify a single log name + // or resource type, or to narrow the time range of the search. + string next_page_token = 2; +} + +// The parameters to ListMonitoredResourceDescriptors +message ListMonitoredResourceDescriptorsRequest { + // Optional. The maximum number of results to return from this request. + // Non-positive values are ignored. The presence of `nextPageToken` in the + // response indicates that more results might be available. + int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If present, then retrieve the next batch of results from the + // preceding call to this method. `pageToken` must be the value of + // `nextPageToken` from the previous response. The values of other method + // parameters should be identical to those in the previous call. + string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// Result returned from ListMonitoredResourceDescriptors. +message ListMonitoredResourceDescriptorsResponse { + // A list of resource descriptors. + repeated google.api.MonitoredResourceDescriptor resource_descriptors = 1; + + // If there might be more results than those appearing in this response, then + // `nextPageToken` is included. To get the next set of results, call this + // method again using the value of `nextPageToken` as `pageToken`. + string next_page_token = 2; +} + +// The parameters to ListLogs. +message ListLogsRequest { + // Required. The resource name that owns the logs: + // + // "projects/[PROJECT_ID]" + // "organizations/[ORGANIZATION_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]" + // "folders/[FOLDER_ID]" + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "logging.googleapis.com/Log" + } + ]; + + // Optional. The maximum number of results to return from this request. + // Non-positive values are ignored. The presence of `nextPageToken` in the + // response indicates that more results might be available. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If present, then retrieve the next batch of results from the + // preceding call to this method. `pageToken` must be the value of + // `nextPageToken` from the previous response. The values of other method + // parameters should be identical to those in the previous call. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Result returned from ListLogs. +message ListLogsResponse { + // A list of log names. For example, + // `"projects/my-project/logs/syslog"` or + // `"organizations/123/logs/cloudresourcemanager.googleapis.com%2Factivity"`. + repeated string log_names = 3; + + // If there might be more results than those appearing in this response, then + // `nextPageToken` is included. To get the next set of results, call this + // method again using the value of `nextPageToken` as `pageToken`. + string next_page_token = 2; +} diff --git a/test-fixtures/protos/google/logging/v2/logging_config.proto b/test-fixtures/protos/google/logging/v2/logging_config.proto new file mode 100644 index 000000000..1062a6521 --- /dev/null +++ b/test-fixtures/protos/google/logging/v2/logging_config.proto @@ -0,0 +1,1156 @@ +// 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.logging.v2; + +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/api/annotations.proto"; + +option cc_enable_arenas = true; +option csharp_namespace = "Google.Cloud.Logging.V2"; +option go_package = "google.golang.org/genproto/googleapis/logging/v2;logging"; +option java_multiple_files = true; +option java_outer_classname = "LoggingConfigProto"; +option java_package = "com.google.logging.v2"; +option php_namespace = "Google\\Cloud\\Logging\\V2"; + +// Service for configuring sinks used to route log entries. +service ConfigServiceV2 { + option (google.api.default_host) = "logging.googleapis.com"; + option (google.api.oauth_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"; + + // Lists buckets (Beta). + rpc ListBuckets(ListBucketsRequest) returns (ListBucketsResponse) { + option (google.api.http) = { + get: "/v2/{parent=*/*/locations/*}/buckets" + additional_bindings { + get: "/v2/{parent=projects/*/locations/*}/buckets" + } + additional_bindings { + get: "/v2/{parent=organizations/*/locations/*}/buckets" + } + additional_bindings { + get: "/v2/{parent=folders/*/locations/*}/buckets" + } + additional_bindings { + get: "/v2/{parent=billingAccounts/*/locations/*}/buckets" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Gets a bucket (Beta). + rpc GetBucket(GetBucketRequest) returns (LogBucket) { + option (google.api.http) = { + get: "/v2/{name=*/*/locations/*/buckets/*}" + additional_bindings { + get: "/v2/{name=projects/*/locations/*/buckets/*}" + } + additional_bindings { + get: "/v2/{name=organizations/*/locations/*/buckets/*}" + } + additional_bindings { + get: "/v2/{name=folders/*/locations/*/buckets/*}" + } + additional_bindings { + get: "/v2/{name=billingAccounts/*/buckets/*}" + } + }; + } + + // Updates a bucket. This method replaces the following fields in the + // existing bucket with values from the new bucket: `retention_period` + // + // If the retention period is decreased and the bucket is locked, + // FAILED_PRECONDITION will be returned. + // + // If the bucket has a LifecycleState of DELETE_REQUESTED, FAILED_PRECONDITION + // will be returned. + // + // A buckets region may not be modified after it is created. + // This method is in Beta. + rpc UpdateBucket(UpdateBucketRequest) returns (LogBucket) { + option (google.api.http) = { + patch: "/v2/{name=*/*/locations/*/buckets/*}" + body: "bucket" + additional_bindings { + patch: "/v2/{name=projects/*/locations/*/buckets/*}" + body: "bucket" + } + additional_bindings { + patch: "/v2/{name=organizations/*/locations/*/buckets/*}" + body: "bucket" + } + additional_bindings { + patch: "/v2/{name=folders/*/locations/*/buckets/*}" + body: "bucket" + } + additional_bindings { + patch: "/v2/{name=billingAccounts/*/locations/*/buckets/*}" + body: "bucket" + } + }; + } + + // Lists sinks. + rpc ListSinks(ListSinksRequest) returns (ListSinksResponse) { + option (google.api.http) = { + get: "/v2/{parent=*/*}/sinks" + additional_bindings { + get: "/v2/{parent=projects/*}/sinks" + } + additional_bindings { + get: "/v2/{parent=organizations/*}/sinks" + } + additional_bindings { + get: "/v2/{parent=folders/*}/sinks" + } + additional_bindings { + get: "/v2/{parent=billingAccounts/*}/sinks" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Gets a sink. + rpc GetSink(GetSinkRequest) returns (LogSink) { + option (google.api.http) = { + get: "/v2/{sink_name=*/*/sinks/*}" + additional_bindings { + get: "/v2/{sink_name=projects/*/sinks/*}" + } + additional_bindings { + get: "/v2/{sink_name=organizations/*/sinks/*}" + } + additional_bindings { + get: "/v2/{sink_name=folders/*/sinks/*}" + } + additional_bindings { + get: "/v2/{sink_name=billingAccounts/*/sinks/*}" + } + }; + option (google.api.method_signature) = "sink_name"; + } + + // Creates a sink that exports specified log entries to a destination. The + // export of newly-ingested log entries begins immediately, unless the sink's + // `writer_identity` is not permitted to write to the destination. A sink can + // export log entries only from the resource owning the sink. + rpc CreateSink(CreateSinkRequest) returns (LogSink) { + option (google.api.http) = { + post: "/v2/{parent=*/*}/sinks" + body: "sink" + additional_bindings { + post: "/v2/{parent=projects/*}/sinks" + body: "sink" + } + additional_bindings { + post: "/v2/{parent=organizations/*}/sinks" + body: "sink" + } + additional_bindings { + post: "/v2/{parent=folders/*}/sinks" + body: "sink" + } + additional_bindings { + post: "/v2/{parent=billingAccounts/*}/sinks" + body: "sink" + } + }; + option (google.api.method_signature) = "parent,sink"; + } + + // Updates a sink. This method replaces the following fields in the existing + // sink with values from the new sink: `destination`, and `filter`. + // + // The updated sink might also have a new `writer_identity`; see the + // `unique_writer_identity` field. + rpc UpdateSink(UpdateSinkRequest) returns (LogSink) { + option (google.api.http) = { + put: "/v2/{sink_name=*/*/sinks/*}" + body: "sink" + additional_bindings { + put: "/v2/{sink_name=projects/*/sinks/*}" + body: "sink" + } + additional_bindings { + put: "/v2/{sink_name=organizations/*/sinks/*}" + body: "sink" + } + additional_bindings { + put: "/v2/{sink_name=folders/*/sinks/*}" + body: "sink" + } + additional_bindings { + put: "/v2/{sink_name=billingAccounts/*/sinks/*}" + body: "sink" + } + additional_bindings { + patch: "/v2/{sink_name=projects/*/sinks/*}" + body: "sink" + } + additional_bindings { + patch: "/v2/{sink_name=organizations/*/sinks/*}" + body: "sink" + } + additional_bindings { + patch: "/v2/{sink_name=folders/*/sinks/*}" + body: "sink" + } + additional_bindings { + patch: "/v2/{sink_name=billingAccounts/*/sinks/*}" + body: "sink" + } + }; + option (google.api.method_signature) = "sink_name,sink,update_mask"; + option (google.api.method_signature) = "sink_name,sink"; + } + + // Deletes a sink. If the sink has a unique `writer_identity`, then that + // service account is also deleted. + rpc DeleteSink(DeleteSinkRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2/{sink_name=*/*/sinks/*}" + additional_bindings { + delete: "/v2/{sink_name=projects/*/sinks/*}" + } + additional_bindings { + delete: "/v2/{sink_name=organizations/*/sinks/*}" + } + additional_bindings { + delete: "/v2/{sink_name=folders/*/sinks/*}" + } + additional_bindings { + delete: "/v2/{sink_name=billingAccounts/*/sinks/*}" + } + }; + option (google.api.method_signature) = "sink_name"; + } + + // Lists all the exclusions in a parent resource. + rpc ListExclusions(ListExclusionsRequest) returns (ListExclusionsResponse) { + option (google.api.http) = { + get: "/v2/{parent=*/*}/exclusions" + additional_bindings { + get: "/v2/{parent=projects/*}/exclusions" + } + additional_bindings { + get: "/v2/{parent=organizations/*}/exclusions" + } + additional_bindings { + get: "/v2/{parent=folders/*}/exclusions" + } + additional_bindings { + get: "/v2/{parent=billingAccounts/*}/exclusions" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Gets the description of an exclusion. + rpc GetExclusion(GetExclusionRequest) returns (LogExclusion) { + option (google.api.http) = { + get: "/v2/{name=*/*/exclusions/*}" + additional_bindings { + get: "/v2/{name=projects/*/exclusions/*}" + } + additional_bindings { + get: "/v2/{name=organizations/*/exclusions/*}" + } + additional_bindings { + get: "/v2/{name=folders/*/exclusions/*}" + } + additional_bindings { + get: "/v2/{name=billingAccounts/*/exclusions/*}" + } + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new exclusion in a specified parent resource. + // Only log entries belonging to that resource can be excluded. + // You can have up to 10 exclusions in a resource. + rpc CreateExclusion(CreateExclusionRequest) returns (LogExclusion) { + option (google.api.http) = { + post: "/v2/{parent=*/*}/exclusions" + body: "exclusion" + additional_bindings { + post: "/v2/{parent=projects/*}/exclusions" + body: "exclusion" + } + additional_bindings { + post: "/v2/{parent=organizations/*}/exclusions" + body: "exclusion" + } + additional_bindings { + post: "/v2/{parent=folders/*}/exclusions" + body: "exclusion" + } + additional_bindings { + post: "/v2/{parent=billingAccounts/*}/exclusions" + body: "exclusion" + } + }; + option (google.api.method_signature) = "parent,exclusion"; + } + + // Changes one or more properties of an existing exclusion. + rpc UpdateExclusion(UpdateExclusionRequest) returns (LogExclusion) { + option (google.api.http) = { + patch: "/v2/{name=*/*/exclusions/*}" + body: "exclusion" + additional_bindings { + patch: "/v2/{name=projects/*/exclusions/*}" + body: "exclusion" + } + additional_bindings { + patch: "/v2/{name=organizations/*/exclusions/*}" + body: "exclusion" + } + additional_bindings { + patch: "/v2/{name=folders/*/exclusions/*}" + body: "exclusion" + } + additional_bindings { + patch: "/v2/{name=billingAccounts/*/exclusions/*}" + body: "exclusion" + } + }; + option (google.api.method_signature) = "name,exclusion,update_mask"; + } + + // Deletes an exclusion. + rpc DeleteExclusion(DeleteExclusionRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2/{name=*/*/exclusions/*}" + additional_bindings { + delete: "/v2/{name=projects/*/exclusions/*}" + } + additional_bindings { + delete: "/v2/{name=organizations/*/exclusions/*}" + } + additional_bindings { + delete: "/v2/{name=folders/*/exclusions/*}" + } + additional_bindings { + delete: "/v2/{name=billingAccounts/*/exclusions/*}" + } + }; + option (google.api.method_signature) = "name"; + } + + // Gets the Logs Router CMEK settings for the given resource. + // + // Note: CMEK for the Logs Router can currently only be configured for GCP + // organizations. Once configured, it applies to all projects and folders in + // the GCP organization. + // + // See [Enabling CMEK for Logs + // Router](/logging/docs/routing/managed-encryption) for more information. + rpc GetCmekSettings(GetCmekSettingsRequest) returns (CmekSettings) { + option (google.api.http) = { + get: "/v2/{name=*/*}/cmekSettings" + additional_bindings { + get: "/v2/{name=organizations/*}/cmekSettings" + } + }; + } + + // Updates the Logs Router CMEK settings for the given resource. + // + // Note: CMEK for the Logs Router can currently only be configured for GCP + // organizations. Once configured, it applies to all projects and folders in + // the GCP organization. + // + // [UpdateCmekSettings][google.logging.v2.ConfigServiceV2.UpdateCmekSettings] + // will fail if 1) `kms_key_name` is invalid, or 2) the associated service + // account does not have the required + // `roles/cloudkms.cryptoKeyEncrypterDecrypter` role assigned for the key, or + // 3) access to the key is disabled. + // + // See [Enabling CMEK for Logs + // Router](/logging/docs/routing/managed-encryption) for more information. + rpc UpdateCmekSettings(UpdateCmekSettingsRequest) returns (CmekSettings) { + option (google.api.http) = { + patch: "/v2/{name=*/*}/cmekSettings" + body: "cmek_settings" + additional_bindings { + patch: "/v2/{name=organizations/*}/cmekSettings" + body: "cmek_settings" + } + }; + } +} + +// Describes a repository of logs (Beta). +message LogBucket { + option (google.api.resource) = { + type: "logging.googleapis.com/LogBucket" + pattern: "projects/{project}/locations/{location}/buckets/{bucket}" + pattern: "organizations/{organization}/locations/{location}/buckets/{bucket}" + pattern: "folders/{folder}/locations/{location}/buckets/{bucket}" + pattern: "billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}" + }; + + // The resource name of the bucket. + // For example: + // "projects/my-project-id/locations/my-location/buckets/my-bucket-id The + // supported locations are: + // "global" + // "us-central1" + // + // For the location of `global` it is unspecified where logs are actually + // stored. + // Once a bucket has been created, the location can not be changed. + string name = 1; + + // Describes this bucket. + string description = 3; + + // Output only. The creation timestamp of the bucket. This is not set for any of the + // default buckets. + google.protobuf.Timestamp create_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The last update timestamp of the bucket. + google.protobuf.Timestamp update_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Logs will be retained by default for this amount of time, after which they + // will automatically be deleted. The minimum retention period is 1 day. + // If this value is set to zero at bucket creation time, the default time of + // 30 days will be used. + int32 retention_days = 11; + + // Output only. The bucket lifecycle state. + LifecycleState lifecycle_state = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Describes a sink used to export log entries to one of the following +// destinations in any project: a Cloud Storage bucket, a BigQuery dataset, or a +// Cloud Pub/Sub topic. A logs filter controls which log entries are exported. +// The sink must be created within a project, organization, billing account, or +// folder. +message LogSink { + option (google.api.resource) = { + type: "logging.googleapis.com/LogSink" + pattern: "projects/{project}/sinks/{sink}" + pattern: "organizations/{organization}/sinks/{sink}" + pattern: "folders/{folder}/sinks/{sink}" + pattern: "billingAccounts/{billing_account}/sinks/{sink}" + }; + + // Available log entry formats. Log entries can be written to + // Logging in either format and can be exported in either format. + // Version 2 is the preferred format. + enum VersionFormat { + // An unspecified format version that will default to V2. + VERSION_FORMAT_UNSPECIFIED = 0; + + // `LogEntry` version 2 format. + V2 = 1; + + // `LogEntry` version 1 format. + V1 = 2; + } + + // Required. The client-assigned sink identifier, unique within the project. Example: + // `"my-syslog-errors-to-pubsub"`. Sink identifiers are limited to 100 + // characters and can include only the following characters: upper and + // lower-case alphanumeric characters, underscores, hyphens, and periods. + // First character has to be alphanumeric. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The export destination: + // + // "storage.googleapis.com/[GCS_BUCKET]" + // "bigquery.googleapis.com/projects/[PROJECT_ID]/datasets/[DATASET]" + // "pubsub.googleapis.com/projects/[PROJECT_ID]/topics/[TOPIC_ID]" + // + // The sink's `writer_identity`, set when the sink is created, must + // have permission to write to the destination or else the log + // entries are not exported. For more information, see + // [Exporting Logs with Sinks](/logging/docs/api/tasks/exporting-logs). + string destination = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "*" + } + ]; + + // Optional. An [advanced logs filter](/logging/docs/view/advanced-queries). The only + // exported log entries are those that are in the resource owning the sink and + // that match the filter. For example: + // + // logName="projects/[PROJECT_ID]/logs/[LOG_ID]" AND severity>=ERROR + string filter = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A description of this sink. + // The maximum length of the description is 8000 characters. + string description = 18 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If set to True, then this sink is disabled and it does not + // export any log entries. + bool disabled = 19 [(google.api.field_behavior) = OPTIONAL]; + + // Deprecated. The log entry format to use for this sink's exported log + // entries. The v2 format is used by default and cannot be changed. + VersionFormat output_version_format = 6 [deprecated = true]; + + // Output only. An IAM identity–a service account or group—under which Logging + // writes the exported log entries to the sink's destination. This field is + // set by [sinks.create][google.logging.v2.ConfigServiceV2.CreateSink] and + // [sinks.update][google.logging.v2.ConfigServiceV2.UpdateSink] based on the + // value of `unique_writer_identity` in those methods. + // + // Until you grant this identity write-access to the destination, log entry + // exports from this sink will fail. For more information, + // see [Granting Access for a + // Resource](/iam/docs/granting-roles-to-service-accounts#granting_access_to_a_service_account_for_a_resource). + // Consult the destination service's documentation to determine the + // appropriate IAM roles to assign to the identity. + string writer_identity = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. This field applies only to sinks owned by organizations and + // folders. If the field is false, the default, only the logs owned by the + // sink's parent resource are available for export. If the field is true, then + // logs from all the projects, folders, and billing accounts contained in the + // sink's parent resource are also available for export. Whether a particular + // log entry from the children is exported depends on the sink's filter + // expression. For example, if this field is true, then the filter + // `resource.type=gce_instance` would export all Compute Engine VM instance + // log entries from all projects in the sink's parent. To only export entries + // from certain child projects, filter on the project part of the log name: + // + // logName:("projects/test-project1/" OR "projects/test-project2/") AND + // resource.type=gce_instance + bool include_children = 9 [(google.api.field_behavior) = OPTIONAL]; + + // Destination dependent options. + oneof options { + // Optional. Options that affect sinks exporting data to BigQuery. + BigQueryOptions bigquery_options = 12 [(google.api.field_behavior) = OPTIONAL]; + } + + // Output only. The creation timestamp of the sink. + // + // This field may not be present for older sinks. + google.protobuf.Timestamp create_time = 13 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The last update timestamp of the sink. + // + // This field may not be present for older sinks. + google.protobuf.Timestamp update_time = 14 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Options that change functionality of a sink exporting data to BigQuery. +message BigQueryOptions { + // Optional. Whether to use [BigQuery's partition + // tables](/bigquery/docs/partitioned-tables). By default, Logging + // creates dated tables based on the log entries' timestamps, e.g. + // syslog_20170523. With partitioned tables the date suffix is no longer + // present and [special query + // syntax](/bigquery/docs/querying-partitioned-tables) has to be used instead. + // In both cases, tables are sharded based on UTC timezone. + bool use_partitioned_tables = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. True if new timestamp column based partitioning is in use, + // false if legacy ingestion-time partitioning is in use. + // All new sinks will have this field set true and will use timestamp column + // based partitioning. If use_partitioned_tables is false, this value has no + // meaning and will be false. Legacy sinks using partitioned tables will have + // this field set to false. + bool uses_timestamp_column_partitioning = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// LogBucket lifecycle states (Beta). +enum LifecycleState { + // Unspecified state. This is only used/useful for distinguishing + // unset values. + LIFECYCLE_STATE_UNSPECIFIED = 0; + + // The normal and active state. + ACTIVE = 1; + + // The bucket has been marked for deletion by the user. + DELETE_REQUESTED = 2; +} + +// The parameters to `ListBuckets` (Beta). +message ListBucketsRequest { + // Required. The parent resource whose buckets are to be listed: + // + // "projects/[PROJECT_ID]/locations/[LOCATION_ID]" + // "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]" + // "folders/[FOLDER_ID]/locations/[LOCATION_ID]" + // + // Note: The locations portion of the resource must be specified, but + // supplying the character `-` in place of [LOCATION_ID] will return all + // buckets. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "logging.googleapis.com/LogBucket" + }]; + + // Optional. If present, then retrieve the next batch of results from the + // preceding call to this method. `pageToken` must be the value of + // `nextPageToken` from the previous response. The values of other method + // parameters should be identical to those in the previous call. + string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maximum number of results to return from this request. + // Non-positive values are ignored. The presence of `nextPageToken` in the + // response indicates that more results might be available. + int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response from ListBuckets (Beta). +message ListBucketsResponse { + // A list of buckets. + repeated LogBucket buckets = 1; + + // If there might be more results than appear in this response, then + // `nextPageToken` is included. To get the next set of results, call the same + // method again using the value of `nextPageToken` as `pageToken`. + string next_page_token = 2; +} + +// The parameters to `UpdateBucket` (Beta). +message UpdateBucketRequest { + // Required. The full resource name of the bucket to update. + // + // "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + // "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + // "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + // + // Example: + // `"projects/my-project-id/locations/my-location/buckets/my-bucket-id"`. Also + // requires permission "resourcemanager.projects.updateLiens" to set the + // locked property + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "logging.googleapis.com/LogBucket" + } + ]; + + // Required. The updated bucket. + LogBucket bucket = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. Field mask that specifies the fields in `bucket` that need an update. A + // bucket field will be overwritten if, and only if, it is in the update + // mask. `name` and output only fields cannot be updated. + // + // For a detailed `FieldMask` definition, see + // https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask + // + // Example: `updateMask=retention_days`. + google.protobuf.FieldMask update_mask = 4 [(google.api.field_behavior) = REQUIRED]; +} + +// The parameters to `GetBucket` (Beta). +message GetBucketRequest { + // Required. The resource name of the bucket: + // + // "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + // "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + // "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + // + // Example: + // `"projects/my-project-id/locations/my-location/buckets/my-bucket-id"`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "logging.googleapis.com/LogBucket" + } + ]; +} + +// The parameters to `ListSinks`. +message ListSinksRequest { + // Required. The parent resource whose sinks are to be listed: + // + // "projects/[PROJECT_ID]" + // "organizations/[ORGANIZATION_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]" + // "folders/[FOLDER_ID]" + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "logging.googleapis.com/LogSink" + } + ]; + + // Optional. If present, then retrieve the next batch of results from the + // preceding call to this method. `pageToken` must be the value of + // `nextPageToken` from the previous response. The values of other method + // parameters should be identical to those in the previous call. + string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maximum number of results to return from this request. + // Non-positive values are ignored. The presence of `nextPageToken` in the + // response indicates that more results might be available. + int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Result returned from `ListSinks`. +message ListSinksResponse { + // A list of sinks. + repeated LogSink sinks = 1; + + // If there might be more results than appear in this response, then + // `nextPageToken` is included. To get the next set of results, call the same + // method again using the value of `nextPageToken` as `pageToken`. + string next_page_token = 2; +} + +// The parameters to `GetSink`. +message GetSinkRequest { + // Required. The resource name of the sink: + // + // "projects/[PROJECT_ID]/sinks/[SINK_ID]" + // "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" + // "folders/[FOLDER_ID]/sinks/[SINK_ID]" + // + // Example: `"projects/my-project-id/sinks/my-sink-id"`. + string sink_name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "logging.googleapis.com/LogSink" + } + ]; +} + +// The parameters to `CreateSink`. +message CreateSinkRequest { + // Required. The resource in which to create the sink: + // + // "projects/[PROJECT_ID]" + // "organizations/[ORGANIZATION_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]" + // "folders/[FOLDER_ID]" + // + // Examples: `"projects/my-logging-project"`, `"organizations/123456789"`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "logging.googleapis.com/LogSink" + } + ]; + + // Required. The new sink, whose `name` parameter is a sink identifier that + // is not already in use. + LogSink sink = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Determines the kind of IAM identity returned as `writer_identity` + // in the new sink. If this value is omitted or set to false, and if the + // sink's parent is a project, then the value returned as `writer_identity` is + // the same group or service account used by Logging before the addition of + // writer identities to this API. The sink's destination must be in the same + // project as the sink itself. + // + // If this field is set to true, or if the sink is owned by a non-project + // resource such as an organization, then the value of `writer_identity` will + // be a unique service account used only for exports from the new sink. For + // more information, see `writer_identity` in [LogSink][google.logging.v2.LogSink]. + bool unique_writer_identity = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// The parameters to `UpdateSink`. +message UpdateSinkRequest { + // Required. The full resource name of the sink to update, including the parent + // resource and the sink identifier: + // + // "projects/[PROJECT_ID]/sinks/[SINK_ID]" + // "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" + // "folders/[FOLDER_ID]/sinks/[SINK_ID]" + // + // Example: `"projects/my-project-id/sinks/my-sink-id"`. + string sink_name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "logging.googleapis.com/LogSink" + } + ]; + + // Required. The updated sink, whose name is the same identifier that appears as part + // of `sink_name`. + LogSink sink = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. See [sinks.create][google.logging.v2.ConfigServiceV2.CreateSink] + // for a description of this field. When updating a sink, the effect of this + // field on the value of `writer_identity` in the updated sink depends on both + // the old and new values of this field: + // + // + If the old and new values of this field are both false or both true, + // then there is no change to the sink's `writer_identity`. + // + If the old value is false and the new value is true, then + // `writer_identity` is changed to a unique service account. + // + It is an error if the old value is true and the new value is + // set to false or defaulted to false. + bool unique_writer_identity = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Field mask that specifies the fields in `sink` that need + // an update. A sink field will be overwritten if, and only if, it is + // in the update mask. `name` and output only fields cannot be updated. + // + // An empty updateMask is temporarily treated as using the following mask + // for backwards compatibility purposes: + // destination,filter,includeChildren + // At some point in the future, behavior will be removed and specifying an + // empty updateMask will be an error. + // + // For a detailed `FieldMask` definition, see + // https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask + // + // Example: `updateMask=filter`. + google.protobuf.FieldMask update_mask = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// The parameters to `DeleteSink`. +message DeleteSinkRequest { + // Required. The full resource name of the sink to delete, including the parent + // resource and the sink identifier: + // + // "projects/[PROJECT_ID]/sinks/[SINK_ID]" + // "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" + // "folders/[FOLDER_ID]/sinks/[SINK_ID]" + // + // Example: `"projects/my-project-id/sinks/my-sink-id"`. + string sink_name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "logging.googleapis.com/LogSink" + } + ]; +} + +// Specifies a set of log entries that are not to be stored in +// Logging. If your GCP resource receives a large volume of logs, you can +// use exclusions to reduce your chargeable logs. Exclusions are +// processed after log sinks, so you can export log entries before they are +// excluded. Note that organization-level and folder-level exclusions don't +// apply to child resources, and that you can't exclude audit log entries. +message LogExclusion { + option (google.api.resource) = { + type: "logging.googleapis.com/LogExclusion" + pattern: "projects/{project}/exclusions/{exclusion}" + pattern: "organizations/{organization}/exclusions/{exclusion}" + pattern: "folders/{folder}/exclusions/{exclusion}" + pattern: "billingAccounts/{billing_account}/exclusions/{exclusion}" + }; + + // Required. A client-assigned identifier, such as `"load-balancer-exclusion"`. + // Identifiers are limited to 100 characters and can include only letters, + // digits, underscores, hyphens, and periods. First character has to be + // alphanumeric. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. A description of this exclusion. + string description = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Required. An [advanced logs filter](/logging/docs/view/advanced-queries) + // that matches the log entries to be excluded. By using the + // [sample function](/logging/docs/view/advanced-queries#sample), + // you can exclude less than 100% of the matching log entries. + // For example, the following query matches 99% of low-severity log + // entries from Google Cloud Storage buckets: + // + // `"resource.type=gcs_bucket severity=ERROR" + // + // The maximum length of the filter is 20000 characters. + string filter = 3 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The metric descriptor associated with the logs-based metric. + // If unspecified, it uses a default metric descriptor with a DELTA metric + // kind, INT64 value type, with no labels and a unit of "1". Such a metric + // counts the number of log entries matching the `filter` expression. + // + // The `name`, `type`, and `description` fields in the `metric_descriptor` + // are output only, and is constructed using the `name` and `description` + // field in the LogMetric. + // + // To create a logs-based metric that records a distribution of log values, a + // DELTA metric kind with a DISTRIBUTION value type must be used along with + // a `value_extractor` expression in the LogMetric. + // + // Each label in the metric descriptor must have a matching label + // name as the key and an extractor expression as the value in the + // `label_extractors` map. + // + // The `metric_kind` and `value_type` fields in the `metric_descriptor` cannot + // be updated once initially configured. New labels can be added in the + // `metric_descriptor`, but existing labels cannot be modified except for + // their description. + google.api.MetricDescriptor metric_descriptor = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A `value_extractor` is required when using a distribution + // logs-based metric to extract the values to record from a log entry. + // Two functions are supported for value extraction: `EXTRACT(field)` or + // `REGEXP_EXTRACT(field, regex)`. The argument are: + // 1. field: The name of the log entry field from which the value is to be + // extracted. + // 2. regex: A regular expression using the Google RE2 syntax + // (https://github.com/google/re2/wiki/Syntax) with a single capture + // group to extract data from the specified log entry field. The value + // of the field is converted to a string before applying the regex. + // It is an error to specify a regex that does not include exactly one + // capture group. + // + // The result of the extraction must be convertible to a double type, as the + // distribution always records double values. If either the extraction or + // the conversion to double fails, then those values are not recorded in the + // distribution. + // + // Example: `REGEXP_EXTRACT(jsonPayload.request, ".*quantity=(\d+).*")` + string value_extractor = 6 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A map from a label key string to an extractor expression which is + // used to extract data from a log entry field and assign as the label value. + // Each label key specified in the LabelDescriptor must have an associated + // extractor expression in this map. The syntax of the extractor expression + // is the same as for the `value_extractor` field. + // + // The extracted value is converted to the type defined in the label + // descriptor. If the either the extraction or the type conversion fails, + // the label will have a default value. The default value for a string + // label is an empty string, for an integer label its 0, and for a boolean + // label its `false`. + // + // Note that there are upper bounds on the maximum number of labels and the + // number of active time series that are allowed in a project. + map label_extractors = 7 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The `bucket_options` are required when the logs-based metric is + // using a DISTRIBUTION value type and it describes the bucket boundaries + // used to create a histogram of the extracted values. + google.api.Distribution.BucketOptions bucket_options = 8 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The creation timestamp of the metric. + // + // This field may not be present for older metrics. + google.protobuf.Timestamp create_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The last update timestamp of the metric. + // + // This field may not be present for older metrics. + google.protobuf.Timestamp update_time = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Deprecated. The API version that created or updated this metric. + // The v2 format is used by default and cannot be changed. + ApiVersion version = 4 [deprecated = true]; +} + +// The parameters to ListLogMetrics. +message ListLogMetricsRequest { + // Required. The name of the project containing the metrics: + // + // "projects/[PROJECT_ID]" + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Optional. If present, then retrieve the next batch of results from the + // preceding call to this method. `pageToken` must be the value of + // `nextPageToken` from the previous response. The values of other method + // parameters should be identical to those in the previous call. + string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maximum number of results to return from this request. + // Non-positive values are ignored. The presence of `nextPageToken` in the + // response indicates that more results might be available. + int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Result returned from ListLogMetrics. +message ListLogMetricsResponse { + // A list of logs-based metrics. + repeated LogMetric metrics = 1; + + // If there might be more results than appear in this response, then + // `nextPageToken` is included. To get the next set of results, call this + // method again using the value of `nextPageToken` as `pageToken`. + string next_page_token = 2; +} + +// The parameters to GetLogMetric. +message GetLogMetricRequest { + // Required. The resource name of the desired metric: + // + // "projects/[PROJECT_ID]/metrics/[METRIC_ID]" + string metric_name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "logging.googleapis.com/LogMetric" + } + ]; +} + +// The parameters to CreateLogMetric. +message CreateLogMetricRequest { + // Required. The resource name of the project in which to create the metric: + // + // "projects/[PROJECT_ID]" + // + // The new metric must be provided in the request. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "logging.googleapis.com/LogMetric" + } + ]; + + // Required. The new logs-based metric, which must not have an identifier that + // already exists. + LogMetric metric = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The parameters to UpdateLogMetric. +message UpdateLogMetricRequest { + // Required. The resource name of the metric to update: + // + // "projects/[PROJECT_ID]/metrics/[METRIC_ID]" + // + // The updated metric must be provided in the request and it's + // `name` field must be the same as `[METRIC_ID]` If the metric + // does not exist in `[PROJECT_ID]`, then a new metric is created. + string metric_name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "logging.googleapis.com/LogMetric" + } + ]; + + // Required. The updated metric. + LogMetric metric = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The parameters to DeleteLogMetric. +message DeleteLogMetricRequest { + // Required. The resource name of the metric to delete: + // + // "projects/[PROJECT_ID]/metrics/[METRIC_ID]" + string metric_name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "logging.googleapis.com/LogMetric" + } + ]; +} diff --git a/typescript/src/bundle.ts b/typescript/src/bundle.ts new file mode 100644 index 000000000..cdb8192d3 --- /dev/null +++ b/typescript/src/bundle.ts @@ -0,0 +1,86 @@ +export interface Thresholds { + element_count_threshold: number; + request_byte_threshold: number; + delay_threshold_millis: number; + element_count_limit?: number; +} +export interface BatchDescriptor { + batched_field: string; + discriminator_fields: string[]; + subresponse_field: string; +} +export interface BundleConfig { + serviceName: string; + methodName: string; + thresholds: Thresholds; + batchDescriptor: BatchDescriptor; + repeatedField?: string; +} + +export class BundleConfigClient { + bundleConfigs: BundleConfig[] = []; + // tslint:disable-next-line no-any + fromObject(yaml: any) { + // construct meaning Object from GAPIC v2 file. + const interfaces = yaml['interfaces']; + for (const oneInterface of interfaces) { + // service name: google.logging.v2.LoggingServiceV2 + const serviceName: string = oneInterface['name']; + const shortenedServiceName = serviceName.substring( + serviceName.lastIndexOf('.') + 1 + ); + if (!oneInterface['methods']) { + continue; + } + const methods = oneInterface['methods']; + for (const method of methods) { + if (!method['batching']) { + continue; + } + const name = method['name']; + const config = method['batching']; + const elementCountThreshold = + config['thresholds']['element_count_threshold']; + const requestByteThreshold = + config['thresholds']['request_byte_threshold']; + const delayThresholdMillis = + config['thresholds']['delay_threshold_millis']; + const elementCountLimit = + config['thresholds']['element_count_limit'] ?? 1000000; + const batchedField = config['batch_descriptor']['batched_field']; + const discriminatorFields = + config['batch_descriptor']['discriminator_fields']; + const oneBundleConfig: BundleConfig = { + serviceName: shortenedServiceName, + methodName: name, + thresholds: { + element_count_threshold: elementCountThreshold, + request_byte_threshold: requestByteThreshold, + delay_threshold_millis: delayThresholdMillis, + element_count_limit: elementCountLimit, + }, + batchDescriptor: { + batched_field: batchedField, + discriminator_fields: discriminatorFields, + subresponse_field: 'null', + }, + }; + if (config['batch_descriptor']['subresponse_field']) { + let subresponseField = + config['batch_descriptor']['subresponse_field']; + subresponseField = + subresponseField.length > 0 ? subresponseField : null; + Object.assign(oneBundleConfig, { + batchDescriptor: { + batched_field: batchedField, + discriminator_fields: discriminatorFields, + subresponse_field: subresponseField, + }, + }); + } + this.bundleConfigs.push(oneBundleConfig); + } + } + return this.bundleConfigs; + } +} diff --git a/typescript/src/generator.ts b/typescript/src/generator.ts index ccb3d03b0..37a927dcf 100644 --- a/typescript/src/generator.ts +++ b/typescript/src/generator.ts @@ -16,11 +16,13 @@ import * as getStdin from 'get-stdin'; import * as path from 'path'; import * as fs from 'fs'; import * as util from 'util'; +import * as yaml from 'js-yaml'; import * as plugin from '../../pbjs-genfiles/plugin'; import { API } from './schema/api'; import { processTemplates } from './templater'; +import { BundleConfigClient, BundleConfig } from './bundle'; import { commonPrefix, duration } from './util'; export interface OptionsMap { @@ -35,6 +37,7 @@ export class Generator { request: plugin.google.protobuf.compiler.CodeGeneratorRequest; response: plugin.google.protobuf.compiler.CodeGeneratorResponse; grpcServiceConfig: plugin.grpc.service_config.ServiceConfig; + bundleConfigs: BundleConfig[] = []; paramMap: OptionsMap; // This field is for users passing proper publish package name like @google-cloud/text-to-speech. publishName?: string; @@ -96,6 +99,18 @@ export class Generator { } } + private readBundleConfig() { + if (this.paramMap?.['bundle-config']) { + const filename = this.paramMap['bundle-config']; + if (!fs.existsSync(filename)) { + throw new Error(`File ${filename} cannot be opened.`); + } + const content = fs.readFileSync(filename, 'utf8'); + const info = yaml.safeLoad(content); + this.bundleConfigs = new BundleConfigClient().fromObject(info); + } + } + private readPublishPackageName() { this.publishName = this.paramMap['package-name']; } @@ -119,6 +134,7 @@ export class Generator { if (this.request.parameter) { this.getParamMap(this.request.parameter); await this.readGrpcServiceConfig(); + this.readBundleConfig(); this.readPublishPackageName(); this.readMainServiceName(); this.readTemplates(); @@ -154,6 +170,7 @@ export class Generator { } const api = new API(this.request.protoFile, packageName, { grpcServiceConfig: this.grpcServiceConfig, + bundleConfigs: this.bundleConfigs, publishName: this.publishName, mainServiceName: this.mainServiceName, }); diff --git a/typescript/src/schema/api.ts b/typescript/src/schema/api.ts index 768233c6c..d3007e51c 100644 --- a/typescript/src/schema/api.ts +++ b/typescript/src/schema/api.ts @@ -73,7 +73,8 @@ export class API { packageName, options.grpcServiceConfig, allResourceDatabase, - resourceDatabase + resourceDatabase, + options.bundleConfigs ); return map; }, {} as ProtosMap); diff --git a/typescript/src/schema/naming.ts b/typescript/src/schema/naming.ts index d32f2c5d7..892603852 100644 --- a/typescript/src/schema/naming.ts +++ b/typescript/src/schema/naming.ts @@ -15,9 +15,11 @@ import * as plugin from '../../../pbjs-genfiles/plugin'; import { commonPrefix } from '../util'; import { API } from './api'; +import { BundleConfig } from 'src/bundle'; export interface Options { grpcServiceConfig: plugin.grpc.service_config.ServiceConfig; + bundleConfigs?: BundleConfig[]; publishName?: string; mainServiceName?: string; } diff --git a/typescript/src/schema/proto.ts b/typescript/src/schema/proto.ts index c03f21121..eb6af6515 100644 --- a/typescript/src/schema/proto.ts +++ b/typescript/src/schema/proto.ts @@ -22,6 +22,7 @@ import { defaultNonIdempotentRetryCodesName, defaultParameters, } from './retryable-code-map'; +import { BundleConfig } from 'src/bundle'; interface MethodDescriptorProto extends plugin.google.protobuf.IMethodDescriptorProto { @@ -48,6 +49,7 @@ interface MethodDescriptorProto // into x-goog-request-params header, the array will contain // [ ['request', 'foo'], ['request', 'bar']] headerRequestParams: string[][]; + bundleConfig?: BundleConfig; } export interface ServiceDescriptorProto @@ -69,6 +71,8 @@ export interface ServiceDescriptorProto commentsMap: CommentsMap; retryableCodeMap: RetryableCodeMap; grpcServiceConfig: plugin.grpc.service_config.ServiceConfig; + bundleConfigsMethods: MethodDescriptorProto[]; + bundleConfigs?: BundleConfig[]; } export interface ServicesMap { @@ -318,6 +322,23 @@ function augmentMethod( }, method ) as MethodDescriptorProto; + const bundleConfigs = service.bundleConfigs; + if (bundleConfigs) { + for (const bc of bundleConfigs) { + if (bc.methodName === method.name) { + const inputType = messages[method.inputType!]; + const repeatedFields = inputType.field!.filter( + field => + field.label === + plugin.google.protobuf.FieldDescriptorProto.Label + .LABEL_REPEATED && + field.name === bc.batchDescriptor.batched_field + ); + bc.repeatedField = repeatedFields[0].typeName?.substring(1)!; + method.bundleConfig = bc; + } + } + } if (method.inputType && messages[method.inputType]?.field) { const paramComment: Comment[] = []; const inputType = messages[method.inputType!]; @@ -415,7 +436,8 @@ function augmentService( commentsMap: CommentsMap, grpcServiceConfig: plugin.grpc.service_config.ServiceConfig, allResourceDatabase: ResourceDatabase, - resourceDatabase: ResourceDatabase + resourceDatabase: ResourceDatabase, + bundleConfigs?: BundleConfig[] ) { const augmentedService = service as ServiceDescriptorProto; augmentedService.packageName = packageName; @@ -423,9 +445,15 @@ function augmentService( augmentedService.commentsMap = commentsMap; augmentedService.retryableCodeMap = new RetryableCodeMap(); augmentedService.grpcServiceConfig = grpcServiceConfig; + augmentedService.bundleConfigs = bundleConfigs?.filter( + bc => bc.serviceName === service.name + ); augmentedService.method = augmentedService.method.map(method => augmentMethod(messages, augmentedService, method) ); + augmentedService.bundleConfigsMethods = augmentedService.method.filter( + method => method.bundleConfig + ); augmentedService.simpleMethods = augmentedService.method.filter( method => !method.longRunning && !method.streaming && !method.pagingFieldName @@ -497,7 +525,6 @@ function augmentService( // 2. If this resource reference has .type, we should have a known resource with this type, check two maps. if (!resourceReference || !resourceReference.type) continue; - // console.warn('all resources: ', allResourceDatabase.types); const resourceByType = allResourceDatabase.getResourceByType( resourceReference?.type, errorLocation @@ -546,7 +573,8 @@ export class Proto { packageName: string, grpcServiceConfig: plugin.grpc.service_config.ServiceConfig, allResourceDatabase: ResourceDatabase, - resourceDatabase: ResourceDatabase + resourceDatabase: ResourceDatabase, + bundleConfigs?: BundleConfig[] ) { fd.enumType = fd.enumType || []; fd.messageType = fd.messageType || []; @@ -581,7 +609,8 @@ export class Proto { commentsMap, grpcServiceConfig, allResourceDatabase, - resourceDatabase + resourceDatabase, + bundleConfigs ) ) .reduce((map, service) => { diff --git a/typescript/src/start-script.ts b/typescript/src/start-script.ts index 37595a7ab..3b9108cc4 100755 --- a/typescript/src/start-script.ts +++ b/typescript/src/start-script.ts @@ -37,6 +37,8 @@ const argv = yargs .describe('output_dir', 'Path to a directory for the generated code') .alias('grpc-service-config', 'grpc_service_config') .describe('grpc-service-config', 'Path to gRPC service config JSON') + .alias('bundle-config', 'bundle_config') + .describe('bundle-config', 'Path to bundle request config JSON') .alias('package-name', 'package_name') .describe('package-name', 'Publish package name') .alias('main-service', 'main_service') @@ -58,6 +60,7 @@ const argv = yargs google/example/api/v1/api.proto`).argv; const outputDir = argv.outputDir as string; const grpcServiceConfig = argv.grpcServiceConfig as string | undefined; +const bundleConfig = argv.bundleConfig as string | undefined; const packageName = argv.packageName as string | undefined; const mainServiceName = argv.mainService as string | undefined; const template = argv.template as string | undefined; @@ -87,6 +90,9 @@ if (grpcServiceConfig) { `--typescript_gapic_opt="grpc-service-config=${grpcServiceConfig}"` ); } +if (bundleConfig) { + protocCommand.push(`--typescript_gapic_opt="bundle-config=${bundleConfig}"`); +} if (packageName) { protocCommand.push(`--typescript_gapic_opt="package-name=${packageName}"`); } diff --git a/typescript/test/unit/baselines.ts b/typescript/test/unit/baselines.ts index e32140562..1db5cd40e 100644 --- a/typescript/test/unit/baselines.ts +++ b/typescript/test/unit/baselines.ts @@ -80,6 +80,14 @@ describe('Baseline tests', () => { useCommonProto: false, }); + runBaselineTest({ + baselineName: 'logging', + outputDir: '.test-out-logging', + protoPath: 'google/logging/v2/*.proto', + useCommonProto: true, + bundleConfig: 'google/logging/v2/logging_gapic.yaml', + mainServiceName: 'LoggingService', + }); runBaselineTest({ baselineName: 'disable-packing-test', outputDir: '.test-out-disable-packing-test', diff --git a/typescript/test/util.ts b/typescript/test/util.ts index c313079b8..0ff2686b6 100644 --- a/typescript/test/util.ts +++ b/typescript/test/util.ts @@ -34,6 +34,7 @@ export interface BaselineOptions { grpcServiceConfig?: string; packageName?: string; template?: string; + bundleConfig?: string; } const cwd = process.cwd(); @@ -85,7 +86,9 @@ export function runBaselineTest(options: BaselineOptions) { options.grpcServiceConfig.split('/').join(path.sep) ) : undefined; - + const bundleConfig = options.bundleConfig + ? path.join(protosDirRoot, options.bundleConfig.split('/').join(path.sep)) + : undefined; it(options.baselineName, function() { this.timeout(60000); if (fs.existsSync(outputDir)) { @@ -111,6 +114,9 @@ export function runBaselineTest(options: BaselineOptions) { if (options.template) { commandLine += ` --template="${options.template}"`; } + if (options.bundleConfig) { + commandLine += ` --bundle-config="${bundleConfig}"`; + } execSync(commandLine); assert(equalToBaseline(outputDir, baselineDir));