diff --git a/Logging/metadata/V2/LogEntry.php b/Logging/metadata/V2/LogEntry.php index 1fb9f8cc0024..3c27339027ab 100644 Binary files a/Logging/metadata/V2/LogEntry.php and b/Logging/metadata/V2/LogEntry.php differ diff --git a/Logging/metadata/V2/Logging.php b/Logging/metadata/V2/Logging.php index 1882d67a25f9..7044c28ed168 100644 Binary files a/Logging/metadata/V2/Logging.php and b/Logging/metadata/V2/Logging.php differ diff --git a/Logging/metadata/V2/LoggingConfig.php b/Logging/metadata/V2/LoggingConfig.php index 48a86ea323ac..fa641b52d6cb 100644 Binary files a/Logging/metadata/V2/LoggingConfig.php and b/Logging/metadata/V2/LoggingConfig.php differ diff --git a/Logging/metadata/V2/LoggingMetrics.php b/Logging/metadata/V2/LoggingMetrics.php index 3968ffe15d06..f8ab4a96ed8e 100644 Binary files a/Logging/metadata/V2/LoggingMetrics.php and b/Logging/metadata/V2/LoggingMetrics.php differ diff --git a/Logging/src/V2/BigQueryOptions.php b/Logging/src/V2/BigQueryOptions.php index 04f164b8f84d..aee7a78c30ed 100644 --- a/Logging/src/V2/BigQueryOptions.php +++ b/Logging/src/V2/BigQueryOptions.php @@ -17,14 +17,15 @@ class BigQueryOptions extends \Google\Protobuf\Internal\Message { /** * 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 + * tables](https://cloud.google.com/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. + * syntax](https://cloud.google.com/bigquery/docs/querying-partitioned-tables) + * has to be used instead. In both cases, tables are sharded based on UTC + * timezone. * - * Generated from protobuf field bool use_partitioned_tables = 1; + * Generated from protobuf field bool use_partitioned_tables = 1 [(.google.api.field_behavior) = OPTIONAL]; */ private $use_partitioned_tables = false; /** @@ -47,12 +48,13 @@ class BigQueryOptions extends \Google\Protobuf\Internal\Message * * @type bool $use_partitioned_tables * 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 + * tables](https://cloud.google.com/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. + * syntax](https://cloud.google.com/bigquery/docs/querying-partitioned-tables) + * has to be used instead. In both cases, tables are sharded based on UTC + * timezone. * @type bool $uses_timestamp_column_partitioning * Output only. True if new timestamp column based partitioning is in use, * false if legacy ingestion-time partitioning is in use. @@ -69,14 +71,15 @@ public function __construct($data = NULL) { /** * 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 + * tables](https://cloud.google.com/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. + * syntax](https://cloud.google.com/bigquery/docs/querying-partitioned-tables) + * has to be used instead. In both cases, tables are sharded based on UTC + * timezone. * - * Generated from protobuf field bool use_partitioned_tables = 1; + * Generated from protobuf field bool use_partitioned_tables = 1 [(.google.api.field_behavior) = OPTIONAL]; * @return bool */ public function getUsePartitionedTables() @@ -86,14 +89,15 @@ public function getUsePartitionedTables() /** * 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 + * tables](https://cloud.google.com/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. + * syntax](https://cloud.google.com/bigquery/docs/querying-partitioned-tables) + * has to be used instead. In both cases, tables are sharded based on UTC + * timezone. * - * Generated from protobuf field bool use_partitioned_tables = 1; + * Generated from protobuf field bool use_partitioned_tables = 1 [(.google.api.field_behavior) = OPTIONAL]; * @param bool $var * @return $this */ diff --git a/Logging/src/V2/CmekSettings.php b/Logging/src/V2/CmekSettings.php index 839d99ba5bce..9e6a94784a10 100644 --- a/Logging/src/V2/CmekSettings.php +++ b/Logging/src/V2/CmekSettings.php @@ -14,17 +14,18 @@ * 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. + * See [Enabling CMEK for Logs + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) for + * more information. * * Generated from protobuf message google.logging.v2.CmekSettings */ class CmekSettings extends \Google\Protobuf\Internal\Message { /** - * Output Only. The resource name of the CMEK settings. + * Output only. The resource name of the CMEK settings. * - * Generated from protobuf field string name = 1; + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ private $name = ''; /** @@ -43,23 +44,25 @@ class CmekSettings extends \Google\Protobuf\Internal\Message * time of encryption unless access to that key has been revoked. * To disable CMEK for the Logs Router, set this field to an empty string. * See [Enabling CMEK for Logs - * Router](/logging/docs/routing/managed-encryption) for more information. + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. * * Generated from protobuf field string kms_key_name = 2; */ private $kms_key_name = ''; /** - * Output Only. The service account that will be used by the Logs Router to - * access your Cloud KMS key. + * Output only. The service account that will be used by the Logs Router to access your + * Cloud KMS key. * Before enabling CMEK for Logs Router, you must first assign the role * `roles/cloudkms.cryptoKeyEncrypterDecrypter` to the service account that * the Logs Router will use to access your Cloud KMS key. Use * [GetCmekSettings][google.logging.v2.ConfigServiceV2.GetCmekSettings] to * obtain the service account ID. * See [Enabling CMEK for Logs - * Router](/logging/docs/routing/managed-encryption) for more information. + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. * - * Generated from protobuf field string service_account_id = 3; + * Generated from protobuf field string service_account_id = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ private $service_account_id = ''; @@ -70,7 +73,7 @@ class CmekSettings extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $name - * Output Only. The resource name of the CMEK settings. + * Output only. The resource name of the CMEK settings. * @type string $kms_key_name * The resource name for the configured Cloud KMS key. * KMS key name format: @@ -87,17 +90,19 @@ class CmekSettings extends \Google\Protobuf\Internal\Message * time of encryption unless access to that key has been revoked. * To disable CMEK for the Logs Router, set this field to an empty string. * See [Enabling CMEK for Logs - * Router](/logging/docs/routing/managed-encryption) for more information. + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. * @type string $service_account_id - * Output Only. The service account that will be used by the Logs Router to - * access your Cloud KMS key. + * Output only. The service account that will be used by the Logs Router to access your + * Cloud KMS key. * Before enabling CMEK for Logs Router, you must first assign the role * `roles/cloudkms.cryptoKeyEncrypterDecrypter` to the service account that * the Logs Router will use to access your Cloud KMS key. Use * [GetCmekSettings][google.logging.v2.ConfigServiceV2.GetCmekSettings] to * obtain the service account ID. * See [Enabling CMEK for Logs - * Router](/logging/docs/routing/managed-encryption) for more information. + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. * } */ public function __construct($data = NULL) { @@ -106,9 +111,9 @@ public function __construct($data = NULL) { } /** - * Output Only. The resource name of the CMEK settings. + * Output only. The resource name of the CMEK settings. * - * Generated from protobuf field string name = 1; + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @return string */ public function getName() @@ -117,9 +122,9 @@ public function getName() } /** - * Output Only. The resource name of the CMEK settings. + * Output only. The resource name of the CMEK settings. * - * Generated from protobuf field string name = 1; + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @param string $var * @return $this */ @@ -147,7 +152,8 @@ public function setName($var) * time of encryption unless access to that key has been revoked. * To disable CMEK for the Logs Router, set this field to an empty string. * See [Enabling CMEK for Logs - * Router](/logging/docs/routing/managed-encryption) for more information. + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. * * Generated from protobuf field string kms_key_name = 2; * @return string @@ -173,7 +179,8 @@ public function getKmsKeyName() * time of encryption unless access to that key has been revoked. * To disable CMEK for the Logs Router, set this field to an empty string. * See [Enabling CMEK for Logs - * Router](/logging/docs/routing/managed-encryption) for more information. + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. * * Generated from protobuf field string kms_key_name = 2; * @param string $var @@ -188,17 +195,18 @@ public function setKmsKeyName($var) } /** - * Output Only. The service account that will be used by the Logs Router to - * access your Cloud KMS key. + * Output only. The service account that will be used by the Logs Router to access your + * Cloud KMS key. * Before enabling CMEK for Logs Router, you must first assign the role * `roles/cloudkms.cryptoKeyEncrypterDecrypter` to the service account that * the Logs Router will use to access your Cloud KMS key. Use * [GetCmekSettings][google.logging.v2.ConfigServiceV2.GetCmekSettings] to * obtain the service account ID. * See [Enabling CMEK for Logs - * Router](/logging/docs/routing/managed-encryption) for more information. + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. * - * Generated from protobuf field string service_account_id = 3; + * Generated from protobuf field string service_account_id = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @return string */ public function getServiceAccountId() @@ -207,17 +215,18 @@ public function getServiceAccountId() } /** - * Output Only. The service account that will be used by the Logs Router to - * access your Cloud KMS key. + * Output only. The service account that will be used by the Logs Router to access your + * Cloud KMS key. * Before enabling CMEK for Logs Router, you must first assign the role * `roles/cloudkms.cryptoKeyEncrypterDecrypter` to the service account that * the Logs Router will use to access your Cloud KMS key. Use * [GetCmekSettings][google.logging.v2.ConfigServiceV2.GetCmekSettings] to * obtain the service account ID. * See [Enabling CMEK for Logs - * Router](/logging/docs/routing/managed-encryption) for more information. + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. * - * Generated from protobuf field string service_account_id = 3; + * Generated from protobuf field string service_account_id = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @param string $var * @return $this */ diff --git a/Logging/src/V2/ConfigServiceV2Client.php b/Logging/src/V2/ConfigServiceV2Client.php index 19a0756f7be5..8b96ad427503 100644 --- a/Logging/src/V2/ConfigServiceV2Client.php +++ b/Logging/src/V2/ConfigServiceV2Client.php @@ -17,22 +17,18 @@ /* * GENERATED CODE WARNING - * This file was generated from the file - * https://github.com/google/googleapis/blob/master/google/logging/v2/logging_config.proto - * and updates to that file get reflected here through a refresh process. - * - * @experimental + * Generated by gapic-generator-php from the file + * https://github.com/googleapis/googleapis/blob/master/google/logging/v2/logging_config.proto + * Updates to the above are reflected here through a refresh process. */ namespace Google\Cloud\Logging\V2; use Google\Cloud\Logging\V2\Gapic\ConfigServiceV2GapicClient; -/** - * {@inheritdoc} - */ +/** {@inheritdoc} */ class ConfigServiceV2Client extends ConfigServiceV2GapicClient { - // This class is intentionally empty, and is intended to hold manual - // additions to the generated {@see ConfigServiceV2GapicClient} class. + // This class is intentionally empty, and is intended to hold manual additions to + // the generated {@see ConfigServiceV2GapicClient} class. } diff --git a/Logging/src/V2/ConfigServiceV2GrpcClient.php b/Logging/src/V2/ConfigServiceV2GrpcClient.php index 91145050a3bb..09b58f86f995 100644 --- a/Logging/src/V2/ConfigServiceV2GrpcClient.php +++ b/Logging/src/V2/ConfigServiceV2GrpcClient.php @@ -2,7 +2,7 @@ // GENERATED CODE -- DO NOT EDIT! // Original file comments: -// Copyright 2019 Google LLC. +// 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. @@ -16,7 +16,6 @@ // See the License for the specific language governing permissions and // limitations under the License. // -// namespace Google\Cloud\Logging\V2; /** @@ -33,11 +32,193 @@ public function __construct($hostname, $opts, $channel = null) { parent::__construct($hostname, $opts, $channel); } + /** + * Lists buckets. + * @param \Google\Cloud\Logging\V2\ListBucketsRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + * @return \Grpc\UnaryCall + */ + public function ListBuckets(\Google\Cloud\Logging\V2\ListBucketsRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.logging.v2.ConfigServiceV2/ListBuckets', + $argument, + ['\Google\Cloud\Logging\V2\ListBucketsResponse', 'decode'], + $metadata, $options); + } + + /** + * Gets a bucket. + * @param \Google\Cloud\Logging\V2\GetBucketRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + * @return \Grpc\UnaryCall + */ + public function GetBucket(\Google\Cloud\Logging\V2\GetBucketRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.logging.v2.ConfigServiceV2/GetBucket', + $argument, + ['\Google\Cloud\Logging\V2\LogBucket', 'decode'], + $metadata, $options); + } + + /** + * Creates a bucket that can be used to store log entries. Once a bucket has + * been created, the region cannot be changed. + * @param \Google\Cloud\Logging\V2\CreateBucketRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + * @return \Grpc\UnaryCall + */ + public function CreateBucket(\Google\Cloud\Logging\V2\CreateBucketRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.logging.v2.ConfigServiceV2/CreateBucket', + $argument, + ['\Google\Cloud\Logging\V2\LogBucket', 'decode'], + $metadata, $options); + } + + /** + * 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. + * @param \Google\Cloud\Logging\V2\UpdateBucketRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + * @return \Grpc\UnaryCall + */ + public function UpdateBucket(\Google\Cloud\Logging\V2\UpdateBucketRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.logging.v2.ConfigServiceV2/UpdateBucket', + $argument, + ['\Google\Cloud\Logging\V2\LogBucket', 'decode'], + $metadata, $options); + } + + /** + * Deletes a bucket. + * Moves the bucket to the DELETE_REQUESTED state. After 7 days, the + * bucket will be purged and all logs in the bucket will be permanently + * deleted. + * @param \Google\Cloud\Logging\V2\DeleteBucketRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + * @return \Grpc\UnaryCall + */ + public function DeleteBucket(\Google\Cloud\Logging\V2\DeleteBucketRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.logging.v2.ConfigServiceV2/DeleteBucket', + $argument, + ['\Google\Protobuf\GPBEmpty', 'decode'], + $metadata, $options); + } + + /** + * Undeletes a bucket. A bucket that has been deleted may be undeleted within + * the grace period of 7 days. + * @param \Google\Cloud\Logging\V2\UndeleteBucketRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + * @return \Grpc\UnaryCall + */ + public function UndeleteBucket(\Google\Cloud\Logging\V2\UndeleteBucketRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.logging.v2.ConfigServiceV2/UndeleteBucket', + $argument, + ['\Google\Protobuf\GPBEmpty', 'decode'], + $metadata, $options); + } + + /** + * Lists views on a bucket. + * @param \Google\Cloud\Logging\V2\ListViewsRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + * @return \Grpc\UnaryCall + */ + public function ListViews(\Google\Cloud\Logging\V2\ListViewsRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.logging.v2.ConfigServiceV2/ListViews', + $argument, + ['\Google\Cloud\Logging\V2\ListViewsResponse', 'decode'], + $metadata, $options); + } + + /** + * Gets a view. + * @param \Google\Cloud\Logging\V2\GetViewRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + * @return \Grpc\UnaryCall + */ + public function GetView(\Google\Cloud\Logging\V2\GetViewRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.logging.v2.ConfigServiceV2/GetView', + $argument, + ['\Google\Cloud\Logging\V2\LogView', 'decode'], + $metadata, $options); + } + + /** + * Creates a view over logs in a bucket. A bucket may contain a maximum of + * 50 views. + * @param \Google\Cloud\Logging\V2\CreateViewRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + * @return \Grpc\UnaryCall + */ + public function CreateView(\Google\Cloud\Logging\V2\CreateViewRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.logging.v2.ConfigServiceV2/CreateView', + $argument, + ['\Google\Cloud\Logging\V2\LogView', 'decode'], + $metadata, $options); + } + + /** + * Updates a view. This method replaces the following fields in the existing + * view with values from the new view: `filter`. + * @param \Google\Cloud\Logging\V2\UpdateViewRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + * @return \Grpc\UnaryCall + */ + public function UpdateView(\Google\Cloud\Logging\V2\UpdateViewRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.logging.v2.ConfigServiceV2/UpdateView', + $argument, + ['\Google\Cloud\Logging\V2\LogView', 'decode'], + $metadata, $options); + } + + /** + * Deletes a view from a bucket. + * @param \Google\Cloud\Logging\V2\DeleteViewRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + * @return \Grpc\UnaryCall + */ + public function DeleteView(\Google\Cloud\Logging\V2\DeleteViewRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.logging.v2.ConfigServiceV2/DeleteView', + $argument, + ['\Google\Protobuf\GPBEmpty', 'decode'], + $metadata, $options); + } + /** * Lists sinks. * @param \Google\Cloud\Logging\V2\ListSinksRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function ListSinks(\Google\Cloud\Logging\V2\ListSinksRequest $argument, $metadata = [], $options = []) { @@ -52,6 +233,7 @@ public function ListSinks(\Google\Cloud\Logging\V2\ListSinksRequest $argument, * @param \Google\Cloud\Logging\V2\GetSinkRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function GetSink(\Google\Cloud\Logging\V2\GetSinkRequest $argument, $metadata = [], $options = []) { @@ -69,6 +251,7 @@ public function GetSink(\Google\Cloud\Logging\V2\GetSinkRequest $argument, * @param \Google\Cloud\Logging\V2\CreateSinkRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function CreateSink(\Google\Cloud\Logging\V2\CreateSinkRequest $argument, $metadata = [], $options = []) { @@ -87,6 +270,7 @@ public function CreateSink(\Google\Cloud\Logging\V2\CreateSinkRequest $argument, * @param \Google\Cloud\Logging\V2\UpdateSinkRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function UpdateSink(\Google\Cloud\Logging\V2\UpdateSinkRequest $argument, $metadata = [], $options = []) { @@ -102,6 +286,7 @@ public function UpdateSink(\Google\Cloud\Logging\V2\UpdateSinkRequest $argument, * @param \Google\Cloud\Logging\V2\DeleteSinkRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function DeleteSink(\Google\Cloud\Logging\V2\DeleteSinkRequest $argument, $metadata = [], $options = []) { @@ -116,6 +301,7 @@ public function DeleteSink(\Google\Cloud\Logging\V2\DeleteSinkRequest $argument, * @param \Google\Cloud\Logging\V2\ListExclusionsRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function ListExclusions(\Google\Cloud\Logging\V2\ListExclusionsRequest $argument, $metadata = [], $options = []) { @@ -130,6 +316,7 @@ public function ListExclusions(\Google\Cloud\Logging\V2\ListExclusionsRequest $a * @param \Google\Cloud\Logging\V2\GetExclusionRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function GetExclusion(\Google\Cloud\Logging\V2\GetExclusionRequest $argument, $metadata = [], $options = []) { @@ -146,6 +333,7 @@ public function GetExclusion(\Google\Cloud\Logging\V2\GetExclusionRequest $argum * @param \Google\Cloud\Logging\V2\CreateExclusionRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function CreateExclusion(\Google\Cloud\Logging\V2\CreateExclusionRequest $argument, $metadata = [], $options = []) { @@ -160,6 +348,7 @@ public function CreateExclusion(\Google\Cloud\Logging\V2\CreateExclusionRequest * @param \Google\Cloud\Logging\V2\UpdateExclusionRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function UpdateExclusion(\Google\Cloud\Logging\V2\UpdateExclusionRequest $argument, $metadata = [], $options = []) { @@ -174,6 +363,7 @@ public function UpdateExclusion(\Google\Cloud\Logging\V2\UpdateExclusionRequest * @param \Google\Cloud\Logging\V2\DeleteExclusionRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function DeleteExclusion(\Google\Cloud\Logging\V2\DeleteExclusionRequest $argument, $metadata = [], $options = []) { @@ -191,10 +381,12 @@ public function DeleteExclusion(\Google\Cloud\Logging\V2\DeleteExclusionRequest * the GCP organization. * * See [Enabling CMEK for Logs - * Router](/logging/docs/routing/managed-encryption) for more information. + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. * @param \Google\Cloud\Logging\V2\GetCmekSettingsRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function GetCmekSettings(\Google\Cloud\Logging\V2\GetCmekSettingsRequest $argument, $metadata = [], $options = []) { @@ -218,10 +410,12 @@ public function GetCmekSettings(\Google\Cloud\Logging\V2\GetCmekSettingsRequest * 3) access to the key is disabled. * * See [Enabling CMEK for Logs - * Router](/logging/docs/routing/managed-encryption) for more information. + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. * @param \Google\Cloud\Logging\V2\UpdateCmekSettingsRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function UpdateCmekSettings(\Google\Cloud\Logging\V2\UpdateCmekSettingsRequest $argument, $metadata = [], $options = []) { diff --git a/Logging/src/V2/CreateBucketRequest.php b/Logging/src/V2/CreateBucketRequest.php new file mode 100644 index 000000000000..7c8be501f421 --- /dev/null +++ b/Logging/src/V2/CreateBucketRequest.php @@ -0,0 +1,169 @@ +google.logging.v2.CreateBucketRequest + */ +class CreateBucketRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The resource in which to create the bucket: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]" + * Example: `"projects/my-logging-project/locations/global"` + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * Required. A client-assigned identifier such as `"my-bucket"`. Identifiers are + * limited to 100 characters and can include only letters, digits, + * underscores, hyphens, and periods. + * + * Generated from protobuf field string bucket_id = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $bucket_id = ''; + /** + * Required. The new bucket. The region specified in the new bucket must be compliant + * with any Location Restriction Org Policy. The name field in the bucket is + * ignored. + * + * Generated from protobuf field .google.logging.v2.LogBucket bucket = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + private $bucket = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The resource in which to create the bucket: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]" + * Example: `"projects/my-logging-project/locations/global"` + * @type string $bucket_id + * Required. A client-assigned identifier such as `"my-bucket"`. Identifiers are + * limited to 100 characters and can include only letters, digits, + * underscores, hyphens, and periods. + * @type \Google\Cloud\Logging\V2\LogBucket $bucket + * Required. The new bucket. The region specified in the new bucket must be compliant + * with any Location Restriction Org Policy. The name field in the bucket is + * ignored. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Logging\V2\LoggingConfig::initOnce(); + parent::__construct($data); + } + + /** + * Required. The resource in which to create the bucket: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]" + * Example: `"projects/my-logging-project/locations/global"` + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The resource in which to create the bucket: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]" + * Example: `"projects/my-logging-project/locations/global"` + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Required. A client-assigned identifier such as `"my-bucket"`. Identifiers are + * limited to 100 characters and can include only letters, digits, + * underscores, hyphens, and periods. + * + * Generated from protobuf field string bucket_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getBucketId() + { + return $this->bucket_id; + } + + /** + * Required. A client-assigned identifier such as `"my-bucket"`. Identifiers are + * limited to 100 characters and can include only letters, digits, + * underscores, hyphens, and periods. + * + * Generated from protobuf field string bucket_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setBucketId($var) + { + GPBUtil::checkString($var, True); + $this->bucket_id = $var; + + return $this; + } + + /** + * Required. The new bucket. The region specified in the new bucket must be compliant + * with any Location Restriction Org Policy. The name field in the bucket is + * ignored. + * + * Generated from protobuf field .google.logging.v2.LogBucket bucket = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Logging\V2\LogBucket|null + */ + public function getBucket() + { + return $this->bucket; + } + + public function hasBucket() + { + return isset($this->bucket); + } + + public function clearBucket() + { + unset($this->bucket); + } + + /** + * Required. The new bucket. The region specified in the new bucket must be compliant + * with any Location Restriction Org Policy. The name field in the bucket is + * ignored. + * + * Generated from protobuf field .google.logging.v2.LogBucket bucket = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Logging\V2\LogBucket $var + * @return $this + */ + public function setBucket($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Logging\V2\LogBucket::class); + $this->bucket = $var; + + return $this; + } + +} + diff --git a/Logging/src/V2/CreateExclusionRequest.php b/Logging/src/V2/CreateExclusionRequest.php index bc282e5478fe..3a16d84e90a0 100644 --- a/Logging/src/V2/CreateExclusionRequest.php +++ b/Logging/src/V2/CreateExclusionRequest.php @@ -30,7 +30,7 @@ class CreateExclusionRequest extends \Google\Protobuf\Internal\Message * Required. The new exclusion, whose `name` parameter is an exclusion name * that is not already used in the parent resource. * - * Generated from protobuf field .google.logging.v2.LogExclusion exclusion = 2; + * Generated from protobuf field .google.logging.v2.LogExclusion exclusion = 2 [(.google.api.field_behavior) = REQUIRED]; */ private $exclusion = null; @@ -97,19 +97,29 @@ public function setParent($var) * Required. The new exclusion, whose `name` parameter is an exclusion name * that is not already used in the parent resource. * - * Generated from protobuf field .google.logging.v2.LogExclusion exclusion = 2; - * @return \Google\Cloud\Logging\V2\LogExclusion + * Generated from protobuf field .google.logging.v2.LogExclusion exclusion = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Logging\V2\LogExclusion|null */ public function getExclusion() { return $this->exclusion; } + public function hasExclusion() + { + return isset($this->exclusion); + } + + public function clearExclusion() + { + unset($this->exclusion); + } + /** * Required. The new exclusion, whose `name` parameter is an exclusion name * that is not already used in the parent resource. * - * Generated from protobuf field .google.logging.v2.LogExclusion exclusion = 2; + * Generated from protobuf field .google.logging.v2.LogExclusion exclusion = 2 [(.google.api.field_behavior) = REQUIRED]; * @param \Google\Cloud\Logging\V2\LogExclusion $var * @return $this */ diff --git a/Logging/src/V2/CreateLogMetricRequest.php b/Logging/src/V2/CreateLogMetricRequest.php index f51d7b180691..d23f7faf5dd3 100644 --- a/Logging/src/V2/CreateLogMetricRequest.php +++ b/Logging/src/V2/CreateLogMetricRequest.php @@ -86,13 +86,23 @@ public function setParent($var) * already exists. * * Generated from protobuf field .google.logging.v2.LogMetric metric = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Logging\V2\LogMetric + * @return \Google\Cloud\Logging\V2\LogMetric|null */ public function getMetric() { return $this->metric; } + public function hasMetric() + { + return isset($this->metric); + } + + public function clearMetric() + { + unset($this->metric); + } + /** * Required. The new logs-based metric, which must not have an identifier that * already exists. diff --git a/Logging/src/V2/CreateSinkRequest.php b/Logging/src/V2/CreateSinkRequest.php index 0911541443c6..8d283b1687a5 100644 --- a/Logging/src/V2/CreateSinkRequest.php +++ b/Logging/src/V2/CreateSinkRequest.php @@ -45,7 +45,7 @@ class CreateSinkRequest extends \Google\Protobuf\Internal\Message * 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]. * - * Generated from protobuf field bool unique_writer_identity = 3; + * Generated from protobuf field bool unique_writer_identity = 3 [(.google.api.field_behavior) = OPTIONAL]; */ private $unique_writer_identity = false; @@ -124,13 +124,23 @@ public function setParent($var) * is not already in use. * * Generated from protobuf field .google.logging.v2.LogSink sink = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Logging\V2\LogSink + * @return \Google\Cloud\Logging\V2\LogSink|null */ public function getSink() { return $this->sink; } + public function hasSink() + { + return isset($this->sink); + } + + public function clearSink() + { + unset($this->sink); + } + /** * Required. The new sink, whose `name` parameter is a sink identifier that * is not already in use. @@ -159,7 +169,7 @@ public function setSink($var) * 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]. * - * Generated from protobuf field bool unique_writer_identity = 3; + * Generated from protobuf field bool unique_writer_identity = 3 [(.google.api.field_behavior) = OPTIONAL]; * @return bool */ public function getUniqueWriterIdentity() @@ -179,7 +189,7 @@ public function getUniqueWriterIdentity() * 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]. * - * Generated from protobuf field bool unique_writer_identity = 3; + * Generated from protobuf field bool unique_writer_identity = 3 [(.google.api.field_behavior) = OPTIONAL]; * @param bool $var * @return $this */ diff --git a/Logging/src/V2/CreateViewRequest.php b/Logging/src/V2/CreateViewRequest.php new file mode 100644 index 000000000000..a61cc0a3e0f0 --- /dev/null +++ b/Logging/src/V2/CreateViewRequest.php @@ -0,0 +1,157 @@ +google.logging.v2.CreateViewRequest + */ +class CreateViewRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The bucket in which to create the view + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * Example: + * `"projects/my-logging-project/locations/my-location/buckets/my-bucket"` + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + private $parent = ''; + /** + * Required. The id to use for this view. + * + * Generated from protobuf field string view_id = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $view_id = ''; + /** + * Required. The new view. + * + * Generated from protobuf field .google.logging.v2.LogView view = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + private $view = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The bucket in which to create the view + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * Example: + * `"projects/my-logging-project/locations/my-location/buckets/my-bucket"` + * @type string $view_id + * Required. The id to use for this view. + * @type \Google\Cloud\Logging\V2\LogView $view + * Required. The new view. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Logging\V2\LoggingConfig::initOnce(); + parent::__construct($data); + } + + /** + * Required. The bucket in which to create the view + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * Example: + * `"projects/my-logging-project/locations/my-location/buckets/my-bucket"` + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The bucket in which to create the view + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * Example: + * `"projects/my-logging-project/locations/my-location/buckets/my-bucket"` + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Required. The id to use for this view. + * + * Generated from protobuf field string view_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getViewId() + { + return $this->view_id; + } + + /** + * Required. The id to use for this view. + * + * Generated from protobuf field string view_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setViewId($var) + { + GPBUtil::checkString($var, True); + $this->view_id = $var; + + return $this; + } + + /** + * Required. The new view. + * + * Generated from protobuf field .google.logging.v2.LogView view = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Logging\V2\LogView|null + */ + public function getView() + { + return $this->view; + } + + public function hasView() + { + return isset($this->view); + } + + public function clearView() + { + unset($this->view); + } + + /** + * Required. The new view. + * + * Generated from protobuf field .google.logging.v2.LogView view = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Logging\V2\LogView $var + * @return $this + */ + public function setView($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Logging\V2\LogView::class); + $this->view = $var; + + return $this; + } + +} + diff --git a/Logging/src/V2/DeleteBucketRequest.php b/Logging/src/V2/DeleteBucketRequest.php new file mode 100644 index 000000000000..6a8bbe704f17 --- /dev/null +++ b/Logging/src/V2/DeleteBucketRequest.php @@ -0,0 +1,91 @@ +google.logging.v2.DeleteBucketRequest + */ +class DeleteBucketRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The full resource name of the bucket to delete. + * "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"`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The full resource name of the bucket to delete. + * "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"`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Logging\V2\LoggingConfig::initOnce(); + parent::__construct($data); + } + + /** + * Required. The full resource name of the bucket to delete. + * "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"`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. The full resource name of the bucket to delete. + * "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"`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/Logging/src/V2/DeleteSinkRequest.php b/Logging/src/V2/DeleteSinkRequest.php index 0e827fdea4e3..74f965eaf2d4 100644 --- a/Logging/src/V2/DeleteSinkRequest.php +++ b/Logging/src/V2/DeleteSinkRequest.php @@ -16,8 +16,8 @@ class DeleteSinkRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The full resource name of the sink to delete, including the - * parent resource and the sink identifier: + * 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]" @@ -35,8 +35,8 @@ class DeleteSinkRequest extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $sink_name - * Required. The full resource name of the sink to delete, including the - * parent resource and the sink identifier: + * 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]" @@ -50,8 +50,8 @@ public function __construct($data = NULL) { } /** - * Required. The full resource name of the sink to delete, including the - * parent resource and the sink identifier: + * 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]" @@ -67,8 +67,8 @@ public function getSinkName() } /** - * Required. The full resource name of the sink to delete, including the - * parent resource and the sink identifier: + * 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]" diff --git a/Logging/src/V2/DeleteViewRequest.php b/Logging/src/V2/DeleteViewRequest.php new file mode 100644 index 000000000000..16958a7d6674 --- /dev/null +++ b/Logging/src/V2/DeleteViewRequest.php @@ -0,0 +1,79 @@ +google.logging.v2.DeleteViewRequest + */ +class DeleteViewRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The full resource name of the view to delete: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * Example: + * `"projects/my-project-id/locations/my-location/buckets/my-bucket-id/views/my-view-id"`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The full resource name of the view to delete: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * Example: + * `"projects/my-project-id/locations/my-location/buckets/my-bucket-id/views/my-view-id"`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Logging\V2\LoggingConfig::initOnce(); + parent::__construct($data); + } + + /** + * Required. The full resource name of the view to delete: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * Example: + * `"projects/my-project-id/locations/my-location/buckets/my-bucket-id/views/my-view-id"`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. The full resource name of the view to delete: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * Example: + * `"projects/my-project-id/locations/my-location/buckets/my-bucket-id/views/my-view-id"`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/Logging/src/V2/Gapic/ConfigServiceV2GapicClient.php b/Logging/src/V2/Gapic/ConfigServiceV2GapicClient.php index f124c8ba625e..ba89e77e0e23 100644 --- a/Logging/src/V2/Gapic/ConfigServiceV2GapicClient.php +++ b/Logging/src/V2/Gapic/ConfigServiceV2GapicClient.php @@ -17,11 +17,9 @@ /* * GENERATED CODE WARNING - * This file was generated from the file - * https://github.com/google/googleapis/blob/master/google/logging/v2/logging_config.proto - * and updates to that file get reflected here through a refresh process. - * - * @experimental + * Generated by gapic-generator-php from the file + * https://github.com/googleapis/googleapis/blob/master/google/logging/v2/logging_config.proto + * Updates to the above are reflected here through a refresh process. */ namespace Google\Cloud\Logging\V2\Gapic; @@ -29,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; + use Google\ApiCore\PathTemplate; use Google\ApiCore\RequestParamsHeaderDescriptor; use Google\ApiCore\RetrySettings; @@ -36,22 +35,37 @@ use Google\ApiCore\ValidationException; use Google\Auth\FetchAuthTokenInterface; use Google\Cloud\Logging\V2\CmekSettings; +use Google\Cloud\Logging\V2\CreateBucketRequest; use Google\Cloud\Logging\V2\CreateExclusionRequest; use Google\Cloud\Logging\V2\CreateSinkRequest; +use Google\Cloud\Logging\V2\CreateViewRequest; +use Google\Cloud\Logging\V2\DeleteBucketRequest; use Google\Cloud\Logging\V2\DeleteExclusionRequest; use Google\Cloud\Logging\V2\DeleteSinkRequest; +use Google\Cloud\Logging\V2\DeleteViewRequest; +use Google\Cloud\Logging\V2\GetBucketRequest; use Google\Cloud\Logging\V2\GetCmekSettingsRequest; use Google\Cloud\Logging\V2\GetExclusionRequest; use Google\Cloud\Logging\V2\GetSinkRequest; +use Google\Cloud\Logging\V2\GetViewRequest; +use Google\Cloud\Logging\V2\ListBucketsRequest; +use Google\Cloud\Logging\V2\ListBucketsResponse; use Google\Cloud\Logging\V2\ListExclusionsRequest; use Google\Cloud\Logging\V2\ListExclusionsResponse; use Google\Cloud\Logging\V2\ListSinksRequest; use Google\Cloud\Logging\V2\ListSinksResponse; +use Google\Cloud\Logging\V2\ListViewsRequest; +use Google\Cloud\Logging\V2\ListViewsResponse; +use Google\Cloud\Logging\V2\LogBucket; use Google\Cloud\Logging\V2\LogExclusion; use Google\Cloud\Logging\V2\LogSink; +use Google\Cloud\Logging\V2\LogView; +use Google\Cloud\Logging\V2\UndeleteBucketRequest; +use Google\Cloud\Logging\V2\UpdateBucketRequest; use Google\Cloud\Logging\V2\UpdateCmekSettingsRequest; use Google\Cloud\Logging\V2\UpdateExclusionRequest; use Google\Cloud\Logging\V2\UpdateSinkRequest; +use Google\Cloud\Logging\V2\UpdateViewRequest; use Google\Protobuf\FieldMask; use Google\Protobuf\GPBEmpty; @@ -64,34 +78,19 @@ * ``` * $configServiceV2Client = new ConfigServiceV2Client(); * try { - * $formattedParent = $configServiceV2Client->projectName('[PROJECT]'); - * // Iterate over pages of elements - * $pagedResponse = $configServiceV2Client->listSinks($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * - * - * // Alternatively: - * - * // Iterate through all elements - * $pagedResponse = $configServiceV2Client->listSinks($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } + * $formattedParent = $configServiceV2Client->organizationLocationName('[ORGANIZATION]', '[LOCATION]'); + * $bucketId = 'bucket_id'; + * $bucket = new LogBucket(); + * $response = $configServiceV2Client->createBucket($formattedParent, $bucketId, $bucket); * } finally { * $configServiceV2Client->close(); * } * ``` * - * Many parameters require resource names to be formatted in a particular way. To assist - * with these names, this class includes a format method for each type of name, and additionally - * a parseName method to extract the individual identifiers contained within formatted names - * that are returned by the API. - * - * @experimental + * Many parameters require resource names to be formatted in a particular way. To + * assist with these names, this class includes a format method for each type of + * name, and additionally a parseName method to extract the individual identifiers + * contained within formatted names that are returned by the API. */ class ConfigServiceV2GapicClient { @@ -125,125 +124,332 @@ class ConfigServiceV2GapicClient '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', ]; - private static $billingNameTemplate; - private static $billingExclusionNameTemplate; - private static $billingSinkNameTemplate; - private static $exclusionNameTemplate; + + private static $billingAccountNameTemplate; + + private static $billingAccountCmekSettingsNameTemplate; + + private static $billingAccountExclusionNameTemplate; + + private static $billingAccountLocationNameTemplate; + + private static $billingAccountLocationBucketNameTemplate; + + private static $billingAccountLocationBucketViewNameTemplate; + + private static $billingAccountSinkNameTemplate; + + private static $cmekSettingsNameTemplate; + private static $folderNameTemplate; + + private static $folderCmekSettingsNameTemplate; + private static $folderExclusionNameTemplate; + + private static $folderLocationNameTemplate; + + private static $folderLocationBucketNameTemplate; + + private static $folderLocationBucketViewNameTemplate; + private static $folderSinkNameTemplate; + + private static $locationNameTemplate; + + private static $logBucketNameTemplate; + + private static $logExclusionNameTemplate; + + private static $logSinkNameTemplate; + + private static $logViewNameTemplate; + private static $organizationNameTemplate; + + private static $organizationCmekSettingsNameTemplate; + private static $organizationExclusionNameTemplate; + + private static $organizationLocationNameTemplate; + + private static $organizationLocationBucketNameTemplate; + + private static $organizationLocationBucketViewNameTemplate; + private static $organizationSinkNameTemplate; + private static $projectNameTemplate; - private static $sinkNameTemplate; + + private static $projectCmekSettingsNameTemplate; + + private static $projectExclusionNameTemplate; + + private static $projectLocationBucketNameTemplate; + + private static $projectLocationBucketViewNameTemplate; + + private static $projectSinkNameTemplate; + private static $pathTemplateMap; private static function getClientDefaults() { return [ 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS.':'.self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__.'/../resources/config_service_v2_client_config.json', - 'descriptorsConfigPath' => __DIR__.'/../resources/config_service_v2_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__.'/../resources/config_service_v2_grpc_config.json', + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/config_service_v2_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/config_service_v2_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/config_service_v2_grpc_config.json', 'credentialsConfig' => [ - 'scopes' => self::$serviceScopes, + 'defaultScopes' => self::$serviceScopes, ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => __DIR__.'/../resources/config_service_v2_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/config_service_v2_rest_client_config.php', ], ], ]; } - private static function getBillingNameTemplate() + private static function getBillingAccountNameTemplate() + { + if (self::$billingAccountNameTemplate == null) { + self::$billingAccountNameTemplate = new PathTemplate('billingAccounts/{billing_account}'); + } + + return self::$billingAccountNameTemplate; + } + + private static function getBillingAccountCmekSettingsNameTemplate() + { + if (self::$billingAccountCmekSettingsNameTemplate == null) { + self::$billingAccountCmekSettingsNameTemplate = new PathTemplate('billingAccounts/{billing_account}/cmekSettings'); + } + + return self::$billingAccountCmekSettingsNameTemplate; + } + + private static function getBillingAccountExclusionNameTemplate() + { + if (self::$billingAccountExclusionNameTemplate == null) { + self::$billingAccountExclusionNameTemplate = new PathTemplate('billingAccounts/{billing_account}/exclusions/{exclusion}'); + } + + return self::$billingAccountExclusionNameTemplate; + } + + private static function getBillingAccountLocationNameTemplate() + { + if (self::$billingAccountLocationNameTemplate == null) { + self::$billingAccountLocationNameTemplate = new PathTemplate('billingAccounts/{billing_account}/locations/{location}'); + } + + return self::$billingAccountLocationNameTemplate; + } + + private static function getBillingAccountLocationBucketNameTemplate() { - if (null == self::$billingNameTemplate) { - self::$billingNameTemplate = new PathTemplate('billingAccounts/{billing_account}'); + if (self::$billingAccountLocationBucketNameTemplate == null) { + self::$billingAccountLocationBucketNameTemplate = new PathTemplate('billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}'); } - return self::$billingNameTemplate; + return self::$billingAccountLocationBucketNameTemplate; } - private static function getBillingExclusionNameTemplate() + private static function getBillingAccountLocationBucketViewNameTemplate() { - if (null == self::$billingExclusionNameTemplate) { - self::$billingExclusionNameTemplate = new PathTemplate('billingAccounts/{billing_account}/exclusions/{exclusion}'); + if (self::$billingAccountLocationBucketViewNameTemplate == null) { + self::$billingAccountLocationBucketViewNameTemplate = new PathTemplate('billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}/views/{view}'); } - return self::$billingExclusionNameTemplate; + return self::$billingAccountLocationBucketViewNameTemplate; } - private static function getBillingSinkNameTemplate() + private static function getBillingAccountSinkNameTemplate() { - if (null == self::$billingSinkNameTemplate) { - self::$billingSinkNameTemplate = new PathTemplate('billingAccounts/{billing_account}/sinks/{sink}'); + if (self::$billingAccountSinkNameTemplate == null) { + self::$billingAccountSinkNameTemplate = new PathTemplate('billingAccounts/{billing_account}/sinks/{sink}'); } - return self::$billingSinkNameTemplate; + return self::$billingAccountSinkNameTemplate; } - private static function getExclusionNameTemplate() + private static function getCmekSettingsNameTemplate() { - if (null == self::$exclusionNameTemplate) { - self::$exclusionNameTemplate = new PathTemplate('projects/{project}/exclusions/{exclusion}'); + if (self::$cmekSettingsNameTemplate == null) { + self::$cmekSettingsNameTemplate = new PathTemplate('projects/{project}/cmekSettings'); } - return self::$exclusionNameTemplate; + return self::$cmekSettingsNameTemplate; } private static function getFolderNameTemplate() { - if (null == self::$folderNameTemplate) { + if (self::$folderNameTemplate == null) { self::$folderNameTemplate = new PathTemplate('folders/{folder}'); } return self::$folderNameTemplate; } + private static function getFolderCmekSettingsNameTemplate() + { + if (self::$folderCmekSettingsNameTemplate == null) { + self::$folderCmekSettingsNameTemplate = new PathTemplate('folders/{folder}/cmekSettings'); + } + + return self::$folderCmekSettingsNameTemplate; + } + private static function getFolderExclusionNameTemplate() { - if (null == self::$folderExclusionNameTemplate) { + if (self::$folderExclusionNameTemplate == null) { self::$folderExclusionNameTemplate = new PathTemplate('folders/{folder}/exclusions/{exclusion}'); } return self::$folderExclusionNameTemplate; } + private static function getFolderLocationNameTemplate() + { + if (self::$folderLocationNameTemplate == null) { + self::$folderLocationNameTemplate = new PathTemplate('folders/{folder}/locations/{location}'); + } + + return self::$folderLocationNameTemplate; + } + + private static function getFolderLocationBucketNameTemplate() + { + if (self::$folderLocationBucketNameTemplate == null) { + self::$folderLocationBucketNameTemplate = new PathTemplate('folders/{folder}/locations/{location}/buckets/{bucket}'); + } + + return self::$folderLocationBucketNameTemplate; + } + + private static function getFolderLocationBucketViewNameTemplate() + { + if (self::$folderLocationBucketViewNameTemplate == null) { + self::$folderLocationBucketViewNameTemplate = new PathTemplate('folders/{folder}/locations/{location}/buckets/{bucket}/views/{view}'); + } + + return self::$folderLocationBucketViewNameTemplate; + } + private static function getFolderSinkNameTemplate() { - if (null == self::$folderSinkNameTemplate) { + if (self::$folderSinkNameTemplate == null) { self::$folderSinkNameTemplate = new PathTemplate('folders/{folder}/sinks/{sink}'); } return self::$folderSinkNameTemplate; } + private static function getLocationNameTemplate() + { + if (self::$locationNameTemplate == null) { + self::$locationNameTemplate = new PathTemplate('projects/{project}/locations/{location}'); + } + + return self::$locationNameTemplate; + } + + private static function getLogBucketNameTemplate() + { + if (self::$logBucketNameTemplate == null) { + self::$logBucketNameTemplate = new PathTemplate('projects/{project}/locations/{location}/buckets/{bucket}'); + } + + return self::$logBucketNameTemplate; + } + + private static function getLogExclusionNameTemplate() + { + if (self::$logExclusionNameTemplate == null) { + self::$logExclusionNameTemplate = new PathTemplate('projects/{project}/exclusions/{exclusion}'); + } + + return self::$logExclusionNameTemplate; + } + + private static function getLogSinkNameTemplate() + { + if (self::$logSinkNameTemplate == null) { + self::$logSinkNameTemplate = new PathTemplate('projects/{project}/sinks/{sink}'); + } + + return self::$logSinkNameTemplate; + } + + private static function getLogViewNameTemplate() + { + if (self::$logViewNameTemplate == null) { + self::$logViewNameTemplate = new PathTemplate('projects/{project}/locations/{location}/buckets/{bucket}/views/{view}'); + } + + return self::$logViewNameTemplate; + } + private static function getOrganizationNameTemplate() { - if (null == self::$organizationNameTemplate) { + if (self::$organizationNameTemplate == null) { self::$organizationNameTemplate = new PathTemplate('organizations/{organization}'); } return self::$organizationNameTemplate; } + private static function getOrganizationCmekSettingsNameTemplate() + { + if (self::$organizationCmekSettingsNameTemplate == null) { + self::$organizationCmekSettingsNameTemplate = new PathTemplate('organizations/{organization}/cmekSettings'); + } + + return self::$organizationCmekSettingsNameTemplate; + } + private static function getOrganizationExclusionNameTemplate() { - if (null == self::$organizationExclusionNameTemplate) { + if (self::$organizationExclusionNameTemplate == null) { self::$organizationExclusionNameTemplate = new PathTemplate('organizations/{organization}/exclusions/{exclusion}'); } return self::$organizationExclusionNameTemplate; } + private static function getOrganizationLocationNameTemplate() + { + if (self::$organizationLocationNameTemplate == null) { + self::$organizationLocationNameTemplate = new PathTemplate('organizations/{organization}/locations/{location}'); + } + + return self::$organizationLocationNameTemplate; + } + + private static function getOrganizationLocationBucketNameTemplate() + { + if (self::$organizationLocationBucketNameTemplate == null) { + self::$organizationLocationBucketNameTemplate = new PathTemplate('organizations/{organization}/locations/{location}/buckets/{bucket}'); + } + + return self::$organizationLocationBucketNameTemplate; + } + + private static function getOrganizationLocationBucketViewNameTemplate() + { + if (self::$organizationLocationBucketViewNameTemplate == null) { + self::$organizationLocationBucketViewNameTemplate = new PathTemplate('organizations/{organization}/locations/{location}/buckets/{bucket}/views/{view}'); + } + + return self::$organizationLocationBucketViewNameTemplate; + } + private static function getOrganizationSinkNameTemplate() { - if (null == self::$organizationSinkNameTemplate) { + if (self::$organizationSinkNameTemplate == null) { self::$organizationSinkNameTemplate = new PathTemplate('organizations/{organization}/sinks/{sink}'); } @@ -252,38 +458,95 @@ private static function getOrganizationSinkNameTemplate() private static function getProjectNameTemplate() { - if (null == self::$projectNameTemplate) { + if (self::$projectNameTemplate == null) { self::$projectNameTemplate = new PathTemplate('projects/{project}'); } return self::$projectNameTemplate; } - private static function getSinkNameTemplate() + private static function getProjectCmekSettingsNameTemplate() + { + if (self::$projectCmekSettingsNameTemplate == null) { + self::$projectCmekSettingsNameTemplate = new PathTemplate('projects/{project}/cmekSettings'); + } + + return self::$projectCmekSettingsNameTemplate; + } + + private static function getProjectExclusionNameTemplate() + { + if (self::$projectExclusionNameTemplate == null) { + self::$projectExclusionNameTemplate = new PathTemplate('projects/{project}/exclusions/{exclusion}'); + } + + return self::$projectExclusionNameTemplate; + } + + private static function getProjectLocationBucketNameTemplate() + { + if (self::$projectLocationBucketNameTemplate == null) { + self::$projectLocationBucketNameTemplate = new PathTemplate('projects/{project}/locations/{location}/buckets/{bucket}'); + } + + return self::$projectLocationBucketNameTemplate; + } + + private static function getProjectLocationBucketViewNameTemplate() + { + if (self::$projectLocationBucketViewNameTemplate == null) { + self::$projectLocationBucketViewNameTemplate = new PathTemplate('projects/{project}/locations/{location}/buckets/{bucket}/views/{view}'); + } + + return self::$projectLocationBucketViewNameTemplate; + } + + private static function getProjectSinkNameTemplate() { - if (null == self::$sinkNameTemplate) { - self::$sinkNameTemplate = new PathTemplate('projects/{project}/sinks/{sink}'); + if (self::$projectSinkNameTemplate == null) { + self::$projectSinkNameTemplate = new PathTemplate('projects/{project}/sinks/{sink}'); } - return self::$sinkNameTemplate; + return self::$projectSinkNameTemplate; } private static function getPathTemplateMap() { - if (null == self::$pathTemplateMap) { + if (self::$pathTemplateMap == null) { self::$pathTemplateMap = [ - 'billing' => self::getBillingNameTemplate(), - 'billingExclusion' => self::getBillingExclusionNameTemplate(), - 'billingSink' => self::getBillingSinkNameTemplate(), - 'exclusion' => self::getExclusionNameTemplate(), + 'billingAccount' => self::getBillingAccountNameTemplate(), + 'billingAccountCmekSettings' => self::getBillingAccountCmekSettingsNameTemplate(), + 'billingAccountExclusion' => self::getBillingAccountExclusionNameTemplate(), + 'billingAccountLocation' => self::getBillingAccountLocationNameTemplate(), + 'billingAccountLocationBucket' => self::getBillingAccountLocationBucketNameTemplate(), + 'billingAccountLocationBucketView' => self::getBillingAccountLocationBucketViewNameTemplate(), + 'billingAccountSink' => self::getBillingAccountSinkNameTemplate(), + 'cmekSettings' => self::getCmekSettingsNameTemplate(), 'folder' => self::getFolderNameTemplate(), + 'folderCmekSettings' => self::getFolderCmekSettingsNameTemplate(), 'folderExclusion' => self::getFolderExclusionNameTemplate(), + 'folderLocation' => self::getFolderLocationNameTemplate(), + 'folderLocationBucket' => self::getFolderLocationBucketNameTemplate(), + 'folderLocationBucketView' => self::getFolderLocationBucketViewNameTemplate(), 'folderSink' => self::getFolderSinkNameTemplate(), + 'location' => self::getLocationNameTemplate(), + 'logBucket' => self::getLogBucketNameTemplate(), + 'logExclusion' => self::getLogExclusionNameTemplate(), + 'logSink' => self::getLogSinkNameTemplate(), + 'logView' => self::getLogViewNameTemplate(), 'organization' => self::getOrganizationNameTemplate(), + 'organizationCmekSettings' => self::getOrganizationCmekSettingsNameTemplate(), 'organizationExclusion' => self::getOrganizationExclusionNameTemplate(), + 'organizationLocation' => self::getOrganizationLocationNameTemplate(), + 'organizationLocationBucket' => self::getOrganizationLocationBucketNameTemplate(), + 'organizationLocationBucketView' => self::getOrganizationLocationBucketViewNameTemplate(), 'organizationSink' => self::getOrganizationSinkNameTemplate(), 'project' => self::getProjectNameTemplate(), - 'sink' => self::getSinkNameTemplate(), + 'projectCmekSettings' => self::getProjectCmekSettingsNameTemplate(), + 'projectExclusion' => self::getProjectExclusionNameTemplate(), + 'projectLocationBucket' => self::getProjectLocationBucketNameTemplate(), + 'projectLocationBucketView' => self::getProjectLocationBucketViewNameTemplate(), + 'projectSink' => self::getProjectSinkNameTemplate(), ]; } @@ -291,83 +554,148 @@ private static function getPathTemplateMap() } /** - * Formats a string containing the fully-qualified path to represent - * a billing resource. + * Formats a string containing the fully-qualified path to represent a + * billing_account resource. + * + * @param string $billingAccount + * + * @return string The formatted billing_account resource. + */ + public static function billingAccountName($billingAccount) + { + return self::getBillingAccountNameTemplate()->render([ + 'billing_account' => $billingAccount, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * billing_account_cmekSettings resource. * * @param string $billingAccount * - * @return string The formatted billing resource. - * @experimental + * @return string The formatted billing_account_cmekSettings resource. */ - public static function billingName($billingAccount) + public static function billingAccountCmekSettingsName($billingAccount) { - return self::getBillingNameTemplate()->render([ + return self::getBillingAccountCmekSettingsNameTemplate()->render([ 'billing_account' => $billingAccount, ]); } /** - * Formats a string containing the fully-qualified path to represent - * a billing_exclusion resource. + * Formats a string containing the fully-qualified path to represent a + * billing_account_exclusion resource. * * @param string $billingAccount * @param string $exclusion * - * @return string The formatted billing_exclusion resource. - * @experimental + * @return string The formatted billing_account_exclusion resource. */ - public static function billingExclusionName($billingAccount, $exclusion) + public static function billingAccountExclusionName($billingAccount, $exclusion) { - return self::getBillingExclusionNameTemplate()->render([ + return self::getBillingAccountExclusionNameTemplate()->render([ 'billing_account' => $billingAccount, 'exclusion' => $exclusion, ]); } /** - * Formats a string containing the fully-qualified path to represent - * a billing_sink resource. + * Formats a string containing the fully-qualified path to represent a + * billing_account_location resource. + * + * @param string $billingAccount + * @param string $location + * + * @return string The formatted billing_account_location resource. + */ + public static function billingAccountLocationName($billingAccount, $location) + { + return self::getBillingAccountLocationNameTemplate()->render([ + 'billing_account' => $billingAccount, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * billing_account_location_bucket resource. + * + * @param string $billingAccount + * @param string $location + * @param string $bucket + * + * @return string The formatted billing_account_location_bucket resource. + */ + public static function billingAccountLocationBucketName($billingAccount, $location, $bucket) + { + return self::getBillingAccountLocationBucketNameTemplate()->render([ + 'billing_account' => $billingAccount, + 'location' => $location, + 'bucket' => $bucket, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * billing_account_location_bucket_view resource. + * + * @param string $billingAccount + * @param string $location + * @param string $bucket + * @param string $view + * + * @return string The formatted billing_account_location_bucket_view resource. + */ + public static function billingAccountLocationBucketViewName($billingAccount, $location, $bucket, $view) + { + return self::getBillingAccountLocationBucketViewNameTemplate()->render([ + 'billing_account' => $billingAccount, + 'location' => $location, + 'bucket' => $bucket, + 'view' => $view, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * billing_account_sink resource. * * @param string $billingAccount * @param string $sink * - * @return string The formatted billing_sink resource. - * @experimental + * @return string The formatted billing_account_sink resource. */ - public static function billingSinkName($billingAccount, $sink) + public static function billingAccountSinkName($billingAccount, $sink) { - return self::getBillingSinkNameTemplate()->render([ + return self::getBillingAccountSinkNameTemplate()->render([ 'billing_account' => $billingAccount, 'sink' => $sink, ]); } /** - * Formats a string containing the fully-qualified path to represent - * a exclusion resource. + * Formats a string containing the fully-qualified path to represent a + * cmek_settings resource. * * @param string $project - * @param string $exclusion * - * @return string The formatted exclusion resource. - * @experimental + * @return string The formatted cmek_settings resource. */ - public static function exclusionName($project, $exclusion) + public static function cmekSettingsName($project) { - return self::getExclusionNameTemplate()->render([ + return self::getCmekSettingsNameTemplate()->render([ 'project' => $project, - 'exclusion' => $exclusion, ]); } /** - * Formats a string containing the fully-qualified path to represent - * a folder resource. + * Formats a string containing the fully-qualified path to represent a folder + * resource. * * @param string $folder * * @return string The formatted folder resource. - * @experimental */ public static function folderName($folder) { @@ -377,14 +705,28 @@ public static function folderName($folder) } /** - * Formats a string containing the fully-qualified path to represent - * a folder_exclusion resource. + * Formats a string containing the fully-qualified path to represent a + * folder_cmekSettings resource. + * + * @param string $folder + * + * @return string The formatted folder_cmekSettings resource. + */ + public static function folderCmekSettingsName($folder) + { + return self::getFolderCmekSettingsNameTemplate()->render([ + 'folder' => $folder, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_exclusion resource. * * @param string $folder * @param string $exclusion * * @return string The formatted folder_exclusion resource. - * @experimental */ public static function folderExclusionName($folder, $exclusion) { @@ -395,145 +737,451 @@ public static function folderExclusionName($folder, $exclusion) } /** - * Formats a string containing the fully-qualified path to represent - * a folder_sink resource. + * Formats a string containing the fully-qualified path to represent a + * folder_location resource. * * @param string $folder - * @param string $sink + * @param string $location * - * @return string The formatted folder_sink resource. - * @experimental + * @return string The formatted folder_location resource. */ - public static function folderSinkName($folder, $sink) + public static function folderLocationName($folder, $location) { - return self::getFolderSinkNameTemplate()->render([ + return self::getFolderLocationNameTemplate()->render([ 'folder' => $folder, - 'sink' => $sink, + 'location' => $location, ]); } /** - * Formats a string containing the fully-qualified path to represent - * a organization resource. + * Formats a string containing the fully-qualified path to represent a + * folder_location_bucket resource. * - * @param string $organization + * @param string $folder + * @param string $location + * @param string $bucket * - * @return string The formatted organization resource. - * @experimental + * @return string The formatted folder_location_bucket resource. */ - public static function organizationName($organization) + public static function folderLocationBucketName($folder, $location, $bucket) { - return self::getOrganizationNameTemplate()->render([ - 'organization' => $organization, + return self::getFolderLocationBucketNameTemplate()->render([ + 'folder' => $folder, + 'location' => $location, + 'bucket' => $bucket, ]); } /** - * Formats a string containing the fully-qualified path to represent - * a organization_exclusion resource. + * Formats a string containing the fully-qualified path to represent a + * folder_location_bucket_view resource. * - * @param string $organization - * @param string $exclusion + * @param string $folder + * @param string $location + * @param string $bucket + * @param string $view * - * @return string The formatted organization_exclusion resource. - * @experimental + * @return string The formatted folder_location_bucket_view resource. */ - public static function organizationExclusionName($organization, $exclusion) + public static function folderLocationBucketViewName($folder, $location, $bucket, $view) { - return self::getOrganizationExclusionNameTemplate()->render([ - 'organization' => $organization, - 'exclusion' => $exclusion, + return self::getFolderLocationBucketViewNameTemplate()->render([ + 'folder' => $folder, + 'location' => $location, + 'bucket' => $bucket, + 'view' => $view, ]); } /** - * Formats a string containing the fully-qualified path to represent - * a organization_sink resource. + * Formats a string containing the fully-qualified path to represent a folder_sink + * resource. * - * @param string $organization + * @param string $folder * @param string $sink * - * @return string The formatted organization_sink resource. - * @experimental + * @return string The formatted folder_sink resource. */ - public static function organizationSinkName($organization, $sink) + public static function folderSinkName($folder, $sink) { - return self::getOrganizationSinkNameTemplate()->render([ - 'organization' => $organization, + return self::getFolderSinkNameTemplate()->render([ + 'folder' => $folder, 'sink' => $sink, ]); } /** - * Formats a string containing the fully-qualified path to represent - * a project resource. + * Formats a string containing the fully-qualified path to represent a location + * resource. * * @param string $project + * @param string $location * - * @return string The formatted project resource. - * @experimental + * @return string The formatted location resource. */ - public static function projectName($project) + public static function locationName($project, $location) { - return self::getProjectNameTemplate()->render([ + return self::getLocationNameTemplate()->render([ 'project' => $project, + 'location' => $location, ]); } /** - * Formats a string containing the fully-qualified path to represent - * a sink resource. + * Formats a string containing the fully-qualified path to represent a log_bucket + * resource. * * @param string $project - * @param string $sink + * @param string $location + * @param string $bucket * - * @return string The formatted sink resource. - * @experimental + * @return string The formatted log_bucket resource. */ - public static function sinkName($project, $sink) + public static function logBucketName($project, $location, $bucket) { - return self::getSinkNameTemplate()->render([ + return self::getLogBucketNameTemplate()->render([ 'project' => $project, - 'sink' => $sink, + 'location' => $location, + 'bucket' => $bucket, ]); } /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - billing: billingAccounts/{billing_account} - * - billingExclusion: billingAccounts/{billing_account}/exclusions/{exclusion} - * - billingSink: billingAccounts/{billing_account}/sinks/{sink} - * - exclusion: projects/{project}/exclusions/{exclusion} - * - folder: folders/{folder} - * - folderExclusion: folders/{folder}/exclusions/{exclusion} - * - folderSink: folders/{folder}/sinks/{sink} - * - organization: organizations/{organization} - * - organizationExclusion: organizations/{organization}/exclusions/{exclusion} - * - organizationSink: organizations/{organization}/sinks/{sink} - * - project: projects/{project} - * - sink: projects/{project}/sinks/{sink}. - * - * The optional $template argument can be supplied to specify a particular pattern, and must - * match one of the templates listed above. If no $template argument is provided, or if the - * $template argument does not match one of the templates listed, then parseName will check - * each of the supported templates, and return the first match. + * Formats a string containing the fully-qualified path to represent a + * log_exclusion resource. * - * @param string $formattedName The formatted name string - * @param string $template Optional name of template to match - * - * @return array An associative array from name component IDs to component values. + * @param string $project + * @param string $exclusion * - * @throws ValidationException If $formattedName could not be matched. - * @experimental + * @return string The formatted log_exclusion resource. */ - public static function parseName($formattedName, $template = null) + public static function logExclusionName($project, $exclusion) { - $templateMap = self::getPathTemplateMap(); - - if ($template) { - if (!isset($templateMap[$template])) { + return self::getLogExclusionNameTemplate()->render([ + 'project' => $project, + 'exclusion' => $exclusion, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a log_sink + * resource. + * + * @param string $project + * @param string $sink + * + * @return string The formatted log_sink resource. + */ + public static function logSinkName($project, $sink) + { + return self::getLogSinkNameTemplate()->render([ + 'project' => $project, + 'sink' => $sink, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a log_view + * resource. + * + * @param string $project + * @param string $location + * @param string $bucket + * @param string $view + * + * @return string The formatted log_view resource. + */ + public static function logViewName($project, $location, $bucket, $view) + { + return self::getLogViewNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'bucket' => $bucket, + 'view' => $view, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a organization + * resource. + * + * @param string $organization + * + * @return string The formatted organization resource. + */ + public static function organizationName($organization) + { + return self::getOrganizationNameTemplate()->render([ + 'organization' => $organization, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_cmekSettings resource. + * + * @param string $organization + * + * @return string The formatted organization_cmekSettings resource. + */ + public static function organizationCmekSettingsName($organization) + { + return self::getOrganizationCmekSettingsNameTemplate()->render([ + 'organization' => $organization, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_exclusion resource. + * + * @param string $organization + * @param string $exclusion + * + * @return string The formatted organization_exclusion resource. + */ + public static function organizationExclusionName($organization, $exclusion) + { + return self::getOrganizationExclusionNameTemplate()->render([ + 'organization' => $organization, + 'exclusion' => $exclusion, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_location resource. + * + * @param string $organization + * @param string $location + * + * @return string The formatted organization_location resource. + */ + public static function organizationLocationName($organization, $location) + { + return self::getOrganizationLocationNameTemplate()->render([ + 'organization' => $organization, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_location_bucket resource. + * + * @param string $organization + * @param string $location + * @param string $bucket + * + * @return string The formatted organization_location_bucket resource. + */ + public static function organizationLocationBucketName($organization, $location, $bucket) + { + return self::getOrganizationLocationBucketNameTemplate()->render([ + 'organization' => $organization, + 'location' => $location, + 'bucket' => $bucket, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_location_bucket_view resource. + * + * @param string $organization + * @param string $location + * @param string $bucket + * @param string $view + * + * @return string The formatted organization_location_bucket_view resource. + */ + public static function organizationLocationBucketViewName($organization, $location, $bucket, $view) + { + return self::getOrganizationLocationBucketViewNameTemplate()->render([ + 'organization' => $organization, + 'location' => $location, + 'bucket' => $bucket, + 'view' => $view, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_sink resource. + * + * @param string $organization + * @param string $sink + * + * @return string The formatted organization_sink resource. + */ + public static function organizationSinkName($organization, $sink) + { + return self::getOrganizationSinkNameTemplate()->render([ + 'organization' => $organization, + 'sink' => $sink, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a project + * resource. + * + * @param string $project + * + * @return string The formatted project resource. + */ + public static function projectName($project) + { + return self::getProjectNameTemplate()->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_cmekSettings resource. + * + * @param string $project + * + * @return string The formatted project_cmekSettings resource. + */ + public static function projectCmekSettingsName($project) + { + return self::getProjectCmekSettingsNameTemplate()->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_exclusion resource. + * + * @param string $project + * @param string $exclusion + * + * @return string The formatted project_exclusion resource. + */ + public static function projectExclusionName($project, $exclusion) + { + return self::getProjectExclusionNameTemplate()->render([ + 'project' => $project, + 'exclusion' => $exclusion, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_bucket resource. + * + * @param string $project + * @param string $location + * @param string $bucket + * + * @return string The formatted project_location_bucket resource. + */ + public static function projectLocationBucketName($project, $location, $bucket) + { + return self::getProjectLocationBucketNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'bucket' => $bucket, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_bucket_view resource. + * + * @param string $project + * @param string $location + * @param string $bucket + * @param string $view + * + * @return string The formatted project_location_bucket_view resource. + */ + public static function projectLocationBucketViewName($project, $location, $bucket, $view) + { + return self::getProjectLocationBucketViewNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'bucket' => $bucket, + 'view' => $view, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a project_sink + * resource. + * + * @param string $project + * @param string $sink + * + * @return string The formatted project_sink resource. + */ + public static function projectSinkName($project, $sink) + { + return self::getProjectSinkNameTemplate()->render([ + 'project' => $project, + 'sink' => $sink, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - billingAccount: billingAccounts/{billing_account} + * - billingAccountCmekSettings: billingAccounts/{billing_account}/cmekSettings + * - billingAccountExclusion: billingAccounts/{billing_account}/exclusions/{exclusion} + * - billingAccountLocation: billingAccounts/{billing_account}/locations/{location} + * - billingAccountLocationBucket: billingAccounts/{billing_account}/locations/{location}/buckets/{bucket} + * - billingAccountLocationBucketView: billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}/views/{view} + * - billingAccountSink: billingAccounts/{billing_account}/sinks/{sink} + * - cmekSettings: projects/{project}/cmekSettings + * - folder: folders/{folder} + * - folderCmekSettings: folders/{folder}/cmekSettings + * - folderExclusion: folders/{folder}/exclusions/{exclusion} + * - folderLocation: folders/{folder}/locations/{location} + * - folderLocationBucket: folders/{folder}/locations/{location}/buckets/{bucket} + * - folderLocationBucketView: folders/{folder}/locations/{location}/buckets/{bucket}/views/{view} + * - folderSink: folders/{folder}/sinks/{sink} + * - location: projects/{project}/locations/{location} + * - logBucket: projects/{project}/locations/{location}/buckets/{bucket} + * - logExclusion: projects/{project}/exclusions/{exclusion} + * - logSink: projects/{project}/sinks/{sink} + * - logView: projects/{project}/locations/{location}/buckets/{bucket}/views/{view} + * - organization: organizations/{organization} + * - organizationCmekSettings: organizations/{organization}/cmekSettings + * - organizationExclusion: organizations/{organization}/exclusions/{exclusion} + * - organizationLocation: organizations/{organization}/locations/{location} + * - organizationLocationBucket: organizations/{organization}/locations/{location}/buckets/{bucket} + * - organizationLocationBucketView: organizations/{organization}/locations/{location}/buckets/{bucket}/views/{view} + * - organizationSink: organizations/{organization}/sinks/{sink} + * - project: projects/{project} + * - projectCmekSettings: projects/{project}/cmekSettings + * - projectExclusion: projects/{project}/exclusions/{exclusion} + * - projectLocationBucket: projects/{project}/locations/{location}/buckets/{bucket} + * - projectLocationBucketView: projects/{project}/locations/{location}/buckets/{bucket}/views/{view} + * - projectSink: projects/{project}/sinks/{sink} + * + * The optional $template argument can be supplied to specify a particular pattern, + * and must match one of the templates listed above. If no $template argument is + * provided, or if the $template argument does not match one of the templates + * listed, then parseName will check each of the supported templates, and return + * the first match. + * + * @param string $formattedName The formatted name string + * @param string $template Optional name of template to match + * + * @return array An associative array from name component IDs to component values. + * + * @throws ValidationException If $formattedName could not be matched. + */ + public static function parseName($formattedName, $template = null) + { + $templateMap = self::getPathTemplateMap(); + if ($template) { + if (!isset($templateMap[$template])) { throw new ValidationException("Template name $template does not exist"); } @@ -547,6 +1195,7 @@ public static function parseName($formattedName, $template = null) // Swallow the exception to continue trying other path templates } } + throw new ValidationException("Input did not match any known format. Input: $formattedName"); } @@ -554,7 +1203,7 @@ public static function parseName($formattedName, $template = null) * Constructor. * * @param array $options { - * Optional. Options for configuring the service API wrapper. + * Optional. Options for configuring the service API wrapper. * * @type string $serviceAddress * **Deprecated**. This option will be removed in a future major release. Please @@ -571,39 +1220,41 @@ public static function parseName($formattedName, $template = null) * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these * objects are provided, any settings in $credentialsConfig will be ignored. * @type array $credentialsConfig - * Options used to configure credentials, including auth token caching, for the client. - * For a full list of supporting configuration options, see - * {@see \Google\ApiCore\CredentialsWrapper::build()}. + * Options used to configure credentials, including auth token caching, for the + * client. For a full list of supporting configuration options, see + * {@see \Google\ApiCore\CredentialsWrapper::build()} . * @type bool $disableRetries * Determines whether or not retries defined by the client configuration should be * disabled. Defaults to `false`. * @type string|array $clientConfig - * Client method configuration, including retry settings. This option can be either a - * path to a JSON file, or a PHP array containing the decoded JSON data. - * By default this settings points to the default client config file, which is provided - * in the resources folder. + * Client method configuration, including retry settings. This option can be either + * a path to a JSON file, or a PHP array containing the decoded JSON data. By + * default this settings points to the default client config file, which is + * provided in the resources folder. * @type string|TransportInterface $transport - * The transport used for executing network requests. May be either the string `rest` - * or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. - * *Advanced usage*: Additionally, it is possible to pass in an already instantiated - * {@see \Google\ApiCore\Transport\TransportInterface} object. Note that when this - * object is provided, any settings in $transportConfig, and any `$apiEndpoint` - * setting, will be ignored. + * The transport used for executing network requests. May be either the string + * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. + * *Advanced usage*: Additionally, it is possible to pass in an already + * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note + * that when this object is provided, any settings in $transportConfig, and any + * $serviceAddress setting, will be ignored. * @type array $transportConfig * Configuration options that will be used to construct the transport. Options for * each supported transport type should be passed in a key for that transport. For * example: * $transportConfig = [ * 'grpc' => [...], - * 'rest' => [...] + * 'rest' => [...], * ]; * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the * supported options. + * @type callable $clientCertSource + * A callable which returns the client cert as a string. This can be used to + * provide a certificate and private key to the transport layer for mTLS. * } * * @throws ValidationException - * @experimental */ public function __construct(array $options = []) { @@ -612,145 +1263,111 @@ public function __construct(array $options = []) } /** - * Lists sinks. + * Creates a bucket that can be used to store log entries. Once a bucket has + * been created, the region cannot be changed. * * Sample code: * ``` * $configServiceV2Client = new ConfigServiceV2Client(); * try { - * $formattedParent = $configServiceV2Client->projectName('[PROJECT]'); - * // Iterate over pages of elements - * $pagedResponse = $configServiceV2Client->listSinks($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * - * - * // Alternatively: - * - * // Iterate through all elements - * $pagedResponse = $configServiceV2Client->listSinks($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } + * $formattedParent = $configServiceV2Client->organizationLocationName('[ORGANIZATION]', '[LOCATION]'); + * $bucketId = 'bucket_id'; + * $bucket = new LogBucket(); + * $response = $configServiceV2Client->createBucket($formattedParent, $bucketId, $bucket); * } finally { * $configServiceV2Client->close(); * } * ``` * - * @param string $parent Required. The parent resource whose sinks are to be listed: + * @param string $parent Required. The resource in which to create the bucket: * - * "projects/[PROJECT_ID]" - * "organizations/[ORGANIZATION_ID]" - * "billingAccounts/[BILLING_ACCOUNT_ID]" - * "folders/[FOLDER_ID]" - * @param array $optionalArgs { - * Optional. + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]" + * + * Example: `"projects/my-logging-project/locations/global"` + * @param string $bucketId Required. A client-assigned identifier such as `"my-bucket"`. Identifiers are + * limited to 100 characters and can include only letters, digits, + * underscores, hyphens, and periods. + * @param LogBucket $bucket Required. The new bucket. The region specified in the new bucket must be compliant + * with any Location Restriction Org Policy. The name field in the bucket is + * ignored. + * @param array $optionalArgs { + * Optional. * - * @type string $pageToken - * A page token is used to specify a page of values to be returned. - * If no page token is specified (the default), the first page - * of values will be returned. Any page token used here must have - * been generated by a previous call to the API. - * @type int $pageSize - * The maximum number of resources contained in the underlying API - * response. The API may return fewer values in a page, even if - * there are additional values to be retrieved. * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\ApiCore\PagedListResponse + * @return \Google\Cloud\Logging\V2\LogBucket * * @throws ApiException if the remote call fails - * @experimental */ - public function listSinks($parent, array $optionalArgs = []) + public function createBucket($parent, $bucketId, $bucket, array $optionalArgs = []) { - $request = new ListSinksRequest(); + $request = new CreateBucketRequest(); + $requestParamHeaders = []; $request->setParent($parent); - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - $requestParams = new RequestParamsHeaderDescriptor([ - 'parent' => $request->getParent(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->getPagedListResponse( - 'ListSinks', - $optionalArgs, - ListSinksResponse::class, - $request - ); + $request->setBucketId($bucketId); + $request->setBucket($bucket); + $requestParamHeaders['parent'] = $parent; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('CreateBucket', LogBucket::class, $optionalArgs, $request)->wait(); } /** - * Gets a sink. + * 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. * * Sample code: * ``` * $configServiceV2Client = new ConfigServiceV2Client(); * try { - * $formattedSinkName = $configServiceV2Client->sinkName('[PROJECT]', '[SINK]'); - * $response = $configServiceV2Client->getSink($formattedSinkName); + * $formattedParent = $configServiceV2Client->projectName('[PROJECT]'); + * $exclusion = new LogExclusion(); + * $response = $configServiceV2Client->createExclusion($formattedParent, $exclusion); * } finally { * $configServiceV2Client->close(); * } * ``` * - * @param string $sinkName Required. The resource name of the sink: + * @param string $parent Required. The parent resource in which to create the exclusion: * - * "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]" + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" * - * Example: `"projects/my-project-id/sinks/my-sink-id"`. - * @param array $optionalArgs { - * Optional. + * Examples: `"projects/my-logging-project"`, `"organizations/123456789"`. + * @param LogExclusion $exclusion Required. The new exclusion, whose `name` parameter is an exclusion name + * that is not already used in the parent resource. + * @param array $optionalArgs { + * Optional. * * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Logging\V2\LogSink + * @return \Google\Cloud\Logging\V2\LogExclusion * * @throws ApiException if the remote call fails - * @experimental */ - public function getSink($sinkName, array $optionalArgs = []) + public function createExclusion($parent, $exclusion, array $optionalArgs = []) { - $request = new GetSinkRequest(); - $request->setSinkName($sinkName); - - $requestParams = new RequestParamsHeaderDescriptor([ - 'sink_name' => $request->getSinkName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'GetSink', - LogSink::class, - $optionalArgs, - $request - )->wait(); + $request = new CreateExclusionRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $request->setExclusion($exclusion); + $requestParamHeaders['parent'] = $parent; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('CreateExclusion', LogExclusion::class, $optionalArgs, $request)->wait(); } /** @@ -771,244 +1388,787 @@ public function getSink($sinkName, array $optionalArgs = []) * } * ``` * - * @param string $parent Required. The resource in which to create the sink: + * @param string $parent Required. The resource in which to create the sink: * - * "projects/[PROJECT_ID]" - * "organizations/[ORGANIZATION_ID]" - * "billingAccounts/[BILLING_ACCOUNT_ID]" - * "folders/[FOLDER_ID]" + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" * - * Examples: `"projects/my-logging-project"`, `"organizations/123456789"`. + * Examples: `"projects/my-logging-project"`, `"organizations/123456789"`. * @param LogSink $sink Required. The new sink, whose `name` parameter is a sink identifier that * is not already in use. * @param array $optionalArgs { - * Optional. + * Optional. * * @type bool $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 [LogSink][google.logging.v2.LogSink]. + * 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]. * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * * @return \Google\Cloud\Logging\V2\LogSink * * @throws ApiException if the remote call fails - * @experimental */ public function createSink($parent, $sink, array $optionalArgs = []) { $request = new CreateSinkRequest(); + $requestParamHeaders = []; $request->setParent($parent); $request->setSink($sink); + $requestParamHeaders['parent'] = $parent; if (isset($optionalArgs['uniqueWriterIdentity'])) { $request->setUniqueWriterIdentity($optionalArgs['uniqueWriterIdentity']); } - $requestParams = new RequestParamsHeaderDescriptor([ - 'parent' => $request->getParent(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('CreateSink', LogSink::class, $optionalArgs, $request)->wait(); + } - return $this->startCall( - 'CreateSink', - LogSink::class, - $optionalArgs, - $request - )->wait(); + /** + * Creates a view over logs in a bucket. A bucket may contain a maximum of + * 50 views. + * + * Sample code: + * ``` + * $configServiceV2Client = new ConfigServiceV2Client(); + * try { + * $parent = 'parent'; + * $viewId = 'view_id'; + * $view = new LogView(); + * $response = $configServiceV2Client->createView($parent, $viewId, $view); + * } finally { + * $configServiceV2Client->close(); + * } + * ``` + * + * @param string $parent Required. The bucket in which to create the view + * + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * + * Example: + * `"projects/my-logging-project/locations/my-location/buckets/my-bucket"` + * @param string $viewId Required. The id to use for this view. + * @param LogView $view Required. The new view. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Logging\V2\LogView + * + * @throws ApiException if the remote call fails + */ + public function createView($parent, $viewId, $view, array $optionalArgs = []) + { + $request = new CreateViewRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $request->setViewId($viewId); + $request->setView($view); + $requestParamHeaders['parent'] = $parent; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('CreateView', LogView::class, $optionalArgs, $request)->wait(); } /** - * Updates a sink. This method replaces the following fields in the existing - * sink with values from the new sink: `destination`, and `filter`. + * Deletes a bucket. + * Moves the bucket to the DELETE_REQUESTED state. After 7 days, the + * bucket will be purged and all logs in the bucket will be permanently + * deleted. * - * The updated sink might also have a new `writer_identity`; see the - * `unique_writer_identity` field. + * Sample code: + * ``` + * $configServiceV2Client = new ConfigServiceV2Client(); + * try { + * $formattedName = $configServiceV2Client->logBucketName('[PROJECT]', '[LOCATION]', '[BUCKET]'); + * $configServiceV2Client->deleteBucket($formattedName); + * } finally { + * $configServiceV2Client->close(); + * } + * ``` + * + * @param string $name Required. The full resource name of the bucket to delete. + * + * "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 array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @throws ApiException if the remote call fails + */ + public function deleteBucket($name, array $optionalArgs = []) + { + $request = new DeleteBucketRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('DeleteBucket', GPBEmpty::class, $optionalArgs, $request)->wait(); + } + + /** + * Deletes an exclusion. * * Sample code: * ``` * $configServiceV2Client = new ConfigServiceV2Client(); * try { - * $formattedSinkName = $configServiceV2Client->sinkName('[PROJECT]', '[SINK]'); - * $sink = new LogSink(); - * $response = $configServiceV2Client->updateSink($formattedSinkName, $sink); + * $formattedName = $configServiceV2Client->logExclusionName('[PROJECT]', '[EXCLUSION]'); + * $configServiceV2Client->deleteExclusion($formattedName); + * } finally { + * $configServiceV2Client->close(); + * } + * ``` + * + * @param string $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 array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @throws ApiException if the remote call fails + */ + public function deleteExclusion($name, array $optionalArgs = []) + { + $request = new DeleteExclusionRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('DeleteExclusion', GPBEmpty::class, $optionalArgs, $request)->wait(); + } + + /** + * Deletes a sink. If the sink has a unique `writer_identity`, then that + * service account is also deleted. + * + * Sample code: + * ``` + * $configServiceV2Client = new ConfigServiceV2Client(); + * try { + * $formattedSinkName = $configServiceV2Client->logSinkName('[PROJECT]', '[SINK]'); + * $configServiceV2Client->deleteSink($formattedSinkName); + * } finally { + * $configServiceV2Client->close(); + * } + * ``` + * + * @param string $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 array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @throws ApiException if the remote call fails + */ + public function deleteSink($sinkName, array $optionalArgs = []) + { + $request = new DeleteSinkRequest(); + $requestParamHeaders = []; + $request->setSinkName($sinkName); + $requestParamHeaders['sink_name'] = $sinkName; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('DeleteSink', GPBEmpty::class, $optionalArgs, $request)->wait(); + } + + /** + * Deletes a view from a bucket. + * + * Sample code: + * ``` + * $configServiceV2Client = new ConfigServiceV2Client(); + * try { + * $formattedName = $configServiceV2Client->logViewName('[PROJECT]', '[LOCATION]', '[BUCKET]', '[VIEW]'); + * $configServiceV2Client->deleteView($formattedName); + * } finally { + * $configServiceV2Client->close(); + * } + * ``` + * + * @param string $name Required. The full resource name of the view to delete: + * + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * + * Example: + * `"projects/my-project-id/locations/my-location/buckets/my-bucket-id/views/my-view-id"`. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @throws ApiException if the remote call fails + */ + public function deleteView($name, array $optionalArgs = []) + { + $request = new DeleteViewRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('DeleteView', GPBEmpty::class, $optionalArgs, $request)->wait(); + } + + /** + * Gets a bucket. + * + * Sample code: + * ``` + * $configServiceV2Client = new ConfigServiceV2Client(); + * try { + * $formattedName = $configServiceV2Client->logBucketName('[PROJECT]', '[LOCATION]', '[BUCKET]'); + * $response = $configServiceV2Client->getBucket($formattedName); + * } finally { + * $configServiceV2Client->close(); + * } + * ``` + * + * @param string $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 array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Logging\V2\LogBucket + * + * @throws ApiException if the remote call fails + */ + public function getBucket($name, array $optionalArgs = []) + { + $request = new GetBucketRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetBucket', LogBucket::class, $optionalArgs, $request)->wait(); + } + + /** + * 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](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. + * + * Sample code: + * ``` + * $configServiceV2Client = new ConfigServiceV2Client(); + * try { + * $response = $configServiceV2Client->getCmekSettings(); + * } finally { + * $configServiceV2Client->close(); + * } + * ``` + * + * @param array $optionalArgs { + * Optional. + * + * @type string $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. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Logging\V2\CmekSettings + * + * @throws ApiException if the remote call fails + */ + public function getCmekSettings(array $optionalArgs = []) + { + $request = new GetCmekSettingsRequest(); + $requestParamHeaders = []; + if (isset($optionalArgs['name'])) { + $request->setName($optionalArgs['name']); + $requestParamHeaders['name'] = $optionalArgs['name']; + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetCmekSettings', CmekSettings::class, $optionalArgs, $request)->wait(); + } + + /** + * Gets the description of an exclusion. + * + * Sample code: + * ``` + * $configServiceV2Client = new ConfigServiceV2Client(); + * try { + * $formattedName = $configServiceV2Client->logExclusionName('[PROJECT]', '[EXCLUSION]'); + * $response = $configServiceV2Client->getExclusion($formattedName); + * } finally { + * $configServiceV2Client->close(); + * } + * ``` + * + * @param string $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 array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Logging\V2\LogExclusion + * + * @throws ApiException if the remote call fails + */ + public function getExclusion($name, array $optionalArgs = []) + { + $request = new GetExclusionRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetExclusion', LogExclusion::class, $optionalArgs, $request)->wait(); + } + + /** + * Gets a sink. + * + * Sample code: + * ``` + * $configServiceV2Client = new ConfigServiceV2Client(); + * try { + * $formattedSinkName = $configServiceV2Client->logSinkName('[PROJECT]', '[SINK]'); + * $response = $configServiceV2Client->getSink($formattedSinkName); + * } finally { + * $configServiceV2Client->close(); + * } + * ``` + * + * @param string $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 array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Logging\V2\LogSink + * + * @throws ApiException if the remote call fails + */ + public function getSink($sinkName, array $optionalArgs = []) + { + $request = new GetSinkRequest(); + $requestParamHeaders = []; + $request->setSinkName($sinkName); + $requestParamHeaders['sink_name'] = $sinkName; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetSink', LogSink::class, $optionalArgs, $request)->wait(); + } + + /** + * Gets a view. + * + * Sample code: + * ``` + * $configServiceV2Client = new ConfigServiceV2Client(); + * try { + * $formattedName = $configServiceV2Client->logViewName('[PROJECT]', '[LOCATION]', '[BUCKET]', '[VIEW]'); + * $response = $configServiceV2Client->getView($formattedName); + * } finally { + * $configServiceV2Client->close(); + * } + * ``` + * + * @param string $name Required. The resource name of the policy: + * + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * + * Example: + * `"projects/my-project-id/locations/my-location/buckets/my-bucket-id/views/my-view-id"`. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Logging\V2\LogView + * + * @throws ApiException if the remote call fails + */ + public function getView($name, array $optionalArgs = []) + { + $request = new GetViewRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetView', LogView::class, $optionalArgs, $request)->wait(); + } + + /** + * Lists buckets. + * + * Sample code: + * ``` + * $configServiceV2Client = new ConfigServiceV2Client(); + * try { + * $formattedParent = $configServiceV2Client->organizationLocationName('[ORGANIZATION]', '[LOCATION]'); + * // Iterate over pages of elements + * $pagedResponse = $configServiceV2Client->listBuckets($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $configServiceV2Client->listBuckets($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $configServiceV2Client->close(); + * } + * ``` + * + * @param string $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 array $optionalArgs { + * Optional. + * + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listBuckets($parent, array $optionalArgs = []) + { + $request = new ListBucketsRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListBuckets', $optionalArgs, ListBucketsResponse::class, $request); + } + + /** + * Lists all the exclusions in a parent resource. + * + * Sample code: + * ``` + * $configServiceV2Client = new ConfigServiceV2Client(); + * try { + * $formattedParent = $configServiceV2Client->projectName('[PROJECT]'); + * // Iterate over pages of elements + * $pagedResponse = $configServiceV2Client->listExclusions($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $configServiceV2Client->listExclusions($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } * } finally { * $configServiceV2Client->close(); * } * ``` * - * @param string $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 LogSink $sink Required. The updated sink, whose name is the same identifier that appears - * as part of `sink_name`. - * @param array $optionalArgs { - * Optional. - * - * @type bool $uniqueWriterIdentity - * 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. - * @type FieldMask $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. + * @param string $parent Required. The parent resource whose exclusions are to be listed. * - * For a detailed `FieldMask` definition, see - * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @param array $optionalArgs { + * Optional. * - * Example: `updateMask=filter`. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Logging\V2\LogSink + * @return \Google\ApiCore\PagedListResponse * * @throws ApiException if the remote call fails - * @experimental */ - public function updateSink($sinkName, $sink, array $optionalArgs = []) + public function listExclusions($parent, array $optionalArgs = []) { - $request = new UpdateSinkRequest(); - $request->setSinkName($sinkName); - $request->setSink($sink); - if (isset($optionalArgs['uniqueWriterIdentity'])) { - $request->setUniqueWriterIdentity($optionalArgs['uniqueWriterIdentity']); - } - if (isset($optionalArgs['updateMask'])) { - $request->setUpdateMask($optionalArgs['updateMask']); + $request = new ListExclusionsRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); } - $requestParams = new RequestParamsHeaderDescriptor([ - 'sink_name' => $request->getSinkName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } - return $this->startCall( - 'UpdateSink', - LogSink::class, - $optionalArgs, - $request - )->wait(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListExclusions', $optionalArgs, ListExclusionsResponse::class, $request); } /** - * Deletes a sink. If the sink has a unique `writer_identity`, then that - * service account is also deleted. + * Lists sinks. * * Sample code: * ``` * $configServiceV2Client = new ConfigServiceV2Client(); * try { - * $formattedSinkName = $configServiceV2Client->sinkName('[PROJECT]', '[SINK]'); - * $configServiceV2Client->deleteSink($formattedSinkName); + * $formattedParent = $configServiceV2Client->projectName('[PROJECT]'); + * // Iterate over pages of elements + * $pagedResponse = $configServiceV2Client->listSinks($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $configServiceV2Client->listSinks($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } * } finally { * $configServiceV2Client->close(); * } * ``` * - * @param string $sinkName Required. The full resource name of the sink to delete, including the - * parent resource and the sink identifier: + * @param string $parent Required. The parent resource whose sinks are to be listed: * - * "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 array $optionalArgs { - * Optional. + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @param array $optionalArgs { + * Optional. * + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * + * @return \Google\ApiCore\PagedListResponse + * * @throws ApiException if the remote call fails - * @experimental */ - public function deleteSink($sinkName, array $optionalArgs = []) + public function listSinks($parent, array $optionalArgs = []) { - $request = new DeleteSinkRequest(); - $request->setSinkName($sinkName); + $request = new ListSinksRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } - $requestParams = new RequestParamsHeaderDescriptor([ - 'sink_name' => $request->getSinkName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } - return $this->startCall( - 'DeleteSink', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListSinks', $optionalArgs, ListSinksResponse::class, $request); } /** - * Lists all the exclusions in a parent resource. + * Lists views on a bucket. * * Sample code: * ``` * $configServiceV2Client = new ConfigServiceV2Client(); * try { - * $formattedParent = $configServiceV2Client->projectName('[PROJECT]'); + * $parent = 'parent'; * // Iterate over pages of elements - * $pagedResponse = $configServiceV2Client->listExclusions($formattedParent); + * $pagedResponse = $configServiceV2Client->listViews($parent); * foreach ($pagedResponse->iteratePages() as $page) { * foreach ($page as $element) { * // doSomethingWith($element); * } * } - * - * * // Alternatively: - * * // Iterate through all elements - * $pagedResponse = $configServiceV2Client->listExclusions($formattedParent); + * $pagedResponse = $configServiceV2Client->listViews($parent); * foreach ($pagedResponse->iterateAllElements() as $element) { * // doSomethingWith($element); * } @@ -1017,469 +2177,470 @@ public function deleteSink($sinkName, array $optionalArgs = []) * } * ``` * - * @param string $parent Required. The parent resource whose exclusions are to be listed. + * @param string $parent Required. The bucket whose views are to be listed: * - * "projects/[PROJECT_ID]" - * "organizations/[ORGANIZATION_ID]" - * "billingAccounts/[BILLING_ACCOUNT_ID]" - * "folders/[FOLDER_ID]" - * @param array $optionalArgs { - * Optional. + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * @param array $optionalArgs { + * Optional. * * @type string $pageToken - * A page token is used to specify a page of values to be returned. - * If no page token is specified (the default), the first page - * of values will be returned. Any page token used here must have - * been generated by a previous call to the API. + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. * @type int $pageSize - * The maximum number of resources contained in the underlying API - * response. The API may return fewer values in a page, even if - * there are additional values to be retrieved. + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * * @return \Google\ApiCore\PagedListResponse * * @throws ApiException if the remote call fails - * @experimental */ - public function listExclusions($parent, array $optionalArgs = []) + public function listViews($parent, array $optionalArgs = []) { - $request = new ListExclusionsRequest(); + $request = new ListViewsRequest(); + $requestParamHeaders = []; $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; if (isset($optionalArgs['pageToken'])) { $request->setPageToken($optionalArgs['pageToken']); } + if (isset($optionalArgs['pageSize'])) { $request->setPageSize($optionalArgs['pageSize']); } - $requestParams = new RequestParamsHeaderDescriptor([ - 'parent' => $request->getParent(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->getPagedListResponse( - 'ListExclusions', - $optionalArgs, - ListExclusionsResponse::class, - $request - ); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListViews', $optionalArgs, ListViewsResponse::class, $request); } /** - * Gets the description of an exclusion. + * Undeletes a bucket. A bucket that has been deleted may be undeleted within + * the grace period of 7 days. * * Sample code: * ``` * $configServiceV2Client = new ConfigServiceV2Client(); * try { - * $formattedName = $configServiceV2Client->exclusionName('[PROJECT]', '[EXCLUSION]'); - * $response = $configServiceV2Client->getExclusion($formattedName); + * $formattedName = $configServiceV2Client->logBucketName('[PROJECT]', '[LOCATION]', '[BUCKET]'); + * $configServiceV2Client->undeleteBucket($formattedName); * } finally { * $configServiceV2Client->close(); * } * ``` * - * @param string $name Required. The resource name of an existing exclusion: + * @param string $name Required. The full resource name of the bucket to undelete. * - * "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]" + * "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/exclusions/my-exclusion-id"`. - * @param array $optionalArgs { - * Optional. + * Example: + * `"projects/my-project-id/locations/my-location/buckets/my-bucket-id"`. + * @param array $optionalArgs { + * Optional. * * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Logging\V2\LogExclusion - * * @throws ApiException if the remote call fails - * @experimental */ - public function getExclusion($name, array $optionalArgs = []) + public function undeleteBucket($name, array $optionalArgs = []) { - $request = new GetExclusionRequest(); + $request = new UndeleteBucketRequest(); + $requestParamHeaders = []; $request->setName($name); - - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'GetExclusion', - LogExclusion::class, - $optionalArgs, - $request - )->wait(); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('UndeleteBucket', GPBEmpty::class, $optionalArgs, $request)->wait(); } /** - * 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. + * 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. * * Sample code: * ``` * $configServiceV2Client = new ConfigServiceV2Client(); * try { - * $formattedParent = $configServiceV2Client->projectName('[PROJECT]'); - * $exclusion = new LogExclusion(); - * $response = $configServiceV2Client->createExclusion($formattedParent, $exclusion); + * $formattedName = $configServiceV2Client->logBucketName('[PROJECT]', '[LOCATION]', '[BUCKET]'); + * $bucket = new LogBucket(); + * $updateMask = new FieldMask(); + * $response = $configServiceV2Client->updateBucket($formattedName, $bucket, $updateMask); * } finally { * $configServiceV2Client->close(); * } * ``` * - * @param string $parent Required. The parent resource in which to create the exclusion: + * @param string $name Required. The full resource name of the bucket to update. * - * "projects/[PROJECT_ID]" - * "organizations/[ORGANIZATION_ID]" - * "billingAccounts/[BILLING_ACCOUNT_ID]" - * "folders/[FOLDER_ID]" + * "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]" * - * Examples: `"projects/my-logging-project"`, `"organizations/123456789"`. - * @param LogExclusion $exclusion Required. The new exclusion, whose `name` parameter is an exclusion name - * that is not already used in the parent resource. - * @param array $optionalArgs { - * Optional. + * Example: + * `"projects/my-project-id/locations/my-location/buckets/my-bucket-id"`. Also + * requires permission "resourcemanager.projects.updateLiens" to set the + * locked property + * @param LogBucket $bucket Required. The updated bucket. + * @param FieldMask $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 array $optionalArgs { + * Optional. * * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Logging\V2\LogExclusion + * @return \Google\Cloud\Logging\V2\LogBucket * * @throws ApiException if the remote call fails - * @experimental */ - public function createExclusion($parent, $exclusion, array $optionalArgs = []) + public function updateBucket($name, $bucket, $updateMask, array $optionalArgs = []) { - $request = new CreateExclusionRequest(); - $request->setParent($parent); - $request->setExclusion($exclusion); - - $requestParams = new RequestParamsHeaderDescriptor([ - 'parent' => $request->getParent(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'CreateExclusion', - LogExclusion::class, - $optionalArgs, - $request - )->wait(); + $request = new UpdateBucketRequest(); + $requestParamHeaders = []; + $request->setName($name); + $request->setBucket($bucket); + $request->setUpdateMask($updateMask); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('UpdateBucket', LogBucket::class, $optionalArgs, $request)->wait(); } /** - * Changes one or more properties of an existing exclusion. + * 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](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. * * Sample code: * ``` * $configServiceV2Client = new ConfigServiceV2Client(); * try { - * $formattedName = $configServiceV2Client->exclusionName('[PROJECT]', '[EXCLUSION]'); - * $exclusion = new LogExclusion(); - * $updateMask = new FieldMask(); - * $response = $configServiceV2Client->updateExclusion($formattedName, $exclusion, $updateMask); + * $response = $configServiceV2Client->updateCmekSettings(); * } finally { * $configServiceV2Client->close(); * } * ``` * - * @param string $name Required. The resource name of the exclusion to update: + * @param array $optionalArgs { + * Optional. * - * "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]" + * @type string $name + * Required. The resource name for the CMEK settings to update. * - * Example: `"projects/my-project-id/exclusions/my-exclusion-id"`. - * @param LogExclusion $exclusion Required. New values for the existing exclusion. Only the fields specified - * in `update_mask` are relevant. - * @param FieldMask $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 - * [LogExclusion][google.logging.v2.LogExclusion] included in this request. Fields not mentioned in - * `update_mask` are not changed and are ignored in the request. + * "projects/[PROJECT_ID]/cmekSettings" + * "organizations/[ORGANIZATION_ID]/cmekSettings" + * "billingAccounts/[BILLING_ACCOUNT_ID]/cmekSettings" + * "folders/[FOLDER_ID]/cmekSettings" * - * For example, to change the filter and description of an exclusion, - * specify an `update_mask` of `"filter,description"`. - * @param array $optionalArgs { - * Optional. + * 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. + * @type CmekSettings $cmekSettings + * Required. The CMEK settings to update. + * + * See [Enabling CMEK for Logs + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. + * @type FieldMask $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 [FieldMask][google.protobuf.FieldMask] for more information. + * + * Example: `"updateMask=kmsKeyName"` * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Logging\V2\LogExclusion + * @return \Google\Cloud\Logging\V2\CmekSettings * * @throws ApiException if the remote call fails - * @experimental */ - public function updateExclusion($name, $exclusion, $updateMask, array $optionalArgs = []) + public function updateCmekSettings(array $optionalArgs = []) { - $request = new UpdateExclusionRequest(); - $request->setName($name); - $request->setExclusion($exclusion); - $request->setUpdateMask($updateMask); + $request = new UpdateCmekSettingsRequest(); + $requestParamHeaders = []; + if (isset($optionalArgs['name'])) { + $request->setName($optionalArgs['name']); + $requestParamHeaders['name'] = $optionalArgs['name']; + } - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); + if (isset($optionalArgs['cmekSettings'])) { + $request->setCmekSettings($optionalArgs['cmekSettings']); + } + + if (isset($optionalArgs['updateMask'])) { + $request->setUpdateMask($optionalArgs['updateMask']); + } - return $this->startCall( - 'UpdateExclusion', - LogExclusion::class, - $optionalArgs, - $request - )->wait(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('UpdateCmekSettings', CmekSettings::class, $optionalArgs, $request)->wait(); } /** - * Deletes an exclusion. + * Changes one or more properties of an existing exclusion. * * Sample code: * ``` * $configServiceV2Client = new ConfigServiceV2Client(); * try { - * $formattedName = $configServiceV2Client->exclusionName('[PROJECT]', '[EXCLUSION]'); - * $configServiceV2Client->deleteExclusion($formattedName); + * $formattedName = $configServiceV2Client->logExclusionName('[PROJECT]', '[EXCLUSION]'); + * $exclusion = new LogExclusion(); + * $updateMask = new FieldMask(); + * $response = $configServiceV2Client->updateExclusion($formattedName, $exclusion, $updateMask); * } finally { * $configServiceV2Client->close(); * } * ``` * - * @param string $name Required. The resource name of an existing exclusion to delete: + * @param string $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]" + * "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 array $optionalArgs { - * Optional. + * Example: `"projects/my-project-id/exclusions/my-exclusion-id"`. + * @param LogExclusion $exclusion Required. New values for the existing exclusion. Only the fields specified in + * `update_mask` are relevant. + * @param FieldMask $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 + * [LogExclusion][google.logging.v2.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 array $optionalArgs { + * Optional. * * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * + * @return \Google\Cloud\Logging\V2\LogExclusion + * * @throws ApiException if the remote call fails - * @experimental */ - public function deleteExclusion($name, array $optionalArgs = []) + public function updateExclusion($name, $exclusion, $updateMask, array $optionalArgs = []) { - $request = new DeleteExclusionRequest(); + $request = new UpdateExclusionRequest(); + $requestParamHeaders = []; $request->setName($name); - - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'DeleteExclusion', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); + $request->setExclusion($exclusion); + $request->setUpdateMask($updateMask); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('UpdateExclusion', LogExclusion::class, $optionalArgs, $request)->wait(); } /** - * 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. + * Updates a sink. This method replaces the following fields in the existing + * sink with values from the new sink: `destination`, and `filter`. * - * See [Enabling CMEK for Logs - * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) for more information. + * The updated sink might also have a new `writer_identity`; see the + * `unique_writer_identity` field. * * Sample code: * ``` * $configServiceV2Client = new ConfigServiceV2Client(); * try { - * $response = $configServiceV2Client->getCmekSettings(); + * $formattedSinkName = $configServiceV2Client->logSinkName('[PROJECT]', '[SINK]'); + * $sink = new LogSink(); + * $response = $configServiceV2Client->updateSink($formattedSinkName, $sink); * } finally { * $configServiceV2Client->close(); * } * ``` * - * @param array $optionalArgs { - * Optional. + * @param string $sinkName Required. The full resource name of the sink to update, including the parent + * resource and the sink identifier: * - * @type string $name - * Required. The resource for which to retrieve CMEK settings. + * "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 LogSink $sink Required. The updated sink, whose name is the same identifier that appears as part + * of `sink_name`. + * @param array $optionalArgs { + * Optional. + * + * @type bool $uniqueWriterIdentity + * 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. + * @type FieldMask $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. * - * "projects/[PROJECT_ID]/cmekSettings" - * "organizations/[ORGANIZATION_ID]/cmekSettings" - * "billingAccounts/[BILLING_ACCOUNT_ID]/cmekSettings" - * "folders/[FOLDER_ID]/cmekSettings" + * 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. * - * Example: `"organizations/12345/cmekSettings"`. + * For a detailed `FieldMask` definition, see + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask * - * 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. + * Example: `updateMask=filter`. * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Logging\V2\CmekSettings + * @return \Google\Cloud\Logging\V2\LogSink * * @throws ApiException if the remote call fails - * @experimental */ - public function getCmekSettings(array $optionalArgs = []) + public function updateSink($sinkName, $sink, array $optionalArgs = []) { - $request = new GetCmekSettingsRequest(); - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); + $request = new UpdateSinkRequest(); + $requestParamHeaders = []; + $request->setSinkName($sinkName); + $request->setSink($sink); + $requestParamHeaders['sink_name'] = $sinkName; + if (isset($optionalArgs['uniqueWriterIdentity'])) { + $request->setUniqueWriterIdentity($optionalArgs['uniqueWriterIdentity']); } - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); + if (isset($optionalArgs['updateMask'])) { + $request->setUpdateMask($optionalArgs['updateMask']); + } - return $this->startCall( - 'GetCmekSettings', - CmekSettings::class, - $optionalArgs, - $request - )->wait(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('UpdateSink', LogSink::class, $optionalArgs, $request)->wait(); } /** - * 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](https://cloud.google.com/logging/docs/routing/managed-encryption) for more information. + * Updates a view. This method replaces the following fields in the existing + * view with values from the new view: `filter`. * * Sample code: * ``` * $configServiceV2Client = new ConfigServiceV2Client(); * try { - * $response = $configServiceV2Client->updateCmekSettings(); + * $name = 'name'; + * $view = new LogView(); + * $response = $configServiceV2Client->updateView($name, $view); * } finally { * $configServiceV2Client->close(); * } * ``` * - * @param array $optionalArgs { - * Optional. - * - * @type string $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" + * @param string $name Required. The full resource name of the view to update * - * Example: `"organizations/12345/cmekSettings"`. + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" * - * 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. - * @type CmekSettings $cmekSettings - * Required. The CMEK settings to update. + * Example: + * `"projects/my-project-id/locations/my-location/buckets/my-bucket-id/views/my-view-id"`. + * @param LogView $view Required. The updated view. + * @param array $optionalArgs { + * Optional. * - * See [Enabling CMEK for Logs - * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) for more information. * @type FieldMask $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. + * Optional. Field mask that specifies the fields in `view` that need + * an update. A field will be overwritten if, and only if, it is + * in the update mask. `name` and output only fields cannot be updated. * - * See [FieldMask][google.protobuf.FieldMask] for more information. + * For a detailed `FieldMask` definition, see + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask * - * Example: `"updateMask=kmsKeyName"` + * Example: `updateMask=filter`. * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Logging\V2\CmekSettings + * @return \Google\Cloud\Logging\V2\LogView * * @throws ApiException if the remote call fails - * @experimental */ - public function updateCmekSettings(array $optionalArgs = []) + public function updateView($name, $view, array $optionalArgs = []) { - $request = new UpdateCmekSettingsRequest(); - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - } - if (isset($optionalArgs['cmekSettings'])) { - $request->setCmekSettings($optionalArgs['cmekSettings']); - } + $request = new UpdateViewRequest(); + $requestParamHeaders = []; + $request->setName($name); + $request->setView($view); + $requestParamHeaders['name'] = $name; if (isset($optionalArgs['updateMask'])) { $request->setUpdateMask($optionalArgs['updateMask']); } - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'UpdateCmekSettings', - CmekSettings::class, - $optionalArgs, - $request - )->wait(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('UpdateView', LogView::class, $optionalArgs, $request)->wait(); } } diff --git a/Logging/src/V2/Gapic/LoggingServiceV2GapicClient.php b/Logging/src/V2/Gapic/LoggingServiceV2GapicClient.php index f39ef43ff610..3350ab7ac530 100644 --- a/Logging/src/V2/Gapic/LoggingServiceV2GapicClient.php +++ b/Logging/src/V2/Gapic/LoggingServiceV2GapicClient.php @@ -17,24 +17,25 @@ /* * GENERATED CODE WARNING - * This file was generated from the file - * https://github.com/google/googleapis/blob/master/google/logging/v2/logging.proto - * and updates to that file get reflected here through a refresh process. - * - * @experimental + * Generated by gapic-generator-php from the file + * https://github.com/googleapis/googleapis/blob/master/google/logging/v2/logging.proto + * Updates to the above are reflected here through a refresh process. */ namespace Google\Cloud\Logging\V2\Gapic; use Google\ApiCore\ApiException; +use Google\ApiCore\Call; +use Google\Api\MonitoredResource; + use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\PathTemplate; use Google\ApiCore\RequestParamsHeaderDescriptor; use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; + use Google\ApiCore\ValidationException; -use Google\Api\MonitoredResource; use Google\Auth\FetchAuthTokenInterface; use Google\Cloud\Logging\V2\DeleteLogRequest; use Google\Cloud\Logging\V2\ListLogEntriesRequest; @@ -44,6 +45,8 @@ use Google\Cloud\Logging\V2\ListMonitoredResourceDescriptorsRequest; use Google\Cloud\Logging\V2\ListMonitoredResourceDescriptorsResponse; use Google\Cloud\Logging\V2\LogEntry; +use Google\Cloud\Logging\V2\TailLogEntriesRequest; +use Google\Cloud\Logging\V2\TailLogEntriesResponse; use Google\Cloud\Logging\V2\WriteLogEntriesRequest; use Google\Cloud\Logging\V2\WriteLogEntriesResponse; use Google\Protobuf\GPBEmpty; @@ -64,12 +67,10 @@ * } * ``` * - * Many parameters require resource names to be formatted in a particular way. To assist - * with these names, this class includes a format method for each type of name, and additionally - * a parseName method to extract the individual identifiers contained within formatted names - * that are returned by the API. - * - * @experimental + * Many parameters require resource names to be formatted in a particular way. To + * assist with these names, this class includes a format method for each type of + * name, and additionally a parseName method to extract the individual identifiers + * contained within formatted names that are returned by the API. */ class LoggingServiceV2GapicClient { @@ -105,56 +106,67 @@ class LoggingServiceV2GapicClient 'https://www.googleapis.com/auth/logging.read', 'https://www.googleapis.com/auth/logging.write', ]; - private static $billingNameTemplate; - private static $billingLogNameTemplate; + + private static $billingAccountNameTemplate; + + private static $billingAccountLogNameTemplate; + private static $folderNameTemplate; + private static $folderLogNameTemplate; + private static $logNameTemplate; + private static $organizationNameTemplate; + private static $organizationLogNameTemplate; + private static $projectNameTemplate; + + private static $projectLogNameTemplate; + private static $pathTemplateMap; private static function getClientDefaults() { return [ 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS.':'.self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__.'/../resources/logging_service_v2_client_config.json', - 'descriptorsConfigPath' => __DIR__.'/../resources/logging_service_v2_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__.'/../resources/logging_service_v2_grpc_config.json', + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/logging_service_v2_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/logging_service_v2_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/logging_service_v2_grpc_config.json', 'credentialsConfig' => [ - 'scopes' => self::$serviceScopes, + 'defaultScopes' => self::$serviceScopes, ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => __DIR__.'/../resources/logging_service_v2_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/logging_service_v2_rest_client_config.php', ], ], ]; } - private static function getBillingNameTemplate() + private static function getBillingAccountNameTemplate() { - if (null == self::$billingNameTemplate) { - self::$billingNameTemplate = new PathTemplate('billingAccounts/{billing_account}'); + if (self::$billingAccountNameTemplate == null) { + self::$billingAccountNameTemplate = new PathTemplate('billingAccounts/{billing_account}'); } - return self::$billingNameTemplate; + return self::$billingAccountNameTemplate; } - private static function getBillingLogNameTemplate() + private static function getBillingAccountLogNameTemplate() { - if (null == self::$billingLogNameTemplate) { - self::$billingLogNameTemplate = new PathTemplate('billingAccounts/{billing_account}/logs/{log}'); + if (self::$billingAccountLogNameTemplate == null) { + self::$billingAccountLogNameTemplate = new PathTemplate('billingAccounts/{billing_account}/logs/{log}'); } - return self::$billingLogNameTemplate; + return self::$billingAccountLogNameTemplate; } private static function getFolderNameTemplate() { - if (null == self::$folderNameTemplate) { + if (self::$folderNameTemplate == null) { self::$folderNameTemplate = new PathTemplate('folders/{folder}'); } @@ -163,7 +175,7 @@ private static function getFolderNameTemplate() private static function getFolderLogNameTemplate() { - if (null == self::$folderLogNameTemplate) { + if (self::$folderLogNameTemplate == null) { self::$folderLogNameTemplate = new PathTemplate('folders/{folder}/logs/{log}'); } @@ -172,7 +184,7 @@ private static function getFolderLogNameTemplate() private static function getLogNameTemplate() { - if (null == self::$logNameTemplate) { + if (self::$logNameTemplate == null) { self::$logNameTemplate = new PathTemplate('projects/{project}/logs/{log}'); } @@ -181,7 +193,7 @@ private static function getLogNameTemplate() private static function getOrganizationNameTemplate() { - if (null == self::$organizationNameTemplate) { + if (self::$organizationNameTemplate == null) { self::$organizationNameTemplate = new PathTemplate('organizations/{organization}'); } @@ -190,7 +202,7 @@ private static function getOrganizationNameTemplate() private static function getOrganizationLogNameTemplate() { - if (null == self::$organizationLogNameTemplate) { + if (self::$organizationLogNameTemplate == null) { self::$organizationLogNameTemplate = new PathTemplate('organizations/{organization}/logs/{log}'); } @@ -199,25 +211,35 @@ private static function getOrganizationLogNameTemplate() private static function getProjectNameTemplate() { - if (null == self::$projectNameTemplate) { + if (self::$projectNameTemplate == null) { self::$projectNameTemplate = new PathTemplate('projects/{project}'); } return self::$projectNameTemplate; } + private static function getProjectLogNameTemplate() + { + if (self::$projectLogNameTemplate == null) { + self::$projectLogNameTemplate = new PathTemplate('projects/{project}/logs/{log}'); + } + + return self::$projectLogNameTemplate; + } + private static function getPathTemplateMap() { - if (null == self::$pathTemplateMap) { + if (self::$pathTemplateMap == null) { self::$pathTemplateMap = [ - 'billing' => self::getBillingNameTemplate(), - 'billingLog' => self::getBillingLogNameTemplate(), + 'billingAccount' => self::getBillingAccountNameTemplate(), + 'billingAccountLog' => self::getBillingAccountLogNameTemplate(), 'folder' => self::getFolderNameTemplate(), 'folderLog' => self::getFolderLogNameTemplate(), 'log' => self::getLogNameTemplate(), 'organization' => self::getOrganizationNameTemplate(), 'organizationLog' => self::getOrganizationLogNameTemplate(), 'project' => self::getProjectNameTemplate(), + 'projectLog' => self::getProjectLogNameTemplate(), ]; } @@ -225,47 +247,44 @@ private static function getPathTemplateMap() } /** - * Formats a string containing the fully-qualified path to represent - * a billing resource. + * Formats a string containing the fully-qualified path to represent a + * billing_account resource. * * @param string $billingAccount * - * @return string The formatted billing resource. - * @experimental + * @return string The formatted billing_account resource. */ - public static function billingName($billingAccount) + public static function billingAccountName($billingAccount) { - return self::getBillingNameTemplate()->render([ + return self::getBillingAccountNameTemplate()->render([ 'billing_account' => $billingAccount, ]); } /** - * Formats a string containing the fully-qualified path to represent - * a billing_log resource. + * Formats a string containing the fully-qualified path to represent a + * billing_account_log resource. * * @param string $billingAccount * @param string $log * - * @return string The formatted billing_log resource. - * @experimental + * @return string The formatted billing_account_log resource. */ - public static function billingLogName($billingAccount, $log) + public static function billingAccountLogName($billingAccount, $log) { - return self::getBillingLogNameTemplate()->render([ + return self::getBillingAccountLogNameTemplate()->render([ 'billing_account' => $billingAccount, 'log' => $log, ]); } /** - * Formats a string containing the fully-qualified path to represent - * a folder resource. + * Formats a string containing the fully-qualified path to represent a folder + * resource. * * @param string $folder * * @return string The formatted folder resource. - * @experimental */ public static function folderName($folder) { @@ -275,14 +294,13 @@ public static function folderName($folder) } /** - * Formats a string containing the fully-qualified path to represent - * a folder_log resource. + * Formats a string containing the fully-qualified path to represent a folder_log + * resource. * * @param string $folder * @param string $log * * @return string The formatted folder_log resource. - * @experimental */ public static function folderLogName($folder, $log) { @@ -293,14 +311,13 @@ public static function folderLogName($folder, $log) } /** - * Formats a string containing the fully-qualified path to represent - * a log resource. + * Formats a string containing the fully-qualified path to represent a log + * resource. * * @param string $project * @param string $log * * @return string The formatted log resource. - * @experimental */ public static function logName($project, $log) { @@ -311,13 +328,12 @@ public static function logName($project, $log) } /** - * Formats a string containing the fully-qualified path to represent - * a organization resource. + * Formats a string containing the fully-qualified path to represent a organization + * resource. * * @param string $organization * * @return string The formatted organization resource. - * @experimental */ public static function organizationName($organization) { @@ -327,14 +343,13 @@ public static function organizationName($organization) } /** - * Formats a string containing the fully-qualified path to represent - * a organization_log resource. + * Formats a string containing the fully-qualified path to represent a + * organization_log resource. * * @param string $organization * @param string $log * * @return string The formatted organization_log resource. - * @experimental */ public static function organizationLogName($organization, $log) { @@ -345,13 +360,12 @@ public static function organizationLogName($organization, $log) } /** - * Formats a string containing the fully-qualified path to represent - * a project resource. + * Formats a string containing the fully-qualified path to represent a project + * resource. * * @param string $project * * @return string The formatted project resource. - * @experimental */ public static function projectName($project) { @@ -360,23 +374,42 @@ public static function projectName($project) ]); } + /** + * Formats a string containing the fully-qualified path to represent a project_log + * resource. + * + * @param string $project + * @param string $log + * + * @return string The formatted project_log resource. + */ + public static function projectLogName($project, $log) + { + return self::getProjectLogNameTemplate()->render([ + 'project' => $project, + 'log' => $log, + ]); + } + /** * Parses a formatted name string and returns an associative array of the components in the name. * The following name formats are supported: * Template: Pattern - * - billing: billingAccounts/{billing_account} - * - billingLog: billingAccounts/{billing_account}/logs/{log} + * - billingAccount: billingAccounts/{billing_account} + * - billingAccountLog: billingAccounts/{billing_account}/logs/{log} * - folder: folders/{folder} * - folderLog: folders/{folder}/logs/{log} * - log: projects/{project}/logs/{log} * - organization: organizations/{organization} * - organizationLog: organizations/{organization}/logs/{log} - * - project: projects/{project}. + * - project: projects/{project} + * - projectLog: projects/{project}/logs/{log} * - * The optional $template argument can be supplied to specify a particular pattern, and must - * match one of the templates listed above. If no $template argument is provided, or if the - * $template argument does not match one of the templates listed, then parseName will check - * each of the supported templates, and return the first match. + * The optional $template argument can be supplied to specify a particular pattern, + * and must match one of the templates listed above. If no $template argument is + * provided, or if the $template argument does not match one of the templates + * listed, then parseName will check each of the supported templates, and return + * the first match. * * @param string $formattedName The formatted name string * @param string $template Optional name of template to match @@ -384,12 +417,10 @@ public static function projectName($project) * @return array An associative array from name component IDs to component values. * * @throws ValidationException If $formattedName could not be matched. - * @experimental */ public static function parseName($formattedName, $template = null) { $templateMap = self::getPathTemplateMap(); - if ($template) { if (!isset($templateMap[$template])) { throw new ValidationException("Template name $template does not exist"); @@ -405,6 +436,7 @@ public static function parseName($formattedName, $template = null) // Swallow the exception to continue trying other path templates } } + throw new ValidationException("Input did not match any known format. Input: $formattedName"); } @@ -412,7 +444,7 @@ public static function parseName($formattedName, $template = null) * Constructor. * * @param array $options { - * Optional. Options for configuring the service API wrapper. + * Optional. Options for configuring the service API wrapper. * * @type string $serviceAddress * **Deprecated**. This option will be removed in a future major release. Please @@ -429,39 +461,41 @@ public static function parseName($formattedName, $template = null) * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these * objects are provided, any settings in $credentialsConfig will be ignored. * @type array $credentialsConfig - * Options used to configure credentials, including auth token caching, for the client. - * For a full list of supporting configuration options, see - * {@see \Google\ApiCore\CredentialsWrapper::build()}. + * Options used to configure credentials, including auth token caching, for the + * client. For a full list of supporting configuration options, see + * {@see \Google\ApiCore\CredentialsWrapper::build()} . * @type bool $disableRetries * Determines whether or not retries defined by the client configuration should be * disabled. Defaults to `false`. * @type string|array $clientConfig - * Client method configuration, including retry settings. This option can be either a - * path to a JSON file, or a PHP array containing the decoded JSON data. - * By default this settings points to the default client config file, which is provided - * in the resources folder. + * Client method configuration, including retry settings. This option can be either + * a path to a JSON file, or a PHP array containing the decoded JSON data. By + * default this settings points to the default client config file, which is + * provided in the resources folder. * @type string|TransportInterface $transport - * The transport used for executing network requests. May be either the string `rest` - * or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. - * *Advanced usage*: Additionally, it is possible to pass in an already instantiated - * {@see \Google\ApiCore\Transport\TransportInterface} object. Note that when this - * object is provided, any settings in $transportConfig, and any `$apiEndpoint` - * setting, will be ignored. + * The transport used for executing network requests. May be either the string + * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. + * *Advanced usage*: Additionally, it is possible to pass in an already + * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note + * that when this object is provided, any settings in $transportConfig, and any + * $serviceAddress setting, will be ignored. * @type array $transportConfig * Configuration options that will be used to construct the transport. Options for * each supported transport type should be passed in a key for that transport. For * example: * $transportConfig = [ * 'grpc' => [...], - * 'rest' => [...] + * 'rest' => [...], * ]; * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the * supported options. + * @type callable $clientCertSource + * A callable which returns the client cert as a string. This can be used to + * provide a certificate and private key to the transport layer for mTLS. * } * * @throws ValidationException - * @experimental */ public function __construct(array $options = []) { @@ -486,202 +520,167 @@ public function __construct(array $options = []) * } * ``` * - * @param string $logName Required. The resource name of the log to delete: + * @param string $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]" + * "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]. - * @param array $optionalArgs { - * Optional. + * `[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]. + * @param array $optionalArgs { + * Optional. * * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * * @throws ApiException if the remote call fails - * @experimental */ public function deleteLog($logName, array $optionalArgs = []) { $request = new DeleteLogRequest(); + $requestParamHeaders = []; $request->setLogName($logName); - - $requestParams = new RequestParamsHeaderDescriptor([ - 'log_name' => $request->getLogName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'DeleteLog', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); + $requestParamHeaders['log_name'] = $logName; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('DeleteLog', GPBEmpty::class, $optionalArgs, $request)->wait(); } /** - * 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). + * 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](https://cloud.google.com/logging/docs/export). * * Sample code: * ``` * $loggingServiceV2Client = new LoggingServiceV2Client(); * try { - * $entries = []; - * $response = $loggingServiceV2Client->writeLogEntries($entries); + * $formattedResourceNames = [ + * $loggingServiceV2Client->projectName('[PROJECT]'), + * ]; + * // Iterate over pages of elements + * $pagedResponse = $loggingServiceV2Client->listLogEntries($formattedResourceNames); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $loggingServiceV2Client->listLogEntries($formattedResourceNames); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } * } finally { * $loggingServiceV2Client->close(); * } * ``` * - * @param LogEntry[] $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 - * [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](https://cloud.google.com/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](https://cloud.google.com/logging/docs/api/tasks/exporting-logs). - * - * To improve throughput and to avoid exceeding the - * [quota limit](https://cloud.google.com/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 array $optionalArgs { - * Optional. - * - * @type string $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: + * @param string[] $resourceNames Required. Names of one or more parent resources from which to + * retrieve log entries: * - * "projects/my-project-id/logs/syslog" - * "organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity" + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" * - * 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. - * @type MonitoredResource $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: + * May alternatively be one or more views + * projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] * - * { "type": "gce_instance", - * "labels": { - * "zone": "us-central1-a", "instance_id": "00000000000000000000" }} + * Projects listed in the `project_ids` field are added to this list. + * @param array $optionalArgs { + * Optional. * - * See [LogEntry][google.logging.v2.LogEntry]. - * @type array $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 [LogEntry][google.logging.v2.LogEntry]. - * @type bool $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. - * @type bool $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. + * @type string $filter + * Optional. A filter that chooses which log entries to return. See [Advanced + * Logs Queries](https://cloud.google.com/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. + * @type string $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. + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Logging\V2\WriteLogEntriesResponse + * @return \Google\ApiCore\PagedListResponse * * @throws ApiException if the remote call fails - * @experimental */ - public function writeLogEntries($entries, array $optionalArgs = []) + public function listLogEntries($resourceNames, array $optionalArgs = []) { - $request = new WriteLogEntriesRequest(); - $request->setEntries($entries); - if (isset($optionalArgs['logName'])) { - $request->setLogName($optionalArgs['logName']); - } - if (isset($optionalArgs['resource'])) { - $request->setResource($optionalArgs['resource']); + $request = new ListLogEntriesRequest(); + $request->setResourceNames($resourceNames); + if (isset($optionalArgs['filter'])) { + $request->setFilter($optionalArgs['filter']); } - if (isset($optionalArgs['labels'])) { - $request->setLabels($optionalArgs['labels']); + + if (isset($optionalArgs['orderBy'])) { + $request->setOrderBy($optionalArgs['orderBy']); } - if (isset($optionalArgs['partialSuccess'])) { - $request->setPartialSuccess($optionalArgs['partialSuccess']); + + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); } - if (isset($optionalArgs['dryRun'])) { - $request->setDryRun($optionalArgs['dryRun']); + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); } - return $this->startCall( - 'WriteLogEntries', - WriteLogEntriesResponse::class, - $optionalArgs, - $request - )->wait(); + return $this->getPagedListResponse('ListLogEntries', $optionalArgs, ListLogEntriesResponse::class, $request); } /** - * 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](https://cloud.google.com/logging/docs/export). + * Lists the logs in projects, organizations, folders, or billing accounts. + * Only logs that have entries are listed. * * Sample code: * ``` * $loggingServiceV2Client = new LoggingServiceV2Client(); * try { - * $formattedResourceNames = []; + * $formattedParent = $loggingServiceV2Client->projectName('[PROJECT]'); * // Iterate over pages of elements - * $pagedResponse = $loggingServiceV2Client->listLogEntries($formattedResourceNames); + * $pagedResponse = $loggingServiceV2Client->listLogs($formattedParent); * foreach ($pagedResponse->iteratePages() as $page) { * foreach ($page as $element) { * // doSomethingWith($element); * } * } - * - * * // Alternatively: - * * // Iterate through all elements - * $pagedResponse = $loggingServiceV2Client->listLogEntries($formattedResourceNames); + * $pagedResponse = $loggingServiceV2Client->listLogs($formattedParent); * foreach ($pagedResponse->iterateAllElements() as $element) { * // doSomethingWith($element); * } @@ -690,82 +689,68 @@ public function writeLogEntries($entries, array $optionalArgs = []) * } * ``` * - * @param string[] $resourceNames Required. Names of one or more parent resources from which to - * retrieve log entries: + * @param string $parent Required. The resource name that owns the logs: * - * "projects/[PROJECT_ID]" - * "organizations/[ORGANIZATION_ID]" - * "billingAccounts/[BILLING_ACCOUNT_ID]" - * "folders/[FOLDER_ID]" - * @param array $optionalArgs { - * Optional. + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @param array $optionalArgs { + * Optional. * - * @type string[] $projectIds - * Deprecated. Use `resource_names` instead. One or more project identifiers - * or project numbers from which to retrieve log entries. Example: - * `"my-project-1A"`. - * @type string $filter - * Optional. A filter that chooses which log entries to return. See [Advanced - * Logs Queries](https://cloud.google.com/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. - * @type string $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. * @type int $pageSize - * The maximum number of resources contained in the underlying API - * response. The API may return fewer values in a page, even if - * there are additional values to be retrieved. + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. * @type string $pageToken - * A page token is used to specify a page of values to be returned. - * If no page token is specified (the default), the first page - * of values will be returned. Any page token used here must have - * been generated by a previous call to the API. + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type string[] $resourceNames + * Optional. The resource name that owns the logs: + * projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * + * To support legacy queries, it could also be: + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * * @return \Google\ApiCore\PagedListResponse * * @throws ApiException if the remote call fails - * @experimental */ - public function listLogEntries($resourceNames, array $optionalArgs = []) + public function listLogs($parent, array $optionalArgs = []) { - $request = new ListLogEntriesRequest(); - $request->setResourceNames($resourceNames); - if (isset($optionalArgs['projectIds'])) { - $request->setProjectIds($optionalArgs['projectIds']); - } - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - if (isset($optionalArgs['orderBy'])) { - $request->setOrderBy($optionalArgs['orderBy']); - } + $request = new ListLogsRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; if (isset($optionalArgs['pageSize'])) { $request->setPageSize($optionalArgs['pageSize']); } + if (isset($optionalArgs['pageToken'])) { $request->setPageToken($optionalArgs['pageToken']); } - return $this->getPagedListResponse( - 'ListLogEntries', - $optionalArgs, - ListLogEntriesResponse::class, - $request - ); + if (isset($optionalArgs['resourceNames'])) { + $request->setResourceNames($optionalArgs['resourceNames']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListLogs', $optionalArgs, ListLogsResponse::class, $request); } /** @@ -782,10 +767,7 @@ public function listLogEntries($resourceNames, array $optionalArgs = []) * // doSomethingWith($element); * } * } - * - * * // Alternatively: - * * // Iterate through all elements * $pagedResponse = $loggingServiceV2Client->listMonitoredResourceDescriptors(); * foreach ($pagedResponse->iterateAllElements() as $element) { @@ -797,28 +779,27 @@ public function listLogEntries($resourceNames, array $optionalArgs = []) * ``` * * @param array $optionalArgs { - * Optional. + * Optional. * * @type int $pageSize - * The maximum number of resources contained in the underlying API - * response. The API may return fewer values in a page, even if - * there are additional values to be retrieved. + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. * @type string $pageToken - * A page token is used to specify a page of values to be returned. - * If no page token is specified (the default), the first page - * of values will be returned. Any page token used here must have - * been generated by a previous call to the API. + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * * @return \Google\ApiCore\PagedListResponse * * @throws ApiException if the remote call fails - * @experimental */ public function listMonitoredResourceDescriptors(array $optionalArgs = []) { @@ -826,101 +807,200 @@ public function listMonitoredResourceDescriptors(array $optionalArgs = []) if (isset($optionalArgs['pageSize'])) { $request->setPageSize($optionalArgs['pageSize']); } + if (isset($optionalArgs['pageToken'])) { $request->setPageToken($optionalArgs['pageToken']); } - return $this->getPagedListResponse( - 'ListMonitoredResourceDescriptors', - $optionalArgs, - ListMonitoredResourceDescriptorsResponse::class, - $request - ); + return $this->getPagedListResponse('ListMonitoredResourceDescriptors', $optionalArgs, ListMonitoredResourceDescriptorsResponse::class, $request); } /** - * Lists the logs in projects, organizations, folders, or billing accounts. - * Only logs that have entries are listed. + * Streaming read of log entries as they are ingested. Until the stream is + * terminated, it will continue reading logs. * * Sample code: * ``` * $loggingServiceV2Client = new LoggingServiceV2Client(); * try { - * $formattedParent = $loggingServiceV2Client->projectName('[PROJECT]'); - * // Iterate over pages of elements - * $pagedResponse = $loggingServiceV2Client->listLogs($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } + * $resourceNames = []; + * $request = new TailLogEntriesRequest(); + * $request->setResourceNames($resourceNames); + * // Write all requests to the server, then read all responses until the + * // stream is complete + * $requests = [ + * $request, + * ]; + * $stream = $loggingServiceV2Client->tailLogEntries(); + * $stream->writeAll($requests); + * foreach ($stream->closeWriteAndReadAll() as $element) { + * // doSomethingWith($element); * } + * // Alternatively: + * // Write requests individually, making read() calls if + * // required. Call closeWrite() once writes are complete, and read the + * // remaining responses from the server. + * $requests = [ + * $request, + * ]; + * $stream = $loggingServiceV2Client->tailLogEntries(); + * foreach ($requests as $request) { + * $stream->write($request); + * // if required, read a single response from the stream + * $element = $stream->read(); + * // doSomethingWith($element) + * } + * $stream->closeWrite(); + * $element = $stream->read(); + * while (!is_null($element)) { + * // doSomethingWith($element) + * $element = $stream->read(); + * } + * } finally { + * $loggingServiceV2Client->close(); + * } + * ``` * + * @param array $optionalArgs { + * Optional. * - * // Alternatively: + * @type int $timeoutMillis + * Timeout to use for this call. + * } * - * // Iterate through all elements - * $pagedResponse = $loggingServiceV2Client->listLogs($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } + * @return \Google\ApiCore\BidiStream + * + * @throws ApiException if the remote call fails + */ + public function tailLogEntries(array $optionalArgs = []) + { + return $this->startCall('TailLogEntries', TailLogEntriesResponse::class, $optionalArgs, null, Call::BIDI_STREAMING_CALL); + } + + /** + * 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) + * + * Sample code: + * ``` + * $loggingServiceV2Client = new LoggingServiceV2Client(); + * try { + * $entries = []; + * $response = $loggingServiceV2Client->writeLogEntries($entries); * } finally { * $loggingServiceV2Client->close(); * } * ``` * - * @param string $parent Required. The resource name that owns the logs: + * @param LogEntry[] $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 + * [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](https://cloud.google.com/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](https://cloud.google.com/logging/docs/api/tasks/exporting-logs). + * + * To improve throughput and to avoid exceeding the + * [quota limit](https://cloud.google.com/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 array $optionalArgs { + * Optional. * - * "projects/[PROJECT_ID]" - * "organizations/[ORGANIZATION_ID]" - * "billingAccounts/[BILLING_ACCOUNT_ID]" - * "folders/[FOLDER_ID]" - * @param array $optionalArgs { - * Optional. + * @type string $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`: * - * @type int $pageSize - * The maximum number of resources contained in the underlying API - * response. The API may return fewer values in a page, even if - * there are additional values to be retrieved. - * @type string $pageToken - * A page token is used to specify a page of values to be returned. - * If no page token is specified (the default), the first page - * of values will be returned. Any page token used here must have - * been generated by a previous call to the API. + * "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. + * @type MonitoredResource $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 [LogEntry][google.logging.v2.LogEntry]. + * @type array $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 [LogEntry][google.logging.v2.LogEntry]. + * @type bool $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. + * @type bool $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. * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\ApiCore\PagedListResponse + * @return \Google\Cloud\Logging\V2\WriteLogEntriesResponse * * @throws ApiException if the remote call fails - * @experimental */ - public function listLogs($parent, array $optionalArgs = []) + public function writeLogEntries($entries, array $optionalArgs = []) { - $request = new ListLogsRequest(); - $request->setParent($parent); - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); + $request = new WriteLogEntriesRequest(); + $request->setEntries($entries); + if (isset($optionalArgs['logName'])) { + $request->setLogName($optionalArgs['logName']); } - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); + + if (isset($optionalArgs['resource'])) { + $request->setResource($optionalArgs['resource']); } - $requestParams = new RequestParamsHeaderDescriptor([ - 'parent' => $request->getParent(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->getPagedListResponse( - 'ListLogs', - $optionalArgs, - ListLogsResponse::class, - $request - ); + if (isset($optionalArgs['labels'])) { + $request->setLabels($optionalArgs['labels']); + } + + if (isset($optionalArgs['partialSuccess'])) { + $request->setPartialSuccess($optionalArgs['partialSuccess']); + } + + if (isset($optionalArgs['dryRun'])) { + $request->setDryRun($optionalArgs['dryRun']); + } + + return $this->startCall('WriteLogEntries', WriteLogEntriesResponse::class, $optionalArgs, $request)->wait(); } } diff --git a/Logging/src/V2/Gapic/MetricsServiceV2GapicClient.php b/Logging/src/V2/Gapic/MetricsServiceV2GapicClient.php index 7ec6133b092a..4a780961c8d4 100644 --- a/Logging/src/V2/Gapic/MetricsServiceV2GapicClient.php +++ b/Logging/src/V2/Gapic/MetricsServiceV2GapicClient.php @@ -17,11 +17,9 @@ /* * GENERATED CODE WARNING - * This file was generated from the file - * https://github.com/google/googleapis/blob/master/google/logging/v2/logging_metrics.proto - * and updates to that file get reflected here through a refresh process. - * - * @experimental + * Generated by gapic-generator-php from the file + * https://github.com/googleapis/googleapis/blob/master/google/logging/v2/logging_metrics.proto + * Updates to the above are reflected here through a refresh process. */ namespace Google\Cloud\Logging\V2\Gapic; @@ -29,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; + use Google\ApiCore\PathTemplate; use Google\ApiCore\RequestParamsHeaderDescriptor; use Google\ApiCore\RetrySettings; @@ -54,33 +53,17 @@ * $metricsServiceV2Client = new MetricsServiceV2Client(); * try { * $formattedParent = $metricsServiceV2Client->projectName('[PROJECT]'); - * // Iterate over pages of elements - * $pagedResponse = $metricsServiceV2Client->listLogMetrics($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * - * - * // Alternatively: - * - * // Iterate through all elements - * $pagedResponse = $metricsServiceV2Client->listLogMetrics($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } + * $metric = new LogMetric(); + * $response = $metricsServiceV2Client->createLogMetric($formattedParent, $metric); * } finally { * $metricsServiceV2Client->close(); * } * ``` * - * Many parameters require resource names to be formatted in a particular way. To assist - * with these names, this class includes a format method for each type of name, and additionally - * a parseName method to extract the individual identifiers contained within formatted names - * that are returned by the API. - * - * @experimental + * Many parameters require resource names to be formatted in a particular way. To + * assist with these names, this class includes a format method for each type of + * name, and additionally a parseName method to extract the individual identifiers + * contained within formatted names that are returned by the API. */ class MetricsServiceV2GapicClient { @@ -116,71 +99,44 @@ class MetricsServiceV2GapicClient 'https://www.googleapis.com/auth/logging.read', 'https://www.googleapis.com/auth/logging.write', ]; - private static $billingNameTemplate; - private static $folderNameTemplate; - private static $metricNameTemplate; - private static $organizationNameTemplate; + + private static $logMetricNameTemplate; + private static $projectNameTemplate; + private static $pathTemplateMap; private static function getClientDefaults() { return [ 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS.':'.self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__.'/../resources/metrics_service_v2_client_config.json', - 'descriptorsConfigPath' => __DIR__.'/../resources/metrics_service_v2_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__.'/../resources/metrics_service_v2_grpc_config.json', + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/metrics_service_v2_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/metrics_service_v2_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/metrics_service_v2_grpc_config.json', 'credentialsConfig' => [ - 'scopes' => self::$serviceScopes, + 'defaultScopes' => self::$serviceScopes, ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => __DIR__.'/../resources/metrics_service_v2_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/metrics_service_v2_rest_client_config.php', ], ], ]; } - private static function getBillingNameTemplate() + private static function getLogMetricNameTemplate() { - if (null == self::$billingNameTemplate) { - self::$billingNameTemplate = new PathTemplate('billingAccounts/{billing_account}'); + if (self::$logMetricNameTemplate == null) { + self::$logMetricNameTemplate = new PathTemplate('projects/{project}/metrics/{metric}'); } - return self::$billingNameTemplate; - } - - private static function getFolderNameTemplate() - { - if (null == self::$folderNameTemplate) { - self::$folderNameTemplate = new PathTemplate('folders/{folder}'); - } - - return self::$folderNameTemplate; - } - - private static function getMetricNameTemplate() - { - if (null == self::$metricNameTemplate) { - self::$metricNameTemplate = new PathTemplate('projects/{project}/metrics/{metric}'); - } - - return self::$metricNameTemplate; - } - - private static function getOrganizationNameTemplate() - { - if (null == self::$organizationNameTemplate) { - self::$organizationNameTemplate = new PathTemplate('organizations/{organization}'); - } - - return self::$organizationNameTemplate; + return self::$logMetricNameTemplate; } private static function getProjectNameTemplate() { - if (null == self::$projectNameTemplate) { + if (self::$projectNameTemplate == null) { self::$projectNameTemplate = new PathTemplate('projects/{project}'); } @@ -189,12 +145,9 @@ private static function getProjectNameTemplate() private static function getPathTemplateMap() { - if (null == self::$pathTemplateMap) { + if (self::$pathTemplateMap == null) { self::$pathTemplateMap = [ - 'billing' => self::getBillingNameTemplate(), - 'folder' => self::getFolderNameTemplate(), - 'metric' => self::getMetricNameTemplate(), - 'organization' => self::getOrganizationNameTemplate(), + 'logMetric' => self::getLogMetricNameTemplate(), 'project' => self::getProjectNameTemplate(), ]; } @@ -203,79 +156,29 @@ private static function getPathTemplateMap() } /** - * Formats a string containing the fully-qualified path to represent - * a billing resource. - * - * @param string $billingAccount - * - * @return string The formatted billing resource. - * @experimental - */ - public static function billingName($billingAccount) - { - return self::getBillingNameTemplate()->render([ - 'billing_account' => $billingAccount, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent - * a folder resource. - * - * @param string $folder - * - * @return string The formatted folder resource. - * @experimental - */ - public static function folderName($folder) - { - return self::getFolderNameTemplate()->render([ - 'folder' => $folder, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent - * a metric resource. + * Formats a string containing the fully-qualified path to represent a log_metric + * resource. * * @param string $project * @param string $metric * - * @return string The formatted metric resource. - * @experimental + * @return string The formatted log_metric resource. */ - public static function metricName($project, $metric) + public static function logMetricName($project, $metric) { - return self::getMetricNameTemplate()->render([ + return self::getLogMetricNameTemplate()->render([ 'project' => $project, 'metric' => $metric, ]); } /** - * Formats a string containing the fully-qualified path to represent - * a organization resource. - * - * @param string $organization - * - * @return string The formatted organization resource. - * @experimental - */ - public static function organizationName($organization) - { - return self::getOrganizationNameTemplate()->render([ - 'organization' => $organization, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent - * a project resource. + * Formats a string containing the fully-qualified path to represent a project + * resource. * * @param string $project * * @return string The formatted project resource. - * @experimental */ public static function projectName($project) { @@ -288,16 +191,14 @@ public static function projectName($project) * Parses a formatted name string and returns an associative array of the components in the name. * The following name formats are supported: * Template: Pattern - * - billing: billingAccounts/{billing_account} - * - folder: folders/{folder} - * - metric: projects/{project}/metrics/{metric} - * - organization: organizations/{organization} - * - project: projects/{project}. + * - logMetric: projects/{project}/metrics/{metric} + * - project: projects/{project} * - * The optional $template argument can be supplied to specify a particular pattern, and must - * match one of the templates listed above. If no $template argument is provided, or if the - * $template argument does not match one of the templates listed, then parseName will check - * each of the supported templates, and return the first match. + * The optional $template argument can be supplied to specify a particular pattern, + * and must match one of the templates listed above. If no $template argument is + * provided, or if the $template argument does not match one of the templates + * listed, then parseName will check each of the supported templates, and return + * the first match. * * @param string $formattedName The formatted name string * @param string $template Optional name of template to match @@ -305,12 +206,10 @@ public static function projectName($project) * @return array An associative array from name component IDs to component values. * * @throws ValidationException If $formattedName could not be matched. - * @experimental */ public static function parseName($formattedName, $template = null) { $templateMap = self::getPathTemplateMap(); - if ($template) { if (!isset($templateMap[$template])) { throw new ValidationException("Template name $template does not exist"); @@ -326,6 +225,7 @@ public static function parseName($formattedName, $template = null) // Swallow the exception to continue trying other path templates } } + throw new ValidationException("Input did not match any known format. Input: $formattedName"); } @@ -333,7 +233,7 @@ public static function parseName($formattedName, $template = null) * Constructor. * * @param array $options { - * Optional. Options for configuring the service API wrapper. + * Optional. Options for configuring the service API wrapper. * * @type string $serviceAddress * **Deprecated**. This option will be removed in a future major release. Please @@ -350,39 +250,41 @@ public static function parseName($formattedName, $template = null) * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these * objects are provided, any settings in $credentialsConfig will be ignored. * @type array $credentialsConfig - * Options used to configure credentials, including auth token caching, for the client. - * For a full list of supporting configuration options, see - * {@see \Google\ApiCore\CredentialsWrapper::build()}. + * Options used to configure credentials, including auth token caching, for the + * client. For a full list of supporting configuration options, see + * {@see \Google\ApiCore\CredentialsWrapper::build()} . * @type bool $disableRetries * Determines whether or not retries defined by the client configuration should be * disabled. Defaults to `false`. * @type string|array $clientConfig - * Client method configuration, including retry settings. This option can be either a - * path to a JSON file, or a PHP array containing the decoded JSON data. - * By default this settings points to the default client config file, which is provided - * in the resources folder. + * Client method configuration, including retry settings. This option can be either + * a path to a JSON file, or a PHP array containing the decoded JSON data. By + * default this settings points to the default client config file, which is + * provided in the resources folder. * @type string|TransportInterface $transport - * The transport used for executing network requests. May be either the string `rest` - * or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. - * *Advanced usage*: Additionally, it is possible to pass in an already instantiated - * {@see \Google\ApiCore\Transport\TransportInterface} object. Note that when this - * object is provided, any settings in $transportConfig, and any `$apiEndpoint` - * setting, will be ignored. + * The transport used for executing network requests. May be either the string + * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. + * *Advanced usage*: Additionally, it is possible to pass in an already + * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note + * that when this object is provided, any settings in $transportConfig, and any + * $serviceAddress setting, will be ignored. * @type array $transportConfig * Configuration options that will be used to construct the transport. Options for * each supported transport type should be passed in a key for that transport. For * example: * $transportConfig = [ * 'grpc' => [...], - * 'rest' => [...] + * 'rest' => [...], * ]; * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the * supported options. + * @type callable $clientCertSource + * A callable which returns the client cert as a string. This can be used to + * provide a certificate and private key to the transport layer for mTLS. * } * * @throws ValidationException - * @experimental */ public function __construct(array $options = []) { @@ -391,303 +293,252 @@ public function __construct(array $options = []) } /** - * Lists logs-based metrics. + * Creates a logs-based metric. * * Sample code: * ``` * $metricsServiceV2Client = new MetricsServiceV2Client(); * try { * $formattedParent = $metricsServiceV2Client->projectName('[PROJECT]'); - * // Iterate over pages of elements - * $pagedResponse = $metricsServiceV2Client->listLogMetrics($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * - * - * // Alternatively: - * - * // Iterate through all elements - * $pagedResponse = $metricsServiceV2Client->listLogMetrics($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } + * $metric = new LogMetric(); + * $response = $metricsServiceV2Client->createLogMetric($formattedParent, $metric); * } finally { * $metricsServiceV2Client->close(); * } * ``` * - * @param string $parent Required. The name of the project containing the metrics: + * @param string $parent Required. The resource name of the project in which to create the metric: * - * "projects/[PROJECT_ID]" - * @param array $optionalArgs { - * Optional. + * "projects/[PROJECT_ID]" + * + * The new metric must be provided in the request. + * @param LogMetric $metric Required. The new logs-based metric, which must not have an identifier that + * already exists. + * @param array $optionalArgs { + * Optional. * - * @type string $pageToken - * A page token is used to specify a page of values to be returned. - * If no page token is specified (the default), the first page - * of values will be returned. Any page token used here must have - * been generated by a previous call to the API. - * @type int $pageSize - * The maximum number of resources contained in the underlying API - * response. The API may return fewer values in a page, even if - * there are additional values to be retrieved. * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\ApiCore\PagedListResponse + * @return \Google\Cloud\Logging\V2\LogMetric * * @throws ApiException if the remote call fails - * @experimental */ - public function listLogMetrics($parent, array $optionalArgs = []) + public function createLogMetric($parent, $metric, array $optionalArgs = []) { - $request = new ListLogMetricsRequest(); + $request = new CreateLogMetricRequest(); + $requestParamHeaders = []; $request->setParent($parent); - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - $requestParams = new RequestParamsHeaderDescriptor([ - 'parent' => $request->getParent(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->getPagedListResponse( - 'ListLogMetrics', - $optionalArgs, - ListLogMetricsResponse::class, - $request - ); + $request->setMetric($metric); + $requestParamHeaders['parent'] = $parent; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('CreateLogMetric', LogMetric::class, $optionalArgs, $request)->wait(); } /** - * Gets a logs-based metric. + * Deletes a logs-based metric. * * Sample code: * ``` * $metricsServiceV2Client = new MetricsServiceV2Client(); * try { - * $formattedMetricName = $metricsServiceV2Client->metricName('[PROJECT]', '[METRIC]'); - * $response = $metricsServiceV2Client->getLogMetric($formattedMetricName); + * $formattedMetricName = $metricsServiceV2Client->logMetricName('[PROJECT]', '[METRIC]'); + * $metricsServiceV2Client->deleteLogMetric($formattedMetricName); * } finally { * $metricsServiceV2Client->close(); * } * ``` * - * @param string $metricName Required. The resource name of the desired metric: + * @param string $metricName Required. The resource name of the metric to delete: * - * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" - * @param array $optionalArgs { - * Optional. + * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" + * @param array $optionalArgs { + * Optional. * * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Logging\V2\LogMetric - * * @throws ApiException if the remote call fails - * @experimental */ - public function getLogMetric($metricName, array $optionalArgs = []) + public function deleteLogMetric($metricName, array $optionalArgs = []) { - $request = new GetLogMetricRequest(); + $request = new DeleteLogMetricRequest(); + $requestParamHeaders = []; $request->setMetricName($metricName); - - $requestParams = new RequestParamsHeaderDescriptor([ - 'metric_name' => $request->getMetricName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'GetLogMetric', - LogMetric::class, - $optionalArgs, - $request - )->wait(); + $requestParamHeaders['metric_name'] = $metricName; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('DeleteLogMetric', GPBEmpty::class, $optionalArgs, $request)->wait(); } /** - * Creates a logs-based metric. + * Gets a logs-based metric. * * Sample code: * ``` * $metricsServiceV2Client = new MetricsServiceV2Client(); * try { - * $formattedParent = $metricsServiceV2Client->projectName('[PROJECT]'); - * $metric = new LogMetric(); - * $response = $metricsServiceV2Client->createLogMetric($formattedParent, $metric); + * $formattedMetricName = $metricsServiceV2Client->logMetricName('[PROJECT]', '[METRIC]'); + * $response = $metricsServiceV2Client->getLogMetric($formattedMetricName); * } finally { * $metricsServiceV2Client->close(); * } * ``` * - * @param string $parent Required. The resource name of the project in which to create the metric: - * - * "projects/[PROJECT_ID]" + * @param string $metricName Required. The resource name of the desired metric: * - * The new metric must be provided in the request. - * @param LogMetric $metric Required. The new logs-based metric, which must not have an identifier that - * already exists. - * @param array $optionalArgs { - * Optional. + * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" + * @param array $optionalArgs { + * Optional. * * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * * @return \Google\Cloud\Logging\V2\LogMetric * * @throws ApiException if the remote call fails - * @experimental */ - public function createLogMetric($parent, $metric, array $optionalArgs = []) + public function getLogMetric($metricName, array $optionalArgs = []) { - $request = new CreateLogMetricRequest(); - $request->setParent($parent); - $request->setMetric($metric); - - $requestParams = new RequestParamsHeaderDescriptor([ - 'parent' => $request->getParent(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'CreateLogMetric', - LogMetric::class, - $optionalArgs, - $request - )->wait(); + $request = new GetLogMetricRequest(); + $requestParamHeaders = []; + $request->setMetricName($metricName); + $requestParamHeaders['metric_name'] = $metricName; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetLogMetric', LogMetric::class, $optionalArgs, $request)->wait(); } /** - * Creates or updates a logs-based metric. + * Lists logs-based metrics. * * Sample code: * ``` * $metricsServiceV2Client = new MetricsServiceV2Client(); * try { - * $formattedMetricName = $metricsServiceV2Client->metricName('[PROJECT]', '[METRIC]'); - * $metric = new LogMetric(); - * $response = $metricsServiceV2Client->updateLogMetric($formattedMetricName, $metric); + * $formattedParent = $metricsServiceV2Client->projectName('[PROJECT]'); + * // Iterate over pages of elements + * $pagedResponse = $metricsServiceV2Client->listLogMetrics($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $metricsServiceV2Client->listLogMetrics($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } * } finally { * $metricsServiceV2Client->close(); * } * ``` * - * @param string $metricName Required. The resource name of the metric to update: + * @param string $parent Required. The name of the project containing the metrics: * - * "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 LogMetric $metric Required. The updated metric. - * @param array $optionalArgs { - * Optional. + * "projects/[PROJECT_ID]" + * @param array $optionalArgs { + * Optional. * + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Logging\V2\LogMetric + * @return \Google\ApiCore\PagedListResponse * * @throws ApiException if the remote call fails - * @experimental */ - public function updateLogMetric($metricName, $metric, array $optionalArgs = []) + public function listLogMetrics($parent, array $optionalArgs = []) { - $request = new UpdateLogMetricRequest(); - $request->setMetricName($metricName); - $request->setMetric($metric); + $request = new ListLogMetricsRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } - $requestParams = new RequestParamsHeaderDescriptor([ - 'metric_name' => $request->getMetricName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'UpdateLogMetric', - LogMetric::class, - $optionalArgs, - $request - )->wait(); + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListLogMetrics', $optionalArgs, ListLogMetricsResponse::class, $request); } /** - * Deletes a logs-based metric. + * Creates or updates a logs-based metric. * * Sample code: * ``` * $metricsServiceV2Client = new MetricsServiceV2Client(); * try { - * $formattedMetricName = $metricsServiceV2Client->metricName('[PROJECT]', '[METRIC]'); - * $metricsServiceV2Client->deleteLogMetric($formattedMetricName); + * $formattedMetricName = $metricsServiceV2Client->logMetricName('[PROJECT]', '[METRIC]'); + * $metric = new LogMetric(); + * $response = $metricsServiceV2Client->updateLogMetric($formattedMetricName, $metric); * } finally { * $metricsServiceV2Client->close(); * } * ``` * - * @param string $metricName Required. The resource name of the metric to delete: + * @param string $metricName Required. The resource name of the metric to update: + * + * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" * - * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" - * @param array $optionalArgs { - * Optional. + * 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 LogMetric $metric Required. The updated metric. + * @param array $optionalArgs { + * Optional. * * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * + * @return \Google\Cloud\Logging\V2\LogMetric + * * @throws ApiException if the remote call fails - * @experimental */ - public function deleteLogMetric($metricName, array $optionalArgs = []) + public function updateLogMetric($metricName, $metric, array $optionalArgs = []) { - $request = new DeleteLogMetricRequest(); + $request = new UpdateLogMetricRequest(); + $requestParamHeaders = []; $request->setMetricName($metricName); - - $requestParams = new RequestParamsHeaderDescriptor([ - 'metric_name' => $request->getMetricName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'DeleteLogMetric', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); + $request->setMetric($metric); + $requestParamHeaders['metric_name'] = $metricName; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('UpdateLogMetric', LogMetric::class, $optionalArgs, $request)->wait(); } } diff --git a/Logging/src/V2/GetBucketRequest.php b/Logging/src/V2/GetBucketRequest.php new file mode 100644 index 000000000000..09ec57bec771 --- /dev/null +++ b/Logging/src/V2/GetBucketRequest.php @@ -0,0 +1,91 @@ +google.logging.v2.GetBucketRequest + */ +class GetBucketRequest extends \Google\Protobuf\Internal\Message +{ + /** + * 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"`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $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"`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Logging\V2\LoggingConfig::initOnce(); + parent::__construct($data); + } + + /** + * 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"`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->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"`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/Logging/src/V2/GetCmekSettingsRequest.php b/Logging/src/V2/GetCmekSettingsRequest.php index 43df5408c953..fdbc361632fc 100644 --- a/Logging/src/V2/GetCmekSettingsRequest.php +++ b/Logging/src/V2/GetCmekSettingsRequest.php @@ -11,8 +11,9 @@ /** * The parameters to * [GetCmekSettings][google.logging.v2.ConfigServiceV2.GetCmekSettings]. - * See [Enabling CMEK for Logs Router](/logging/docs/routing/managed-encryption) - * for more information. + * See [Enabling CMEK for Logs + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) for + * more information. * * Generated from protobuf message google.logging.v2.GetCmekSettingsRequest */ @@ -29,7 +30,7 @@ class GetCmekSettingsRequest extends \Google\Protobuf\Internal\Message * organizations. Once configured, it applies to all projects and folders in * the GCP organization. * - * Generated from protobuf field string name = 1; + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ private $name = ''; @@ -67,7 +68,7 @@ public function __construct($data = NULL) { * organizations. Once configured, it applies to all projects and folders in * the GCP organization. * - * Generated from protobuf field string name = 1; + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @return string */ public function getName() @@ -86,7 +87,7 @@ public function getName() * organizations. Once configured, it applies to all projects and folders in * the GCP organization. * - * Generated from protobuf field string name = 1; + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @param string $var * @return $this */ diff --git a/Logging/src/V2/GetViewRequest.php b/Logging/src/V2/GetViewRequest.php new file mode 100644 index 000000000000..3fbf4bb0d2f4 --- /dev/null +++ b/Logging/src/V2/GetViewRequest.php @@ -0,0 +1,79 @@ +google.logging.v2.GetViewRequest + */ +class GetViewRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The resource name of the policy: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * Example: + * `"projects/my-project-id/locations/my-location/buckets/my-bucket-id/views/my-view-id"`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The resource name of the policy: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * Example: + * `"projects/my-project-id/locations/my-location/buckets/my-bucket-id/views/my-view-id"`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Logging\V2\LoggingConfig::initOnce(); + parent::__construct($data); + } + + /** + * Required. The resource name of the policy: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * Example: + * `"projects/my-project-id/locations/my-location/buckets/my-bucket-id/views/my-view-id"`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. The resource name of the policy: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * Example: + * `"projects/my-project-id/locations/my-location/buckets/my-bucket-id/views/my-view-id"`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/Logging/src/V2/LifecycleState.php b/Logging/src/V2/LifecycleState.php new file mode 100644 index 000000000000..b54a0613c279 --- /dev/null +++ b/Logging/src/V2/LifecycleState.php @@ -0,0 +1,62 @@ +google.logging.v2.LifecycleState + */ +class LifecycleState +{ + /** + * Unspecified state. This is only used/useful for distinguishing + * unset values. + * + * Generated from protobuf enum LIFECYCLE_STATE_UNSPECIFIED = 0; + */ + const LIFECYCLE_STATE_UNSPECIFIED = 0; + /** + * The normal and active state. + * + * Generated from protobuf enum ACTIVE = 1; + */ + const ACTIVE = 1; + /** + * The bucket has been marked for deletion by the user. + * + * Generated from protobuf enum DELETE_REQUESTED = 2; + */ + const DELETE_REQUESTED = 2; + + private static $valueToName = [ + self::LIFECYCLE_STATE_UNSPECIFIED => 'LIFECYCLE_STATE_UNSPECIFIED', + self::ACTIVE => 'ACTIVE', + self::DELETE_REQUESTED => 'DELETE_REQUESTED', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + diff --git a/Logging/src/V2/ListBucketsRequest.php b/Logging/src/V2/ListBucketsRequest.php new file mode 100644 index 000000000000..4d630f156c7a --- /dev/null +++ b/Logging/src/V2/ListBucketsRequest.php @@ -0,0 +1,183 @@ +google.logging.v2.ListBucketsRequest + */ +class ListBucketsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * 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. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * 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. + * + * Generated from protobuf field string page_token = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_token = ''; + /** + * 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. + * + * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_size = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $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. + * @type string $page_token + * 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. + * @type int $page_size + * 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. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Logging\V2\LoggingConfig::initOnce(); + parent::__construct($data); + } + + /** + * 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. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->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. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * 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. + * + * Generated from protobuf field string page_token = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * 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. + * + * Generated from protobuf field string page_token = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + + /** + * 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. + * + * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * 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. + * + * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + +} + diff --git a/Logging/src/V2/ListBucketsResponse.php b/Logging/src/V2/ListBucketsResponse.php new file mode 100644 index 000000000000..ea52264b10d6 --- /dev/null +++ b/Logging/src/V2/ListBucketsResponse.php @@ -0,0 +1,109 @@ +google.logging.v2.ListBucketsResponse + */ +class ListBucketsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * A list of buckets. + * + * Generated from protobuf field repeated .google.logging.v2.LogBucket buckets = 1; + */ + private $buckets; + /** + * 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`. + * + * Generated from protobuf field string next_page_token = 2; + */ + private $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Logging\V2\LogBucket[]|\Google\Protobuf\Internal\RepeatedField $buckets + * A list of buckets. + * @type string $next_page_token + * 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`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Logging\V2\LoggingConfig::initOnce(); + parent::__construct($data); + } + + /** + * A list of buckets. + * + * Generated from protobuf field repeated .google.logging.v2.LogBucket buckets = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getBuckets() + { + return $this->buckets; + } + + /** + * A list of buckets. + * + * Generated from protobuf field repeated .google.logging.v2.LogBucket buckets = 1; + * @param \Google\Cloud\Logging\V2\LogBucket[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setBuckets($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Logging\V2\LogBucket::class); + $this->buckets = $arr; + + return $this; + } + + /** + * 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`. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * 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`. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/Logging/src/V2/ListExclusionsRequest.php b/Logging/src/V2/ListExclusionsRequest.php index 7277d1c1ddfd..cf06d9d3cb97 100644 --- a/Logging/src/V2/ListExclusionsRequest.php +++ b/Logging/src/V2/ListExclusionsRequest.php @@ -31,7 +31,7 @@ class ListExclusionsRequest extends \Google\Protobuf\Internal\Message * `nextPageToken` from the previous response. The values of other method * parameters should be identical to those in the previous call. * - * Generated from protobuf field string page_token = 2; + * Generated from protobuf field string page_token = 2 [(.google.api.field_behavior) = OPTIONAL]; */ private $page_token = ''; /** @@ -39,7 +39,7 @@ class ListExclusionsRequest extends \Google\Protobuf\Internal\Message * Non-positive values are ignored. The presence of `nextPageToken` in the * response indicates that more results might be available. * - * Generated from protobuf field int32 page_size = 3; + * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; */ private $page_size = 0; @@ -111,7 +111,7 @@ public function setParent($var) * `nextPageToken` from the previous response. The values of other method * parameters should be identical to those in the previous call. * - * Generated from protobuf field string page_token = 2; + * Generated from protobuf field string page_token = 2 [(.google.api.field_behavior) = OPTIONAL]; * @return string */ public function getPageToken() @@ -125,7 +125,7 @@ public function getPageToken() * `nextPageToken` from the previous response. The values of other method * parameters should be identical to those in the previous call. * - * Generated from protobuf field string page_token = 2; + * Generated from protobuf field string page_token = 2 [(.google.api.field_behavior) = OPTIONAL]; * @param string $var * @return $this */ @@ -142,7 +142,7 @@ public function setPageToken($var) * Non-positive values are ignored. The presence of `nextPageToken` in the * response indicates that more results might be available. * - * Generated from protobuf field int32 page_size = 3; + * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; * @return int */ public function getPageSize() @@ -155,7 +155,7 @@ public function getPageSize() * Non-positive values are ignored. The presence of `nextPageToken` in the * response indicates that more results might be available. * - * Generated from protobuf field int32 page_size = 3; + * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; * @param int $var * @return $this */ diff --git a/Logging/src/V2/ListLogEntriesRequest.php b/Logging/src/V2/ListLogEntriesRequest.php index b566db110306..b7ea7f8b0d6a 100644 --- a/Logging/src/V2/ListLogEntriesRequest.php +++ b/Logging/src/V2/ListLogEntriesRequest.php @@ -15,14 +15,6 @@ */ class ListLogEntriesRequest extends \Google\Protobuf\Internal\Message { - /** - * Deprecated. Use `resource_names` instead. One or more project identifiers - * or project numbers from which to retrieve log entries. Example: - * `"my-project-1A"`. - * - * Generated from protobuf field repeated string project_ids = 1 [deprecated = true]; - */ - private $project_ids; /** * Required. Names of one or more parent resources from which to * retrieve log entries: @@ -30,6 +22,11 @@ class ListLogEntriesRequest extends \Google\Protobuf\Internal\Message * "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" * "folders/[FOLDER_ID]" + * May alternatively be one or more views + * projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] * Projects listed in the `project_ids` field are added to this list. * * Generated from protobuf field repeated string resource_names = 8 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -37,14 +34,14 @@ class ListLogEntriesRequest extends \Google\Protobuf\Internal\Message private $resource_names; /** * 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. + * Logs Queries](https://cloud.google.com/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. * - * Generated from protobuf field string filter = 2; + * Generated from protobuf field string filter = 2 [(.google.api.field_behavior) = OPTIONAL]; */ private $filter = ''; /** @@ -55,15 +52,16 @@ class ListLogEntriesRequest extends \Google\Protobuf\Internal\Message * in order of decreasing timestamps (newest first). Entries with equal * timestamps are returned in order of their `insert_id` values. * - * Generated from protobuf field string order_by = 3; + * Generated from protobuf field string order_by = 3 [(.google.api.field_behavior) = OPTIONAL]; */ private $order_by = ''; /** * Optional. The maximum number of results to return from this request. - * Non-positive values are ignored. The presence of `next_page_token` in the + * Default is 50. If the value is negative or exceeds 1000, + * the request is rejected. The presence of `next_page_token` in the * response indicates that more results might be available. * - * Generated from protobuf field int32 page_size = 4; + * Generated from protobuf field int32 page_size = 4 [(.google.api.field_behavior) = OPTIONAL]; */ private $page_size = 0; /** @@ -72,7 +70,7 @@ class ListLogEntriesRequest extends \Google\Protobuf\Internal\Message * `next_page_token` from the previous response. The values of other method * parameters should be identical to those in the previous call. * - * Generated from protobuf field string page_token = 5; + * Generated from protobuf field string page_token = 5 [(.google.api.field_behavior) = OPTIONAL]; */ private $page_token = ''; @@ -82,10 +80,6 @@ class ListLogEntriesRequest extends \Google\Protobuf\Internal\Message * @param array $data { * Optional. Data for populating the Message object. * - * @type string[]|\Google\Protobuf\Internal\RepeatedField $project_ids - * Deprecated. Use `resource_names` instead. One or more project identifiers - * or project numbers from which to retrieve log entries. Example: - * `"my-project-1A"`. * @type string[]|\Google\Protobuf\Internal\RepeatedField $resource_names * Required. Names of one or more parent resources from which to * retrieve log entries: @@ -93,15 +87,20 @@ class ListLogEntriesRequest extends \Google\Protobuf\Internal\Message * "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" * "folders/[FOLDER_ID]" + * May alternatively be one or more views + * projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] * Projects listed in the `project_ids` field are added to this list. * @type string $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. + * Logs Queries](https://cloud.google.com/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. * @type string $order_by * Optional. How the results should be sorted. Presently, the only permitted * values are `"timestamp asc"` (default) and `"timestamp desc"`. The first @@ -111,7 +110,8 @@ class ListLogEntriesRequest extends \Google\Protobuf\Internal\Message * timestamps are returned in order of their `insert_id` values. * @type int $page_size * Optional. The maximum number of results to return from this request. - * Non-positive values are ignored. The presence of `next_page_token` in the + * Default is 50. If the value is negative or exceeds 1000, + * the request is rejected. The presence of `next_page_token` in the * response indicates that more results might be available. * @type string $page_token * Optional. If present, then retrieve the next batch of results from the @@ -125,36 +125,6 @@ public function __construct($data = NULL) { parent::__construct($data); } - /** - * Deprecated. Use `resource_names` instead. One or more project identifiers - * or project numbers from which to retrieve log entries. Example: - * `"my-project-1A"`. - * - * Generated from protobuf field repeated string project_ids = 1 [deprecated = true]; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getProjectIds() - { - return $this->project_ids; - } - - /** - * Deprecated. Use `resource_names` instead. One or more project identifiers - * or project numbers from which to retrieve log entries. Example: - * `"my-project-1A"`. - * - * Generated from protobuf field repeated string project_ids = 1 [deprecated = true]; - * @param string[]|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setProjectIds($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); - $this->project_ids = $arr; - - return $this; - } - /** * Required. Names of one or more parent resources from which to * retrieve log entries: @@ -162,6 +132,11 @@ public function setProjectIds($var) * "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" * "folders/[FOLDER_ID]" + * May alternatively be one or more views + * projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] * Projects listed in the `project_ids` field are added to this list. * * Generated from protobuf field repeated string resource_names = 8 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -179,6 +154,11 @@ public function getResourceNames() * "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" * "folders/[FOLDER_ID]" + * May alternatively be one or more views + * projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] * Projects listed in the `project_ids` field are added to this list. * * Generated from protobuf field repeated string resource_names = 8 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -195,14 +175,14 @@ public function setResourceNames($var) /** * 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. + * Logs Queries](https://cloud.google.com/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. * - * Generated from protobuf field string filter = 2; + * Generated from protobuf field string filter = 2 [(.google.api.field_behavior) = OPTIONAL]; * @return string */ public function getFilter() @@ -212,14 +192,14 @@ public function getFilter() /** * 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. + * Logs Queries](https://cloud.google.com/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. * - * Generated from protobuf field string filter = 2; + * Generated from protobuf field string filter = 2 [(.google.api.field_behavior) = OPTIONAL]; * @param string $var * @return $this */ @@ -239,7 +219,7 @@ public function setFilter($var) * in order of decreasing timestamps (newest first). Entries with equal * timestamps are returned in order of their `insert_id` values. * - * Generated from protobuf field string order_by = 3; + * Generated from protobuf field string order_by = 3 [(.google.api.field_behavior) = OPTIONAL]; * @return string */ public function getOrderBy() @@ -255,7 +235,7 @@ public function getOrderBy() * in order of decreasing timestamps (newest first). Entries with equal * timestamps are returned in order of their `insert_id` values. * - * Generated from protobuf field string order_by = 3; + * Generated from protobuf field string order_by = 3 [(.google.api.field_behavior) = OPTIONAL]; * @param string $var * @return $this */ @@ -269,10 +249,11 @@ public function setOrderBy($var) /** * Optional. The maximum number of results to return from this request. - * Non-positive values are ignored. The presence of `next_page_token` in the + * Default is 50. If the value is negative or exceeds 1000, + * the request is rejected. The presence of `next_page_token` in the * response indicates that more results might be available. * - * Generated from protobuf field int32 page_size = 4; + * Generated from protobuf field int32 page_size = 4 [(.google.api.field_behavior) = OPTIONAL]; * @return int */ public function getPageSize() @@ -282,10 +263,11 @@ public function getPageSize() /** * Optional. The maximum number of results to return from this request. - * Non-positive values are ignored. The presence of `next_page_token` in the + * Default is 50. If the value is negative or exceeds 1000, + * the request is rejected. The presence of `next_page_token` in the * response indicates that more results might be available. * - * Generated from protobuf field int32 page_size = 4; + * Generated from protobuf field int32 page_size = 4 [(.google.api.field_behavior) = OPTIONAL]; * @param int $var * @return $this */ @@ -303,7 +285,7 @@ public function setPageSize($var) * `next_page_token` from the previous response. The values of other method * parameters should be identical to those in the previous call. * - * Generated from protobuf field string page_token = 5; + * Generated from protobuf field string page_token = 5 [(.google.api.field_behavior) = OPTIONAL]; * @return string */ public function getPageToken() @@ -317,7 +299,7 @@ public function getPageToken() * `next_page_token` from the previous response. The values of other method * parameters should be identical to those in the previous call. * - * Generated from protobuf field string page_token = 5; + * Generated from protobuf field string page_token = 5 [(.google.api.field_behavior) = OPTIONAL]; * @param string $var * @return $this */ diff --git a/Logging/src/V2/ListLogMetricsRequest.php b/Logging/src/V2/ListLogMetricsRequest.php index 84f090e97036..b6d3b8b8986d 100644 --- a/Logging/src/V2/ListLogMetricsRequest.php +++ b/Logging/src/V2/ListLogMetricsRequest.php @@ -28,7 +28,7 @@ class ListLogMetricsRequest extends \Google\Protobuf\Internal\Message * `nextPageToken` from the previous response. The values of other method * parameters should be identical to those in the previous call. * - * Generated from protobuf field string page_token = 2; + * Generated from protobuf field string page_token = 2 [(.google.api.field_behavior) = OPTIONAL]; */ private $page_token = ''; /** @@ -36,7 +36,7 @@ class ListLogMetricsRequest extends \Google\Protobuf\Internal\Message * Non-positive values are ignored. The presence of `nextPageToken` in the * response indicates that more results might be available. * - * Generated from protobuf field int32 page_size = 3; + * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; */ private $page_size = 0; @@ -99,7 +99,7 @@ public function setParent($var) * `nextPageToken` from the previous response. The values of other method * parameters should be identical to those in the previous call. * - * Generated from protobuf field string page_token = 2; + * Generated from protobuf field string page_token = 2 [(.google.api.field_behavior) = OPTIONAL]; * @return string */ public function getPageToken() @@ -113,7 +113,7 @@ public function getPageToken() * `nextPageToken` from the previous response. The values of other method * parameters should be identical to those in the previous call. * - * Generated from protobuf field string page_token = 2; + * Generated from protobuf field string page_token = 2 [(.google.api.field_behavior) = OPTIONAL]; * @param string $var * @return $this */ @@ -130,7 +130,7 @@ public function setPageToken($var) * Non-positive values are ignored. The presence of `nextPageToken` in the * response indicates that more results might be available. * - * Generated from protobuf field int32 page_size = 3; + * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; * @return int */ public function getPageSize() @@ -143,7 +143,7 @@ public function getPageSize() * Non-positive values are ignored. The presence of `nextPageToken` in the * response indicates that more results might be available. * - * Generated from protobuf field int32 page_size = 3; + * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; * @param int $var * @return $this */ diff --git a/Logging/src/V2/ListLogsRequest.php b/Logging/src/V2/ListLogsRequest.php index c6b85ec05da3..228c28f9f0c1 100644 --- a/Logging/src/V2/ListLogsRequest.php +++ b/Logging/src/V2/ListLogsRequest.php @@ -22,7 +22,7 @@ class ListLogsRequest extends \Google\Protobuf\Internal\Message * "billingAccounts/[BILLING_ACCOUNT_ID]" * "folders/[FOLDER_ID]" * - * Generated from protobuf field string parent = 1 [(.google.api.resource_reference) = { + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ private $parent = ''; /** @@ -30,7 +30,7 @@ class ListLogsRequest extends \Google\Protobuf\Internal\Message * Non-positive values are ignored. The presence of `nextPageToken` in the * response indicates that more results might be available. * - * Generated from protobuf field int32 page_size = 2; + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; */ private $page_size = 0; /** @@ -39,9 +39,24 @@ class ListLogsRequest extends \Google\Protobuf\Internal\Message * `nextPageToken` from the previous response. The values of other method * parameters should be identical to those in the previous call. * - * Generated from protobuf field string page_token = 3; + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; */ private $page_token = ''; + /** + * Optional. The resource name that owns the logs: + * projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * To support legacy queries, it could also be: + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * + * Generated from protobuf field repeated string resource_names = 8 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $resource_names; /** * Constructor. @@ -64,6 +79,17 @@ class ListLogsRequest extends \Google\Protobuf\Internal\Message * 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. + * @type string[]|\Google\Protobuf\Internal\RepeatedField $resource_names + * Optional. The resource name that owns the logs: + * projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * To support legacy queries, it could also be: + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" * } */ public function __construct($data = NULL) { @@ -78,7 +104,7 @@ public function __construct($data = NULL) { * "billingAccounts/[BILLING_ACCOUNT_ID]" * "folders/[FOLDER_ID]" * - * Generated from protobuf field string parent = 1 [(.google.api.resource_reference) = { + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @return string */ public function getParent() @@ -93,7 +119,7 @@ public function getParent() * "billingAccounts/[BILLING_ACCOUNT_ID]" * "folders/[FOLDER_ID]" * - * Generated from protobuf field string parent = 1 [(.google.api.resource_reference) = { + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @param string $var * @return $this */ @@ -110,7 +136,7 @@ public function setParent($var) * Non-positive values are ignored. The presence of `nextPageToken` in the * response indicates that more results might be available. * - * Generated from protobuf field int32 page_size = 2; + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; * @return int */ public function getPageSize() @@ -123,7 +149,7 @@ public function getPageSize() * Non-positive values are ignored. The presence of `nextPageToken` in the * response indicates that more results might be available. * - * Generated from protobuf field int32 page_size = 2; + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; * @param int $var * @return $this */ @@ -141,7 +167,7 @@ public function setPageSize($var) * `nextPageToken` from the previous response. The values of other method * parameters should be identical to those in the previous call. * - * Generated from protobuf field string page_token = 3; + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; * @return string */ public function getPageToken() @@ -155,7 +181,7 @@ public function getPageToken() * `nextPageToken` from the previous response. The values of other method * parameters should be identical to those in the previous call. * - * Generated from protobuf field string page_token = 3; + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; * @param string $var * @return $this */ @@ -167,5 +193,49 @@ public function setPageToken($var) return $this; } + /** + * Optional. The resource name that owns the logs: + * projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * To support legacy queries, it could also be: + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * + * Generated from protobuf field repeated string resource_names = 8 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getResourceNames() + { + return $this->resource_names; + } + + /** + * Optional. The resource name that owns the logs: + * projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * To support legacy queries, it could also be: + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * + * Generated from protobuf field repeated string resource_names = 8 [(.google.api.field_behavior) = OPTIONAL]; + * @param string[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setResourceNames($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->resource_names = $arr; + + return $this; + } + } diff --git a/Logging/src/V2/ListMonitoredResourceDescriptorsRequest.php b/Logging/src/V2/ListMonitoredResourceDescriptorsRequest.php index 58fd0a9c4b44..d40096508418 100644 --- a/Logging/src/V2/ListMonitoredResourceDescriptorsRequest.php +++ b/Logging/src/V2/ListMonitoredResourceDescriptorsRequest.php @@ -20,7 +20,7 @@ class ListMonitoredResourceDescriptorsRequest extends \Google\Protobuf\Internal\ * Non-positive values are ignored. The presence of `nextPageToken` in the * response indicates that more results might be available. * - * Generated from protobuf field int32 page_size = 1; + * Generated from protobuf field int32 page_size = 1 [(.google.api.field_behavior) = OPTIONAL]; */ private $page_size = 0; /** @@ -29,7 +29,7 @@ class ListMonitoredResourceDescriptorsRequest extends \Google\Protobuf\Internal\ * `nextPageToken` from the previous response. The values of other method * parameters should be identical to those in the previous call. * - * Generated from protobuf field string page_token = 2; + * Generated from protobuf field string page_token = 2 [(.google.api.field_behavior) = OPTIONAL]; */ private $page_token = ''; @@ -60,7 +60,7 @@ public function __construct($data = NULL) { * Non-positive values are ignored. The presence of `nextPageToken` in the * response indicates that more results might be available. * - * Generated from protobuf field int32 page_size = 1; + * Generated from protobuf field int32 page_size = 1 [(.google.api.field_behavior) = OPTIONAL]; * @return int */ public function getPageSize() @@ -73,7 +73,7 @@ public function getPageSize() * Non-positive values are ignored. The presence of `nextPageToken` in the * response indicates that more results might be available. * - * Generated from protobuf field int32 page_size = 1; + * Generated from protobuf field int32 page_size = 1 [(.google.api.field_behavior) = OPTIONAL]; * @param int $var * @return $this */ @@ -91,7 +91,7 @@ public function setPageSize($var) * `nextPageToken` from the previous response. The values of other method * parameters should be identical to those in the previous call. * - * Generated from protobuf field string page_token = 2; + * Generated from protobuf field string page_token = 2 [(.google.api.field_behavior) = OPTIONAL]; * @return string */ public function getPageToken() @@ -105,7 +105,7 @@ public function getPageToken() * `nextPageToken` from the previous response. The values of other method * parameters should be identical to those in the previous call. * - * Generated from protobuf field string page_token = 2; + * Generated from protobuf field string page_token = 2 [(.google.api.field_behavior) = OPTIONAL]; * @param string $var * @return $this */ diff --git a/Logging/src/V2/ListSinksRequest.php b/Logging/src/V2/ListSinksRequest.php index eb1f3f346734..efbf1a2763fd 100644 --- a/Logging/src/V2/ListSinksRequest.php +++ b/Logging/src/V2/ListSinksRequest.php @@ -31,7 +31,7 @@ class ListSinksRequest extends \Google\Protobuf\Internal\Message * `nextPageToken` from the previous response. The values of other method * parameters should be identical to those in the previous call. * - * Generated from protobuf field string page_token = 2; + * Generated from protobuf field string page_token = 2 [(.google.api.field_behavior) = OPTIONAL]; */ private $page_token = ''; /** @@ -39,7 +39,7 @@ class ListSinksRequest extends \Google\Protobuf\Internal\Message * Non-positive values are ignored. The presence of `nextPageToken` in the * response indicates that more results might be available. * - * Generated from protobuf field int32 page_size = 3; + * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; */ private $page_size = 0; @@ -111,7 +111,7 @@ public function setParent($var) * `nextPageToken` from the previous response. The values of other method * parameters should be identical to those in the previous call. * - * Generated from protobuf field string page_token = 2; + * Generated from protobuf field string page_token = 2 [(.google.api.field_behavior) = OPTIONAL]; * @return string */ public function getPageToken() @@ -125,7 +125,7 @@ public function getPageToken() * `nextPageToken` from the previous response. The values of other method * parameters should be identical to those in the previous call. * - * Generated from protobuf field string page_token = 2; + * Generated from protobuf field string page_token = 2 [(.google.api.field_behavior) = OPTIONAL]; * @param string $var * @return $this */ @@ -142,7 +142,7 @@ public function setPageToken($var) * Non-positive values are ignored. The presence of `nextPageToken` in the * response indicates that more results might be available. * - * Generated from protobuf field int32 page_size = 3; + * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; * @return int */ public function getPageSize() @@ -155,7 +155,7 @@ public function getPageSize() * Non-positive values are ignored. The presence of `nextPageToken` in the * response indicates that more results might be available. * - * Generated from protobuf field int32 page_size = 3; + * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; * @param int $var * @return $this */ diff --git a/Logging/src/V2/ListViewsRequest.php b/Logging/src/V2/ListViewsRequest.php new file mode 100644 index 000000000000..29c8050f18b4 --- /dev/null +++ b/Logging/src/V2/ListViewsRequest.php @@ -0,0 +1,159 @@ +google.logging.v2.ListViewsRequest + */ +class ListViewsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The bucket whose views are to be listed: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + private $parent = ''; + /** + * 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. + * + * Generated from protobuf field string page_token = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_token = ''; + /** + * 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. + * + * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_size = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The bucket whose views are to be listed: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * @type string $page_token + * 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. + * @type int $page_size + * 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. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Logging\V2\LoggingConfig::initOnce(); + parent::__construct($data); + } + + /** + * Required. The bucket whose views are to be listed: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The bucket whose views are to be listed: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * 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. + * + * Generated from protobuf field string page_token = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * 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. + * + * Generated from protobuf field string page_token = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + + /** + * 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. + * + * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * 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. + * + * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + +} + diff --git a/Logging/src/V2/ListViewsResponse.php b/Logging/src/V2/ListViewsResponse.php new file mode 100644 index 000000000000..0ec578b9ee4a --- /dev/null +++ b/Logging/src/V2/ListViewsResponse.php @@ -0,0 +1,109 @@ +google.logging.v2.ListViewsResponse + */ +class ListViewsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * A list of views. + * + * Generated from protobuf field repeated .google.logging.v2.LogView views = 1; + */ + private $views; + /** + * 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`. + * + * Generated from protobuf field string next_page_token = 2; + */ + private $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Logging\V2\LogView[]|\Google\Protobuf\Internal\RepeatedField $views + * A list of views. + * @type string $next_page_token + * 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`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Logging\V2\LoggingConfig::initOnce(); + parent::__construct($data); + } + + /** + * A list of views. + * + * Generated from protobuf field repeated .google.logging.v2.LogView views = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getViews() + { + return $this->views; + } + + /** + * A list of views. + * + * Generated from protobuf field repeated .google.logging.v2.LogView views = 1; + * @param \Google\Cloud\Logging\V2\LogView[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setViews($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Logging\V2\LogView::class); + $this->views = $arr; + + return $this; + } + + /** + * 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`. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * 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`. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/Logging/src/V2/LogBucket.php b/Logging/src/V2/LogBucket.php new file mode 100644 index 000000000000..eca2151b7261 --- /dev/null +++ b/Logging/src/V2/LogBucket.php @@ -0,0 +1,343 @@ +google.logging.v2.LogBucket + */ +class LogBucket extends \Google\Protobuf\Internal\Message +{ + /** + * The resource name of the bucket. + * For example: + * "projects/my-project-id/locations/my-location/buckets/my-bucket-id The + * supported locations are: + * "global" + * 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. + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + /** + * Describes this bucket. + * + * Generated from protobuf field string description = 3; + */ + private $description = ''; + /** + * Output only. The creation timestamp of the bucket. This is not set for any of the + * default buckets. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $create_time = null; + /** + * Output only. The last update timestamp of the bucket. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $update_time = null; + /** + * 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. + * + * Generated from protobuf field int32 retention_days = 11; + */ + private $retention_days = 0; + /** + * Whether the bucket has been locked. + * The retention period on a locked bucket may not be changed. + * Locked buckets may only be deleted if they are empty. + * + * Generated from protobuf field bool locked = 9; + */ + private $locked = false; + /** + * Output only. The bucket lifecycle state. + * + * Generated from protobuf field .google.logging.v2.LifecycleState lifecycle_state = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $lifecycle_state = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * The resource name of the bucket. + * For example: + * "projects/my-project-id/locations/my-location/buckets/my-bucket-id The + * supported locations are: + * "global" + * 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. + * @type string $description + * Describes this bucket. + * @type \Google\Protobuf\Timestamp $create_time + * Output only. The creation timestamp of the bucket. This is not set for any of the + * default buckets. + * @type \Google\Protobuf\Timestamp $update_time + * Output only. The last update timestamp of the bucket. + * @type int $retention_days + * 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. + * @type bool $locked + * Whether the bucket has been locked. + * The retention period on a locked bucket may not be changed. + * Locked buckets may only be deleted if they are empty. + * @type int $lifecycle_state + * Output only. The bucket lifecycle state. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Logging\V2\LoggingConfig::initOnce(); + parent::__construct($data); + } + + /** + * The resource name of the bucket. + * For example: + * "projects/my-project-id/locations/my-location/buckets/my-bucket-id The + * supported locations are: + * "global" + * 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. + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * The resource name of the bucket. + * For example: + * "projects/my-project-id/locations/my-location/buckets/my-bucket-id The + * supported locations are: + * "global" + * 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. + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Describes this bucket. + * + * Generated from protobuf field string description = 3; + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Describes this bucket. + * + * Generated from protobuf field string description = 3; + * @param string $var + * @return $this + */ + public function setDescription($var) + { + GPBUtil::checkString($var, True); + $this->description = $var; + + return $this; + } + + /** + * Output only. The creation timestamp of the bucket. This is not set for any of the + * default buckets. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCreateTime() + { + return $this->create_time; + } + + public function hasCreateTime() + { + return isset($this->create_time); + } + + public function clearCreateTime() + { + unset($this->create_time); + } + + /** + * Output only. The creation timestamp of the bucket. This is not set for any of the + * default buckets. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Output only. The last update timestamp of the bucket. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getUpdateTime() + { + return $this->update_time; + } + + public function hasUpdateTime() + { + return isset($this->update_time); + } + + public function clearUpdateTime() + { + unset($this->update_time); + } + + /** + * Output only. The last update timestamp of the bucket. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setUpdateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->update_time = $var; + + return $this; + } + + /** + * 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. + * + * Generated from protobuf field int32 retention_days = 11; + * @return int + */ + public function getRetentionDays() + { + return $this->retention_days; + } + + /** + * 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. + * + * Generated from protobuf field int32 retention_days = 11; + * @param int $var + * @return $this + */ + public function setRetentionDays($var) + { + GPBUtil::checkInt32($var); + $this->retention_days = $var; + + return $this; + } + + /** + * Whether the bucket has been locked. + * The retention period on a locked bucket may not be changed. + * Locked buckets may only be deleted if they are empty. + * + * Generated from protobuf field bool locked = 9; + * @return bool + */ + public function getLocked() + { + return $this->locked; + } + + /** + * Whether the bucket has been locked. + * The retention period on a locked bucket may not be changed. + * Locked buckets may only be deleted if they are empty. + * + * Generated from protobuf field bool locked = 9; + * @param bool $var + * @return $this + */ + public function setLocked($var) + { + GPBUtil::checkBool($var); + $this->locked = $var; + + return $this; + } + + /** + * Output only. The bucket lifecycle state. + * + * Generated from protobuf field .google.logging.v2.LifecycleState lifecycle_state = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getLifecycleState() + { + return $this->lifecycle_state; + } + + /** + * Output only. The bucket lifecycle state. + * + * Generated from protobuf field .google.logging.v2.LifecycleState lifecycle_state = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setLifecycleState($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Logging\V2\LifecycleState::class); + $this->lifecycle_state = $var; + + return $this; + } + +} + diff --git a/Logging/src/V2/LogEntry.php b/Logging/src/V2/LogEntry.php index 2c43c42b7da0..112db3475b23 100644 --- a/Logging/src/V2/LogEntry.php +++ b/Logging/src/V2/LogEntry.php @@ -21,9 +21,9 @@ class LogEntry extends \Google\Protobuf\Internal\Message * "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" * "folders/[FOLDER_ID]/logs/[LOG_ID]" - * A project number may optionally 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. + * 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 @@ -35,7 +35,7 @@ class LogEntry extends \Google\Protobuf\Internal\Message * slash and filtering for a log name with a leading slash will never return * any results. * - * Generated from protobuf field string log_name = 12; + * Generated from protobuf field string log_name = 12 [(.google.api.field_behavior) = REQUIRED]; */ private $log_name = ''; /** @@ -44,41 +44,39 @@ class LogEntry extends \Google\Protobuf\Internal\Message * the monitored resource designating the particular database that reported * the error. * - * Generated from protobuf field .google.api.MonitoredResource resource = 8; + * Generated from protobuf field .google.api.MonitoredResource resource = 8 [(.google.api.field_behavior) = REQUIRED]; */ private $resource = null; /** - * 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). + * 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 must have timestamps that don't exceed the + * [logs retention + * period](https://cloud.google.com/logging/quotas#logs_retention_periods) in + * the past, and that don't exceed 24 hours in the future. Log entries outside + * those time boundaries aren't ingested by Logging. * - * Generated from protobuf field .google.protobuf.Timestamp timestamp = 9; + * Generated from protobuf field .google.protobuf.Timestamp timestamp = 9 [(.google.api.field_behavior) = OPTIONAL]; */ private $timestamp = null; /** * Output only. The time the log entry was received by Logging. * - * Generated from protobuf field .google.protobuf.Timestamp receive_timestamp = 24; + * Generated from protobuf field .google.protobuf.Timestamp receive_timestamp = 24 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ private $receive_timestamp = null; /** - * Optional. The severity of the log entry. The default value is - * `LogSeverity.DEFAULT`. + * Optional. The severity of the log entry. The default value is `LogSeverity.DEFAULT`. * - * Generated from protobuf field .google.logging.type.LogSeverity severity = 10; + * Generated from protobuf field .google.logging.type.LogSeverity severity = 10 [(.google.api.field_behavior) = OPTIONAL]; */ private $severity = 0; /** - * 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 + * 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. @@ -87,59 +85,46 @@ class LogEntry extends \Google\Protobuf\Internal\Message * In queries, the `insert_id` is also used to order log entries that have * the same `log_name` and `timestamp` values. * - * Generated from protobuf field string insert_id = 4; + * Generated from protobuf field string insert_id = 4 [(.google.api.field_behavior) = OPTIONAL]; */ private $insert_id = ''; /** - * Optional. Information about the HTTP request associated with this log - * entry, if applicable. + * Optional. Information about the HTTP request associated with this log entry, if + * applicable. * - * Generated from protobuf field .google.logging.type.HttpRequest http_request = 7; + * Generated from protobuf field .google.logging.type.HttpRequest http_request = 7 [(.google.api.field_behavior) = OPTIONAL]; */ private $http_request = null; /** * Optional. A set of user-defined (key, value) data that provides additional * information about the log entry. * - * Generated from protobuf field map labels = 11; + * Generated from protobuf field map labels = 11 [(.google.api.field_behavior) = OPTIONAL]; */ private $labels; - /** - * Deprecated. Output only. Additional metadata about the monitored resource. - * Only `k8s_container`, `k8s_pod`, and `k8s_node` MonitoredResources have - * this field populated for GKE versions older than 1.12.6. For GKE versions - * 1.12.6 and above, the `metadata` field has been deprecated. The Kubernetes - * pod labels that used to be in `metadata.userLabels` will now be present in - * the `labels` field with a key prefix of `k8s-pod/`. The Stackdriver system - * labels that were present in the `metadata.systemLabels` field will no - * longer be available in the LogEntry. - * - * Generated from protobuf field .google.api.MonitoredResourceMetadata metadata = 25 [deprecated = true]; - */ - private $metadata = null; /** * Optional. Information about an operation associated with the log entry, if * applicable. * - * Generated from protobuf field .google.logging.v2.LogEntryOperation operation = 15; + * Generated from protobuf field .google.logging.v2.LogEntryOperation operation = 15 [(.google.api.field_behavior) = OPTIONAL]; */ private $operation = null; /** - * 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: + * 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` * - * Generated from protobuf field string trace = 22; + * Generated from protobuf field string trace = 22 [(.google.api.field_behavior) = OPTIONAL]; */ private $trace = ''; /** * 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". + * `000000000000004a`. * - * Generated from protobuf field string span_id = 27; + * Generated from protobuf field string span_id = 27 [(.google.api.field_behavior) = OPTIONAL]; */ private $span_id = ''; /** @@ -150,14 +135,13 @@ class LogEntry extends \Google\Protobuf\Internal\Message * unknown at the time. A non-sampled `trace` value is still useful as a * request correlation identifier. The default is False. * - * Generated from protobuf field bool trace_sampled = 30; + * Generated from protobuf field bool trace_sampled = 30 [(.google.api.field_behavior) = OPTIONAL]; */ private $trace_sampled = false; /** - * Optional. Source code location information associated with the log entry, - * if any. + * Optional. Source code location information associated with the log entry, if any. * - * Generated from protobuf field .google.logging.v2.LogEntrySourceLocation source_location = 23; + * Generated from protobuf field .google.logging.v2.LogEntrySourceLocation source_location = 23 [(.google.api.field_behavior) = OPTIONAL]; */ private $source_location = null; protected $payload; @@ -174,9 +158,9 @@ class LogEntry extends \Google\Protobuf\Internal\Message * "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" * "folders/[FOLDER_ID]/logs/[LOG_ID]" - * A project number may optionally 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. + * 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 @@ -205,25 +189,23 @@ class LogEntry extends \Google\Protobuf\Internal\Message * The log entry payload, represented as a structure that is * expressed as a JSON object. * @type \Google\Protobuf\Timestamp $timestamp - * 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). + * 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 must have timestamps that don't exceed the + * [logs retention + * period](https://cloud.google.com/logging/quotas#logs_retention_periods) in + * the past, and that don't exceed 24 hours in the future. Log entries outside + * those time boundaries aren't ingested by Logging. * @type \Google\Protobuf\Timestamp $receive_timestamp * Output only. The time the log entry was received by Logging. * @type int $severity - * Optional. The severity of the log entry. The default value is - * `LogSeverity.DEFAULT`. + * Optional. The severity of the log entry. The default value is `LogSeverity.DEFAULT`. * @type string $insert_id - * 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 + * 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. @@ -232,33 +214,24 @@ class LogEntry extends \Google\Protobuf\Internal\Message * In queries, the `insert_id` is also used to order log entries that have * the same `log_name` and `timestamp` values. * @type \Google\Cloud\Logging\Type\HttpRequest $http_request - * Optional. Information about the HTTP request associated with this log - * entry, if applicable. + * Optional. Information about the HTTP request associated with this log entry, if + * applicable. * @type array|\Google\Protobuf\Internal\MapField $labels * Optional. A set of user-defined (key, value) data that provides additional * information about the log entry. - * @type \Google\Api\MonitoredResourceMetadata $metadata - * Deprecated. Output only. Additional metadata about the monitored resource. - * Only `k8s_container`, `k8s_pod`, and `k8s_node` MonitoredResources have - * this field populated for GKE versions older than 1.12.6. For GKE versions - * 1.12.6 and above, the `metadata` field has been deprecated. The Kubernetes - * pod labels that used to be in `metadata.userLabels` will now be present in - * the `labels` field with a key prefix of `k8s-pod/`. The Stackdriver system - * labels that were present in the `metadata.systemLabels` field will no - * longer be available in the LogEntry. * @type \Google\Cloud\Logging\V2\LogEntryOperation $operation * Optional. Information about an operation associated with the log entry, if * applicable. * @type string $trace - * 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: + * 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` * @type string $span_id * 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". + * `000000000000004a`. * @type bool $trace_sampled * 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 @@ -267,8 +240,7 @@ class LogEntry extends \Google\Protobuf\Internal\Message * unknown at the time. A non-sampled `trace` value is still useful as a * request correlation identifier. The default is False. * @type \Google\Cloud\Logging\V2\LogEntrySourceLocation $source_location - * Optional. Source code location information associated with the log entry, - * if any. + * Optional. Source code location information associated with the log entry, if any. * } */ public function __construct($data = NULL) { @@ -282,9 +254,9 @@ public function __construct($data = NULL) { * "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" * "folders/[FOLDER_ID]/logs/[LOG_ID]" - * A project number may optionally 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. + * 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 @@ -296,7 +268,7 @@ public function __construct($data = NULL) { * slash and filtering for a log name with a leading slash will never return * any results. * - * Generated from protobuf field string log_name = 12; + * Generated from protobuf field string log_name = 12 [(.google.api.field_behavior) = REQUIRED]; * @return string */ public function getLogName() @@ -310,9 +282,9 @@ public function getLogName() * "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" * "folders/[FOLDER_ID]/logs/[LOG_ID]" - * A project number may optionally 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. + * 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 @@ -324,7 +296,7 @@ public function getLogName() * slash and filtering for a log name with a leading slash will never return * any results. * - * Generated from protobuf field string log_name = 12; + * Generated from protobuf field string log_name = 12 [(.google.api.field_behavior) = REQUIRED]; * @param string $var * @return $this */ @@ -342,21 +314,31 @@ public function setLogName($var) * the monitored resource designating the particular database that reported * the error. * - * Generated from protobuf field .google.api.MonitoredResource resource = 8; - * @return \Google\Api\MonitoredResource + * Generated from protobuf field .google.api.MonitoredResource resource = 8 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Api\MonitoredResource|null */ public function getResource() { return $this->resource; } + public function hasResource() + { + return isset($this->resource); + } + + public function clearResource() + { + unset($this->resource); + } + /** * 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. * - * Generated from protobuf field .google.api.MonitoredResource resource = 8; + * Generated from protobuf field .google.api.MonitoredResource resource = 8 [(.google.api.field_behavior) = REQUIRED]; * @param \Google\Api\MonitoredResource $var * @return $this */ @@ -377,13 +359,18 @@ public function setResource($var) * "type.googleapis.com/google.appengine.logging.v1.RequestLog" * * Generated from protobuf field .google.protobuf.Any proto_payload = 2; - * @return \Google\Protobuf\Any + * @return \Google\Protobuf\Any|null */ public function getProtoPayload() { return $this->readOneof(2); } + public function hasProtoPayload() + { + return $this->hasOneof(2); + } + /** * The log entry payload, represented as a protocol buffer. Some Google * Cloud Platform services use this field for their log entry payloads. @@ -415,6 +402,11 @@ public function getTextPayload() return $this->readOneof(3); } + public function hasTextPayload() + { + return $this->hasOneof(3); + } + /** * The log entry payload, represented as a Unicode string (UTF-8). * @@ -435,13 +427,18 @@ public function setTextPayload($var) * expressed as a JSON object. * * Generated from protobuf field .google.protobuf.Struct json_payload = 6; - * @return \Google\Protobuf\Struct + * @return \Google\Protobuf\Struct|null */ public function getJsonPayload() { return $this->readOneof(6); } + public function hasJsonPayload() + { + return $this->hasOneof(6); + } + /** * The log entry payload, represented as a structure that is * expressed as a JSON object. @@ -459,40 +456,48 @@ public function setJsonPayload($var) } /** - * 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). + * 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 must have timestamps that don't exceed the + * [logs retention + * period](https://cloud.google.com/logging/quotas#logs_retention_periods) in + * the past, and that don't exceed 24 hours in the future. Log entries outside + * those time boundaries aren't ingested by Logging. * - * Generated from protobuf field .google.protobuf.Timestamp timestamp = 9; - * @return \Google\Protobuf\Timestamp + * Generated from protobuf field .google.protobuf.Timestamp timestamp = 9 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Timestamp|null */ public function getTimestamp() { return $this->timestamp; } + public function hasTimestamp() + { + return isset($this->timestamp); + } + + public function clearTimestamp() + { + unset($this->timestamp); + } + /** - * 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). + * 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 must have timestamps that don't exceed the + * [logs retention + * period](https://cloud.google.com/logging/quotas#logs_retention_periods) in + * the past, and that don't exceed 24 hours in the future. Log entries outside + * those time boundaries aren't ingested by Logging. * - * Generated from protobuf field .google.protobuf.Timestamp timestamp = 9; + * Generated from protobuf field .google.protobuf.Timestamp timestamp = 9 [(.google.api.field_behavior) = OPTIONAL]; * @param \Google\Protobuf\Timestamp $var * @return $this */ @@ -507,18 +512,28 @@ public function setTimestamp($var) /** * Output only. The time the log entry was received by Logging. * - * Generated from protobuf field .google.protobuf.Timestamp receive_timestamp = 24; - * @return \Google\Protobuf\Timestamp + * Generated from protobuf field .google.protobuf.Timestamp receive_timestamp = 24 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null */ public function getReceiveTimestamp() { return $this->receive_timestamp; } + public function hasReceiveTimestamp() + { + return isset($this->receive_timestamp); + } + + public function clearReceiveTimestamp() + { + unset($this->receive_timestamp); + } + /** * Output only. The time the log entry was received by Logging. * - * Generated from protobuf field .google.protobuf.Timestamp receive_timestamp = 24; + * Generated from protobuf field .google.protobuf.Timestamp receive_timestamp = 24 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @param \Google\Protobuf\Timestamp $var * @return $this */ @@ -531,10 +546,9 @@ public function setReceiveTimestamp($var) } /** - * Optional. The severity of the log entry. The default value is - * `LogSeverity.DEFAULT`. + * Optional. The severity of the log entry. The default value is `LogSeverity.DEFAULT`. * - * Generated from protobuf field .google.logging.type.LogSeverity severity = 10; + * Generated from protobuf field .google.logging.type.LogSeverity severity = 10 [(.google.api.field_behavior) = OPTIONAL]; * @return int */ public function getSeverity() @@ -543,10 +557,9 @@ public function getSeverity() } /** - * Optional. The severity of the log entry. The default value is - * `LogSeverity.DEFAULT`. + * Optional. The severity of the log entry. The default value is `LogSeverity.DEFAULT`. * - * Generated from protobuf field .google.logging.type.LogSeverity severity = 10; + * Generated from protobuf field .google.logging.type.LogSeverity severity = 10 [(.google.api.field_behavior) = OPTIONAL]; * @param int $var * @return $this */ @@ -559,8 +572,8 @@ public function setSeverity($var) } /** - * 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 + * 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. @@ -569,7 +582,7 @@ public function setSeverity($var) * In queries, the `insert_id` is also used to order log entries that have * the same `log_name` and `timestamp` values. * - * Generated from protobuf field string insert_id = 4; + * Generated from protobuf field string insert_id = 4 [(.google.api.field_behavior) = OPTIONAL]; * @return string */ public function getInsertId() @@ -578,8 +591,8 @@ public function getInsertId() } /** - * 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 + * 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. @@ -588,7 +601,7 @@ public function getInsertId() * In queries, the `insert_id` is also used to order log entries that have * the same `log_name` and `timestamp` values. * - * Generated from protobuf field string insert_id = 4; + * Generated from protobuf field string insert_id = 4 [(.google.api.field_behavior) = OPTIONAL]; * @param string $var * @return $this */ @@ -601,22 +614,32 @@ public function setInsertId($var) } /** - * Optional. Information about the HTTP request associated with this log - * entry, if applicable. + * Optional. Information about the HTTP request associated with this log entry, if + * applicable. * - * Generated from protobuf field .google.logging.type.HttpRequest http_request = 7; - * @return \Google\Cloud\Logging\Type\HttpRequest + * Generated from protobuf field .google.logging.type.HttpRequest http_request = 7 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Logging\Type\HttpRequest|null */ public function getHttpRequest() { return $this->http_request; } + public function hasHttpRequest() + { + return isset($this->http_request); + } + + public function clearHttpRequest() + { + unset($this->http_request); + } + /** - * Optional. Information about the HTTP request associated with this log - * entry, if applicable. + * Optional. Information about the HTTP request associated with this log entry, if + * applicable. * - * Generated from protobuf field .google.logging.type.HttpRequest http_request = 7; + * Generated from protobuf field .google.logging.type.HttpRequest http_request = 7 [(.google.api.field_behavior) = OPTIONAL]; * @param \Google\Cloud\Logging\Type\HttpRequest $var * @return $this */ @@ -632,7 +655,7 @@ public function setHttpRequest($var) * Optional. A set of user-defined (key, value) data that provides additional * information about the log entry. * - * Generated from protobuf field map labels = 11; + * Generated from protobuf field map labels = 11 [(.google.api.field_behavior) = OPTIONAL]; * @return \Google\Protobuf\Internal\MapField */ public function getLabels() @@ -644,7 +667,7 @@ public function getLabels() * Optional. A set of user-defined (key, value) data that provides additional * information about the log entry. * - * Generated from protobuf field map labels = 11; + * Generated from protobuf field map labels = 11 [(.google.api.field_behavior) = OPTIONAL]; * @param array|\Google\Protobuf\Internal\MapField $var * @return $this */ @@ -657,62 +680,32 @@ public function setLabels($var) } /** - * Deprecated. Output only. Additional metadata about the monitored resource. - * Only `k8s_container`, `k8s_pod`, and `k8s_node` MonitoredResources have - * this field populated for GKE versions older than 1.12.6. For GKE versions - * 1.12.6 and above, the `metadata` field has been deprecated. The Kubernetes - * pod labels that used to be in `metadata.userLabels` will now be present in - * the `labels` field with a key prefix of `k8s-pod/`. The Stackdriver system - * labels that were present in the `metadata.systemLabels` field will no - * longer be available in the LogEntry. + * Optional. Information about an operation associated with the log entry, if + * applicable. * - * Generated from protobuf field .google.api.MonitoredResourceMetadata metadata = 25 [deprecated = true]; - * @return \Google\Api\MonitoredResourceMetadata + * Generated from protobuf field .google.logging.v2.LogEntryOperation operation = 15 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Logging\V2\LogEntryOperation|null */ - public function getMetadata() + public function getOperation() { - return $this->metadata; + return $this->operation; } - /** - * Deprecated. Output only. Additional metadata about the monitored resource. - * Only `k8s_container`, `k8s_pod`, and `k8s_node` MonitoredResources have - * this field populated for GKE versions older than 1.12.6. For GKE versions - * 1.12.6 and above, the `metadata` field has been deprecated. The Kubernetes - * pod labels that used to be in `metadata.userLabels` will now be present in - * the `labels` field with a key prefix of `k8s-pod/`. The Stackdriver system - * labels that were present in the `metadata.systemLabels` field will no - * longer be available in the LogEntry. - * - * Generated from protobuf field .google.api.MonitoredResourceMetadata metadata = 25 [deprecated = true]; - * @param \Google\Api\MonitoredResourceMetadata $var - * @return $this - */ - public function setMetadata($var) + public function hasOperation() { - GPBUtil::checkMessage($var, \Google\Api\MonitoredResourceMetadata::class); - $this->metadata = $var; - - return $this; + return isset($this->operation); } - /** - * Optional. Information about an operation associated with the log entry, if - * applicable. - * - * Generated from protobuf field .google.logging.v2.LogEntryOperation operation = 15; - * @return \Google\Cloud\Logging\V2\LogEntryOperation - */ - public function getOperation() + public function clearOperation() { - return $this->operation; + unset($this->operation); } /** * Optional. Information about an operation associated with the log entry, if * applicable. * - * Generated from protobuf field .google.logging.v2.LogEntryOperation operation = 15; + * Generated from protobuf field .google.logging.v2.LogEntryOperation operation = 15 [(.google.api.field_behavior) = OPTIONAL]; * @param \Google\Cloud\Logging\V2\LogEntryOperation $var * @return $this */ @@ -725,12 +718,12 @@ public function setOperation($var) } /** - * 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: + * 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` * - * Generated from protobuf field string trace = 22; + * Generated from protobuf field string trace = 22 [(.google.api.field_behavior) = OPTIONAL]; * @return string */ public function getTrace() @@ -739,12 +732,12 @@ public function getTrace() } /** - * 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: + * 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` * - * Generated from protobuf field string trace = 22; + * Generated from protobuf field string trace = 22 [(.google.api.field_behavior) = OPTIONAL]; * @param string $var * @return $this */ @@ -760,9 +753,9 @@ public function setTrace($var) * 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". + * `000000000000004a`. * - * Generated from protobuf field string span_id = 27; + * Generated from protobuf field string span_id = 27 [(.google.api.field_behavior) = OPTIONAL]; * @return string */ public function getSpanId() @@ -774,9 +767,9 @@ public function getSpanId() * 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". + * `000000000000004a`. * - * Generated from protobuf field string span_id = 27; + * Generated from protobuf field string span_id = 27 [(.google.api.field_behavior) = OPTIONAL]; * @param string $var * @return $this */ @@ -796,7 +789,7 @@ public function setSpanId($var) * unknown at the time. A non-sampled `trace` value is still useful as a * request correlation identifier. The default is False. * - * Generated from protobuf field bool trace_sampled = 30; + * Generated from protobuf field bool trace_sampled = 30 [(.google.api.field_behavior) = OPTIONAL]; * @return bool */ public function getTraceSampled() @@ -812,7 +805,7 @@ public function getTraceSampled() * unknown at the time. A non-sampled `trace` value is still useful as a * request correlation identifier. The default is False. * - * Generated from protobuf field bool trace_sampled = 30; + * Generated from protobuf field bool trace_sampled = 30 [(.google.api.field_behavior) = OPTIONAL]; * @param bool $var * @return $this */ @@ -825,22 +818,30 @@ public function setTraceSampled($var) } /** - * Optional. Source code location information associated with the log entry, - * if any. + * Optional. Source code location information associated with the log entry, if any. * - * Generated from protobuf field .google.logging.v2.LogEntrySourceLocation source_location = 23; - * @return \Google\Cloud\Logging\V2\LogEntrySourceLocation + * Generated from protobuf field .google.logging.v2.LogEntrySourceLocation source_location = 23 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Logging\V2\LogEntrySourceLocation|null */ public function getSourceLocation() { return $this->source_location; } + public function hasSourceLocation() + { + return isset($this->source_location); + } + + public function clearSourceLocation() + { + unset($this->source_location); + } + /** - * Optional. Source code location information associated with the log entry, - * if any. + * Optional. Source code location information associated with the log entry, if any. * - * Generated from protobuf field .google.logging.v2.LogEntrySourceLocation source_location = 23; + * Generated from protobuf field .google.logging.v2.LogEntrySourceLocation source_location = 23 [(.google.api.field_behavior) = OPTIONAL]; * @param \Google\Cloud\Logging\V2\LogEntrySourceLocation $var * @return $this */ diff --git a/Logging/src/V2/LogEntryOperation.php b/Logging/src/V2/LogEntryOperation.php index 630881e0d871..b2a1469ebc41 100644 --- a/Logging/src/V2/LogEntryOperation.php +++ b/Logging/src/V2/LogEntryOperation.php @@ -20,7 +20,7 @@ class LogEntryOperation extends \Google\Protobuf\Internal\Message * Optional. An arbitrary operation identifier. Log entries with the same * identifier are assumed to be part of the same operation. * - * Generated from protobuf field string id = 1; + * Generated from protobuf field string id = 1 [(.google.api.field_behavior) = OPTIONAL]; */ private $id = ''; /** @@ -28,19 +28,19 @@ class LogEntryOperation extends \Google\Protobuf\Internal\Message * `producer` must be globally unique. Examples for `producer`: * `"MyDivision.MyBigCompany.com"`, `"github.com/MyProject/MyApplication"`. * - * Generated from protobuf field string producer = 2; + * Generated from protobuf field string producer = 2 [(.google.api.field_behavior) = OPTIONAL]; */ private $producer = ''; /** * Optional. Set this to True if this is the first log entry in the operation. * - * Generated from protobuf field bool first = 3; + * Generated from protobuf field bool first = 3 [(.google.api.field_behavior) = OPTIONAL]; */ private $first = false; /** * Optional. Set this to True if this is the last log entry in the operation. * - * Generated from protobuf field bool last = 4; + * Generated from protobuf field bool last = 4 [(.google.api.field_behavior) = OPTIONAL]; */ private $last = false; @@ -72,7 +72,7 @@ public function __construct($data = NULL) { * Optional. An arbitrary operation identifier. Log entries with the same * identifier are assumed to be part of the same operation. * - * Generated from protobuf field string id = 1; + * Generated from protobuf field string id = 1 [(.google.api.field_behavior) = OPTIONAL]; * @return string */ public function getId() @@ -84,7 +84,7 @@ public function getId() * Optional. An arbitrary operation identifier. Log entries with the same * identifier are assumed to be part of the same operation. * - * Generated from protobuf field string id = 1; + * Generated from protobuf field string id = 1 [(.google.api.field_behavior) = OPTIONAL]; * @param string $var * @return $this */ @@ -101,7 +101,7 @@ public function setId($var) * `producer` must be globally unique. Examples for `producer`: * `"MyDivision.MyBigCompany.com"`, `"github.com/MyProject/MyApplication"`. * - * Generated from protobuf field string producer = 2; + * Generated from protobuf field string producer = 2 [(.google.api.field_behavior) = OPTIONAL]; * @return string */ public function getProducer() @@ -114,7 +114,7 @@ public function getProducer() * `producer` must be globally unique. Examples for `producer`: * `"MyDivision.MyBigCompany.com"`, `"github.com/MyProject/MyApplication"`. * - * Generated from protobuf field string producer = 2; + * Generated from protobuf field string producer = 2 [(.google.api.field_behavior) = OPTIONAL]; * @param string $var * @return $this */ @@ -129,7 +129,7 @@ public function setProducer($var) /** * Optional. Set this to True if this is the first log entry in the operation. * - * Generated from protobuf field bool first = 3; + * Generated from protobuf field bool first = 3 [(.google.api.field_behavior) = OPTIONAL]; * @return bool */ public function getFirst() @@ -140,7 +140,7 @@ public function getFirst() /** * Optional. Set this to True if this is the first log entry in the operation. * - * Generated from protobuf field bool first = 3; + * Generated from protobuf field bool first = 3 [(.google.api.field_behavior) = OPTIONAL]; * @param bool $var * @return $this */ @@ -155,7 +155,7 @@ public function setFirst($var) /** * Optional. Set this to True if this is the last log entry in the operation. * - * Generated from protobuf field bool last = 4; + * Generated from protobuf field bool last = 4 [(.google.api.field_behavior) = OPTIONAL]; * @return bool */ public function getLast() @@ -166,7 +166,7 @@ public function getLast() /** * Optional. Set this to True if this is the last log entry in the operation. * - * Generated from protobuf field bool last = 4; + * Generated from protobuf field bool last = 4 [(.google.api.field_behavior) = OPTIONAL]; * @param bool $var * @return $this */ diff --git a/Logging/src/V2/LogEntrySourceLocation.php b/Logging/src/V2/LogEntrySourceLocation.php index bba40de24d8b..5de1db970089 100644 --- a/Logging/src/V2/LogEntrySourceLocation.php +++ b/Logging/src/V2/LogEntrySourceLocation.php @@ -20,14 +20,14 @@ class LogEntrySourceLocation extends \Google\Protobuf\Internal\Message * Optional. Source file name. Depending on the runtime environment, this * might be a simple name or a fully-qualified name. * - * Generated from protobuf field string file = 1; + * Generated from protobuf field string file = 1 [(.google.api.field_behavior) = OPTIONAL]; */ private $file = ''; /** * Optional. Line within the source file. 1-based; 0 indicates no line number * available. * - * Generated from protobuf field int64 line = 2; + * Generated from protobuf field int64 line = 2 [(.google.api.field_behavior) = OPTIONAL]; */ private $line = 0; /** @@ -38,7 +38,7 @@ class LogEntrySourceLocation extends \Google\Protobuf\Internal\Message * `qual.if.ied.Class.method` (Java), `dir/package.func` (Go), `function` * (Python). * - * Generated from protobuf field string function = 3; + * Generated from protobuf field string function = 3 [(.google.api.field_behavior) = OPTIONAL]; */ private $function = ''; @@ -72,7 +72,7 @@ public function __construct($data = NULL) { * Optional. Source file name. Depending on the runtime environment, this * might be a simple name or a fully-qualified name. * - * Generated from protobuf field string file = 1; + * Generated from protobuf field string file = 1 [(.google.api.field_behavior) = OPTIONAL]; * @return string */ public function getFile() @@ -84,7 +84,7 @@ public function getFile() * Optional. Source file name. Depending on the runtime environment, this * might be a simple name or a fully-qualified name. * - * Generated from protobuf field string file = 1; + * Generated from protobuf field string file = 1 [(.google.api.field_behavior) = OPTIONAL]; * @param string $var * @return $this */ @@ -100,7 +100,7 @@ public function setFile($var) * Optional. Line within the source file. 1-based; 0 indicates no line number * available. * - * Generated from protobuf field int64 line = 2; + * Generated from protobuf field int64 line = 2 [(.google.api.field_behavior) = OPTIONAL]; * @return int|string */ public function getLine() @@ -112,7 +112,7 @@ public function getLine() * Optional. Line within the source file. 1-based; 0 indicates no line number * available. * - * Generated from protobuf field int64 line = 2; + * Generated from protobuf field int64 line = 2 [(.google.api.field_behavior) = OPTIONAL]; * @param int|string $var * @return $this */ @@ -132,7 +132,7 @@ public function setLine($var) * `qual.if.ied.Class.method` (Java), `dir/package.func` (Go), `function` * (Python). * - * Generated from protobuf field string function = 3; + * Generated from protobuf field string function = 3 [(.google.api.field_behavior) = OPTIONAL]; * @return string */ public function getFunction() @@ -148,7 +148,7 @@ public function getFunction() * `qual.if.ied.Class.method` (Java), `dir/package.func` (Go), `function` * (Python). * - * Generated from protobuf field string function = 3; + * Generated from protobuf field string function = 3 [(.google.api.field_behavior) = OPTIONAL]; * @param string $var * @return $this */ diff --git a/Logging/src/V2/LogExclusion.php b/Logging/src/V2/LogExclusion.php index e96054a44fa0..f6728aa6e5c2 100644 --- a/Logging/src/V2/LogExclusion.php +++ b/Logging/src/V2/LogExclusion.php @@ -21,30 +21,31 @@ class LogExclusion extends \Google\Protobuf\Internal\Message { /** - * 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. + * 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. * - * Generated from protobuf field string name = 1; + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ private $name = ''; /** * Optional. A description of this exclusion. * - * Generated from protobuf field string description = 2; + * Generated from protobuf field string description = 2 [(.google.api.field_behavior) = OPTIONAL]; */ private $description = ''; /** - * 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), + * Required. An [advanced logs + * filter](https://cloud.google.com/logging/docs/view/advanced-queries) that + * matches the log entries to be excluded. By using the [sample + * function](https://cloud.google.com/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 severitystring filter = 3; + * Generated from protobuf field string filter = 3 [(.google.api.field_behavior) = REQUIRED]; */ private $filter = ''; /** @@ -53,21 +54,21 @@ class LogExclusion extends \Google\Protobuf\Internal\Message * exclusion][google.logging.v2.ConfigServiceV2.UpdateExclusion] to change the * value of this field. * - * Generated from protobuf field bool disabled = 4; + * Generated from protobuf field bool disabled = 4 [(.google.api.field_behavior) = OPTIONAL]; */ private $disabled = false; /** * Output only. The creation timestamp of the exclusion. * This field may not be present for older exclusions. * - * Generated from protobuf field .google.protobuf.Timestamp create_time = 5; + * Generated from protobuf field .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ private $create_time = null; /** * Output only. The last update timestamp of the exclusion. * This field may not be present for older exclusions. * - * Generated from protobuf field .google.protobuf.Timestamp update_time = 6; + * Generated from protobuf field .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ private $update_time = null; @@ -78,16 +79,17 @@ class LogExclusion extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $name - * 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. + * 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. * @type string $description * Optional. A description of this exclusion. * @type string $filter - * 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), + * Required. An [advanced logs + * filter](https://cloud.google.com/logging/docs/view/advanced-queries) that + * matches the log entries to be excluded. By using the [sample + * function](https://cloud.google.com/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: @@ -111,12 +113,12 @@ public function __construct($data = NULL) { } /** - * 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. + * 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. * - * Generated from protobuf field string name = 1; + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; * @return string */ public function getName() @@ -125,12 +127,12 @@ public function getName() } /** - * 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. + * 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. * - * Generated from protobuf field string name = 1; + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; * @param string $var * @return $this */ @@ -145,7 +147,7 @@ public function setName($var) /** * Optional. A description of this exclusion. * - * Generated from protobuf field string description = 2; + * Generated from protobuf field string description = 2 [(.google.api.field_behavior) = OPTIONAL]; * @return string */ public function getDescription() @@ -156,7 +158,7 @@ public function getDescription() /** * Optional. A description of this exclusion. * - * Generated from protobuf field string description = 2; + * Generated from protobuf field string description = 2 [(.google.api.field_behavior) = OPTIONAL]; * @param string $var * @return $this */ @@ -169,15 +171,16 @@ public function setDescription($var) } /** - * 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), + * Required. An [advanced logs + * filter](https://cloud.google.com/logging/docs/view/advanced-queries) that + * matches the log entries to be excluded. By using the [sample + * function](https://cloud.google.com/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 severitystring filter = 3; + * Generated from protobuf field string filter = 3 [(.google.api.field_behavior) = REQUIRED]; * @return string */ public function getFilter() @@ -186,15 +189,16 @@ public function getFilter() } /** - * 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), + * Required. An [advanced logs + * filter](https://cloud.google.com/logging/docs/view/advanced-queries) that + * matches the log entries to be excluded. By using the [sample + * function](https://cloud.google.com/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 severitystring filter = 3; + * Generated from protobuf field string filter = 3 [(.google.api.field_behavior) = REQUIRED]; * @param string $var * @return $this */ @@ -212,7 +216,7 @@ public function setFilter($var) * exclusion][google.logging.v2.ConfigServiceV2.UpdateExclusion] to change the * value of this field. * - * Generated from protobuf field bool disabled = 4; + * Generated from protobuf field bool disabled = 4 [(.google.api.field_behavior) = OPTIONAL]; * @return bool */ public function getDisabled() @@ -226,7 +230,7 @@ public function getDisabled() * exclusion][google.logging.v2.ConfigServiceV2.UpdateExclusion] to change the * value of this field. * - * Generated from protobuf field bool disabled = 4; + * Generated from protobuf field bool disabled = 4 [(.google.api.field_behavior) = OPTIONAL]; * @param bool $var * @return $this */ @@ -242,19 +246,29 @@ public function setDisabled($var) * Output only. The creation timestamp of the exclusion. * This field may not be present for older exclusions. * - * Generated from protobuf field .google.protobuf.Timestamp create_time = 5; - * @return \Google\Protobuf\Timestamp + * Generated from protobuf field .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null */ public function getCreateTime() { return $this->create_time; } + public function hasCreateTime() + { + return isset($this->create_time); + } + + public function clearCreateTime() + { + unset($this->create_time); + } + /** * Output only. The creation timestamp of the exclusion. * This field may not be present for older exclusions. * - * Generated from protobuf field .google.protobuf.Timestamp create_time = 5; + * Generated from protobuf field .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @param \Google\Protobuf\Timestamp $var * @return $this */ @@ -270,19 +284,29 @@ public function setCreateTime($var) * Output only. The last update timestamp of the exclusion. * This field may not be present for older exclusions. * - * Generated from protobuf field .google.protobuf.Timestamp update_time = 6; - * @return \Google\Protobuf\Timestamp + * Generated from protobuf field .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null */ public function getUpdateTime() { return $this->update_time; } + public function hasUpdateTime() + { + return isset($this->update_time); + } + + public function clearUpdateTime() + { + unset($this->update_time); + } + /** * Output only. The last update timestamp of the exclusion. * This field may not be present for older exclusions. * - * Generated from protobuf field .google.protobuf.Timestamp update_time = 6; + * Generated from protobuf field .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @param \Google\Protobuf\Timestamp $var * @return $this */ diff --git a/Logging/src/V2/LogMetric.php b/Logging/src/V2/LogMetric.php index 114da18a32d2..1a01d5bf27af 100644 --- a/Logging/src/V2/LogMetric.php +++ b/Logging/src/V2/LogMetric.php @@ -11,8 +11,8 @@ /** * Describes a logs-based metric. The value of the metric is the number of log * entries that match a logs filter in a given time interval. - * Logs-based metric can also be used to extract values from logs and create a - * a distribution of the values. The distribution records the statistics of the + * Logs-based metrics can also be used to extract values from logs and create a + * distribution of the values. The distribution records the statistics of the * extracted values along with an optional histogram of the values as specified * by the bucket options. * @@ -33,24 +33,24 @@ class LogMetric extends \Google\Protobuf\Internal\Message * `metric_name` API parameter, then the metric identifier must be * URL-encoded. Example: `"projects/my-project/metrics/nginx%2Frequests"`. * - * Generated from protobuf field string name = 1; + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ private $name = ''; /** * Optional. A description of this metric, which is used in documentation. * The maximum length of the description is 8000 characters. * - * Generated from protobuf field string description = 2; + * Generated from protobuf field string description = 2 [(.google.api.field_behavior) = OPTIONAL]; */ private $description = ''; /** - * Required. An [advanced logs filter](/logging/docs/view/advanced_filters) - * which is used to match log entries. - * Example: + * Required. An [advanced logs + * filter](https://cloud.google.com/logging/docs/view/advanced_filters) which + * is used to match log entries. Example: * "resource.type=gae_app AND severity>=ERROR" * The maximum length of the filter is 20000 characters. * - * Generated from protobuf field string filter = 3; + * Generated from protobuf field string filter = 3 [(.google.api.field_behavior) = REQUIRED]; */ private $filter = ''; /** @@ -72,7 +72,7 @@ class LogMetric extends \Google\Protobuf\Internal\Message * `metric_descriptor`, but existing labels cannot be modified except for * their description. * - * Generated from protobuf field .google.api.MetricDescriptor metric_descriptor = 5; + * Generated from protobuf field .google.api.MetricDescriptor metric_descriptor = 5 [(.google.api.field_behavior) = OPTIONAL]; */ private $metric_descriptor = null; /** @@ -94,7 +94,7 @@ class LogMetric extends \Google\Protobuf\Internal\Message * distribution. * Example: `REGEXP_EXTRACT(jsonPayload.request, ".*quantity=(\d+).*")` * - * Generated from protobuf field string value_extractor = 6; + * Generated from protobuf field string value_extractor = 6 [(.google.api.field_behavior) = OPTIONAL]; */ private $value_extractor = ''; /** @@ -111,7 +111,7 @@ class LogMetric extends \Google\Protobuf\Internal\Message * 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. * - * Generated from protobuf field map label_extractors = 7; + * Generated from protobuf field map label_extractors = 7 [(.google.api.field_behavior) = OPTIONAL]; */ private $label_extractors; /** @@ -119,21 +119,21 @@ class LogMetric extends \Google\Protobuf\Internal\Message * using a DISTRIBUTION value type and it describes the bucket boundaries * used to create a histogram of the extracted values. * - * Generated from protobuf field .google.api.Distribution.BucketOptions bucket_options = 8; + * Generated from protobuf field .google.api.Distribution.BucketOptions bucket_options = 8 [(.google.api.field_behavior) = OPTIONAL]; */ private $bucket_options = null; /** * Output only. The creation timestamp of the metric. * This field may not be present for older metrics. * - * Generated from protobuf field .google.protobuf.Timestamp create_time = 9; + * Generated from protobuf field .google.protobuf.Timestamp create_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ private $create_time = null; /** * Output only. The last update timestamp of the metric. * This field may not be present for older metrics. * - * Generated from protobuf field .google.protobuf.Timestamp update_time = 10; + * Generated from protobuf field .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ private $update_time = null; /** @@ -141,8 +141,9 @@ class LogMetric extends \Google\Protobuf\Internal\Message * The v2 format is used by default and cannot be changed. * * Generated from protobuf field .google.logging.v2.LogMetric.ApiVersion version = 4 [deprecated = true]; + * @deprecated */ - private $version = 0; + protected $version = 0; /** * Constructor. @@ -166,9 +167,9 @@ class LogMetric extends \Google\Protobuf\Internal\Message * Optional. A description of this metric, which is used in documentation. * The maximum length of the description is 8000 characters. * @type string $filter - * Required. An [advanced logs filter](/logging/docs/view/advanced_filters) - * which is used to match log entries. - * Example: + * Required. An [advanced logs + * filter](https://cloud.google.com/logging/docs/view/advanced_filters) which + * is used to match log entries. Example: * "resource.type=gae_app AND severity>=ERROR" * The maximum length of the filter is 20000 characters. * @type \Google\Api\MetricDescriptor $metric_descriptor @@ -253,7 +254,7 @@ public function __construct($data = NULL) { * `metric_name` API parameter, then the metric identifier must be * URL-encoded. Example: `"projects/my-project/metrics/nginx%2Frequests"`. * - * Generated from protobuf field string name = 1; + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; * @return string */ public function getName() @@ -274,7 +275,7 @@ public function getName() * `metric_name` API parameter, then the metric identifier must be * URL-encoded. Example: `"projects/my-project/metrics/nginx%2Frequests"`. * - * Generated from protobuf field string name = 1; + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; * @param string $var * @return $this */ @@ -290,7 +291,7 @@ public function setName($var) * Optional. A description of this metric, which is used in documentation. * The maximum length of the description is 8000 characters. * - * Generated from protobuf field string description = 2; + * Generated from protobuf field string description = 2 [(.google.api.field_behavior) = OPTIONAL]; * @return string */ public function getDescription() @@ -302,7 +303,7 @@ public function getDescription() * Optional. A description of this metric, which is used in documentation. * The maximum length of the description is 8000 characters. * - * Generated from protobuf field string description = 2; + * Generated from protobuf field string description = 2 [(.google.api.field_behavior) = OPTIONAL]; * @param string $var * @return $this */ @@ -315,13 +316,13 @@ public function setDescription($var) } /** - * Required. An [advanced logs filter](/logging/docs/view/advanced_filters) - * which is used to match log entries. - * Example: + * Required. An [advanced logs + * filter](https://cloud.google.com/logging/docs/view/advanced_filters) which + * is used to match log entries. Example: * "resource.type=gae_app AND severity>=ERROR" * The maximum length of the filter is 20000 characters. * - * Generated from protobuf field string filter = 3; + * Generated from protobuf field string filter = 3 [(.google.api.field_behavior) = REQUIRED]; * @return string */ public function getFilter() @@ -330,13 +331,13 @@ public function getFilter() } /** - * Required. An [advanced logs filter](/logging/docs/view/advanced_filters) - * which is used to match log entries. - * Example: + * Required. An [advanced logs + * filter](https://cloud.google.com/logging/docs/view/advanced_filters) which + * is used to match log entries. Example: * "resource.type=gae_app AND severity>=ERROR" * The maximum length of the filter is 20000 characters. * - * Generated from protobuf field string filter = 3; + * Generated from protobuf field string filter = 3 [(.google.api.field_behavior) = REQUIRED]; * @param string $var * @return $this */ @@ -367,14 +368,24 @@ public function setFilter($var) * `metric_descriptor`, but existing labels cannot be modified except for * their description. * - * Generated from protobuf field .google.api.MetricDescriptor metric_descriptor = 5; - * @return \Google\Api\MetricDescriptor + * Generated from protobuf field .google.api.MetricDescriptor metric_descriptor = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Api\MetricDescriptor|null */ public function getMetricDescriptor() { return $this->metric_descriptor; } + public function hasMetricDescriptor() + { + return isset($this->metric_descriptor); + } + + public function clearMetricDescriptor() + { + unset($this->metric_descriptor); + } + /** * Optional. The metric descriptor associated with the logs-based metric. * If unspecified, it uses a default metric descriptor with a DELTA metric @@ -394,7 +405,7 @@ public function getMetricDescriptor() * `metric_descriptor`, but existing labels cannot be modified except for * their description. * - * Generated from protobuf field .google.api.MetricDescriptor metric_descriptor = 5; + * Generated from protobuf field .google.api.MetricDescriptor metric_descriptor = 5 [(.google.api.field_behavior) = OPTIONAL]; * @param \Google\Api\MetricDescriptor $var * @return $this */ @@ -425,7 +436,7 @@ public function setMetricDescriptor($var) * distribution. * Example: `REGEXP_EXTRACT(jsonPayload.request, ".*quantity=(\d+).*")` * - * Generated from protobuf field string value_extractor = 6; + * Generated from protobuf field string value_extractor = 6 [(.google.api.field_behavior) = OPTIONAL]; * @return string */ public function getValueExtractor() @@ -452,7 +463,7 @@ public function getValueExtractor() * distribution. * Example: `REGEXP_EXTRACT(jsonPayload.request, ".*quantity=(\d+).*")` * - * Generated from protobuf field string value_extractor = 6; + * Generated from protobuf field string value_extractor = 6 [(.google.api.field_behavior) = OPTIONAL]; * @param string $var * @return $this */ @@ -478,7 +489,7 @@ public function setValueExtractor($var) * 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. * - * Generated from protobuf field map label_extractors = 7; + * Generated from protobuf field map label_extractors = 7 [(.google.api.field_behavior) = OPTIONAL]; * @return \Google\Protobuf\Internal\MapField */ public function getLabelExtractors() @@ -500,7 +511,7 @@ public function getLabelExtractors() * 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. * - * Generated from protobuf field map label_extractors = 7; + * Generated from protobuf field map label_extractors = 7 [(.google.api.field_behavior) = OPTIONAL]; * @param array|\Google\Protobuf\Internal\MapField $var * @return $this */ @@ -517,26 +528,36 @@ public function setLabelExtractors($var) * using a DISTRIBUTION value type and it describes the bucket boundaries * used to create a histogram of the extracted values. * - * Generated from protobuf field .google.api.Distribution.BucketOptions bucket_options = 8; - * @return \Google\Api\Distribution\BucketOptions + * Generated from protobuf field .google.api.Distribution.BucketOptions bucket_options = 8 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Api\Distribution\BucketOptions|null */ public function getBucketOptions() { return $this->bucket_options; } + public function hasBucketOptions() + { + return isset($this->bucket_options); + } + + public function clearBucketOptions() + { + unset($this->bucket_options); + } + /** * 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. * - * Generated from protobuf field .google.api.Distribution.BucketOptions bucket_options = 8; + * Generated from protobuf field .google.api.Distribution.BucketOptions bucket_options = 8 [(.google.api.field_behavior) = OPTIONAL]; * @param \Google\Api\Distribution\BucketOptions $var * @return $this */ public function setBucketOptions($var) { - GPBUtil::checkMessage($var, \Google\Api\Distribution_BucketOptions::class); + GPBUtil::checkMessage($var, \Google\Api\Distribution\BucketOptions::class); $this->bucket_options = $var; return $this; @@ -546,19 +567,29 @@ public function setBucketOptions($var) * Output only. The creation timestamp of the metric. * This field may not be present for older metrics. * - * Generated from protobuf field .google.protobuf.Timestamp create_time = 9; - * @return \Google\Protobuf\Timestamp + * Generated from protobuf field .google.protobuf.Timestamp create_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null */ public function getCreateTime() { return $this->create_time; } + public function hasCreateTime() + { + return isset($this->create_time); + } + + public function clearCreateTime() + { + unset($this->create_time); + } + /** * Output only. The creation timestamp of the metric. * This field may not be present for older metrics. * - * Generated from protobuf field .google.protobuf.Timestamp create_time = 9; + * Generated from protobuf field .google.protobuf.Timestamp create_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @param \Google\Protobuf\Timestamp $var * @return $this */ @@ -574,19 +605,29 @@ public function setCreateTime($var) * Output only. The last update timestamp of the metric. * This field may not be present for older metrics. * - * Generated from protobuf field .google.protobuf.Timestamp update_time = 10; - * @return \Google\Protobuf\Timestamp + * Generated from protobuf field .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null */ public function getUpdateTime() { return $this->update_time; } + public function hasUpdateTime() + { + return isset($this->update_time); + } + + public function clearUpdateTime() + { + unset($this->update_time); + } + /** * Output only. The last update timestamp of the metric. * This field may not be present for older metrics. * - * Generated from protobuf field .google.protobuf.Timestamp update_time = 10; + * Generated from protobuf field .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @param \Google\Protobuf\Timestamp $var * @return $this */ @@ -604,9 +645,11 @@ public function setUpdateTime($var) * * Generated from protobuf field .google.logging.v2.LogMetric.ApiVersion version = 4 [deprecated = true]; * @return int + * @deprecated */ public function getVersion() { + @trigger_error('version is deprecated.', E_USER_DEPRECATED); return $this->version; } @@ -617,10 +660,12 @@ public function getVersion() * Generated from protobuf field .google.logging.v2.LogMetric.ApiVersion version = 4 [deprecated = true]; * @param int $var * @return $this + * @deprecated */ public function setVersion($var) { - GPBUtil::checkEnum($var, \Google\Cloud\Logging\V2\LogMetric_ApiVersion::class); + @trigger_error('version is deprecated.', E_USER_DEPRECATED); + GPBUtil::checkEnum($var, \Google\Cloud\Logging\V2\LogMetric\ApiVersion::class); $this->version = $var; return $this; diff --git a/Logging/src/V2/LogSink.php b/Logging/src/V2/LogSink.php index c0037e877c42..18c48f08649f 100644 --- a/Logging/src/V2/LogSink.php +++ b/Logging/src/V2/LogSink.php @@ -20,13 +20,13 @@ class LogSink extends \Google\Protobuf\Internal\Message { /** - * 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. + * 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. * - * Generated from protobuf field string name = 1; + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ private $name = ''; /** @@ -37,53 +37,61 @@ class LogSink extends \Google\Protobuf\Internal\Message * 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). + * [Exporting Logs with + * Sinks](https://cloud.google.com/logging/docs/api/tasks/exporting-logs). * - * Generated from protobuf field string destination = 3 [(.google.api.resource_reference) = { + * Generated from protobuf field string destination = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ private $destination = ''; /** - * 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: + * Optional. An [advanced logs + * filter](https://cloud.google.com/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 * - * Generated from protobuf field string filter = 5; + * Generated from protobuf field string filter = 5 [(.google.api.field_behavior) = OPTIONAL]; */ private $filter = ''; /** * Optional. A description of this sink. * The maximum length of the description is 8000 characters. * - * Generated from protobuf field string description = 18; + * Generated from protobuf field string description = 18 [(.google.api.field_behavior) = OPTIONAL]; */ private $description = ''; /** * Optional. If set to True, then this sink is disabled and it does not * export any log entries. * - * Generated from protobuf field bool disabled = 19; + * Generated from protobuf field bool disabled = 19 [(.google.api.field_behavior) = OPTIONAL]; */ private $disabled = false; /** - * 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. + * Optional. Log entries that match any of the exclusion filters will not be exported. + * If a log entry is matched by both `filter` and one of `exclusion_filters` + * it will not be exported. + * + * Generated from protobuf field repeated .google.logging.v2.LogExclusion exclusions = 16 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $exclusions; + /** + * Deprecated. This field is unused. * * Generated from protobuf field .google.logging.v2.LogSink.VersionFormat output_version_format = 6 [deprecated = true]; + * @deprecated */ - private $output_version_format = 0; + protected $output_version_format = 0; /** - * 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. + * 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). + * Resource](https://cloud.google.com/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. * @@ -104,7 +112,7 @@ class LogSink extends \Google\Protobuf\Internal\Message * logName:("projects/test-project1/" OR "projects/test-project2/") AND * resource.type=gce_instance * - * Generated from protobuf field bool include_children = 9; + * Generated from protobuf field bool include_children = 9 [(.google.api.field_behavior) = OPTIONAL]; */ private $include_children = false; /** @@ -121,18 +129,6 @@ class LogSink extends \Google\Protobuf\Internal\Message * Generated from protobuf field .google.protobuf.Timestamp update_time = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ private $update_time = null; - /** - * Do not use. This field is ignored. - * - * Generated from protobuf field .google.protobuf.Timestamp start_time = 10 [deprecated = true]; - */ - private $start_time = null; - /** - * Do not use. This field is ignored. - * - * Generated from protobuf field .google.protobuf.Timestamp end_time = 11 [deprecated = true]; - */ - private $end_time = null; protected $options; /** @@ -142,11 +138,11 @@ class LogSink extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $name - * 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. + * 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. * @type string $destination * Required. The export destination: * "storage.googleapis.com/[GCS_BUCKET]" @@ -155,11 +151,13 @@ class LogSink extends \Google\Protobuf\Internal\Message * 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). + * [Exporting Logs with + * Sinks](https://cloud.google.com/logging/docs/api/tasks/exporting-logs). * @type string $filter - * 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: + * Optional. An [advanced logs + * filter](https://cloud.google.com/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 * @type string $description * Optional. A description of this sink. @@ -167,21 +165,22 @@ class LogSink extends \Google\Protobuf\Internal\Message * @type bool $disabled * Optional. If set to True, then this sink is disabled and it does not * export any log entries. + * @type \Google\Cloud\Logging\V2\LogExclusion[]|\Google\Protobuf\Internal\RepeatedField $exclusions + * Optional. Log entries that match any of the exclusion filters will not be exported. + * If a log entry is matched by both `filter` and one of `exclusion_filters` + * it will not be exported. * @type int $output_version_format - * 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. + * Deprecated. This field is unused. * @type string $writer_identity - * 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. + * 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). + * Resource](https://cloud.google.com/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. * @type bool $include_children @@ -205,10 +204,6 @@ class LogSink extends \Google\Protobuf\Internal\Message * @type \Google\Protobuf\Timestamp $update_time * Output only. The last update timestamp of the sink. * This field may not be present for older sinks. - * @type \Google\Protobuf\Timestamp $start_time - * Do not use. This field is ignored. - * @type \Google\Protobuf\Timestamp $end_time - * Do not use. This field is ignored. * } */ public function __construct($data = NULL) { @@ -217,13 +212,13 @@ public function __construct($data = NULL) { } /** - * 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. + * 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. * - * Generated from protobuf field string name = 1; + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; * @return string */ public function getName() @@ -232,13 +227,13 @@ public function getName() } /** - * 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. + * 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. * - * Generated from protobuf field string name = 1; + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; * @param string $var * @return $this */ @@ -258,9 +253,10 @@ public function setName($var) * 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). + * [Exporting Logs with + * Sinks](https://cloud.google.com/logging/docs/api/tasks/exporting-logs). * - * Generated from protobuf field string destination = 3 [(.google.api.resource_reference) = { + * Generated from protobuf field string destination = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @return string */ public function getDestination() @@ -276,9 +272,10 @@ public function getDestination() * 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). + * [Exporting Logs with + * Sinks](https://cloud.google.com/logging/docs/api/tasks/exporting-logs). * - * Generated from protobuf field string destination = 3 [(.google.api.resource_reference) = { + * Generated from protobuf field string destination = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @param string $var * @return $this */ @@ -291,12 +288,13 @@ public function setDestination($var) } /** - * 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: + * Optional. An [advanced logs + * filter](https://cloud.google.com/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 * - * Generated from protobuf field string filter = 5; + * Generated from protobuf field string filter = 5 [(.google.api.field_behavior) = OPTIONAL]; * @return string */ public function getFilter() @@ -305,12 +303,13 @@ public function getFilter() } /** - * 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: + * Optional. An [advanced logs + * filter](https://cloud.google.com/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 * - * Generated from protobuf field string filter = 5; + * Generated from protobuf field string filter = 5 [(.google.api.field_behavior) = OPTIONAL]; * @param string $var * @return $this */ @@ -326,7 +325,7 @@ public function setFilter($var) * Optional. A description of this sink. * The maximum length of the description is 8000 characters. * - * Generated from protobuf field string description = 18; + * Generated from protobuf field string description = 18 [(.google.api.field_behavior) = OPTIONAL]; * @return string */ public function getDescription() @@ -338,7 +337,7 @@ public function getDescription() * Optional. A description of this sink. * The maximum length of the description is 8000 characters. * - * Generated from protobuf field string description = 18; + * Generated from protobuf field string description = 18 [(.google.api.field_behavior) = OPTIONAL]; * @param string $var * @return $this */ @@ -354,7 +353,7 @@ public function setDescription($var) * Optional. If set to True, then this sink is disabled and it does not * export any log entries. * - * Generated from protobuf field bool disabled = 19; + * Generated from protobuf field bool disabled = 19 [(.google.api.field_behavior) = OPTIONAL]; * @return bool */ public function getDisabled() @@ -366,7 +365,7 @@ public function getDisabled() * Optional. If set to True, then this sink is disabled and it does not * export any log entries. * - * Generated from protobuf field bool disabled = 19; + * Generated from protobuf field bool disabled = 19 [(.google.api.field_behavior) = OPTIONAL]; * @param bool $var * @return $this */ @@ -379,45 +378,75 @@ public function setDisabled($var) } /** - * 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. + * Optional. Log entries that match any of the exclusion filters will not be exported. + * If a log entry is matched by both `filter` and one of `exclusion_filters` + * it will not be exported. + * + * Generated from protobuf field repeated .google.logging.v2.LogExclusion exclusions = 16 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getExclusions() + { + return $this->exclusions; + } + + /** + * Optional. Log entries that match any of the exclusion filters will not be exported. + * If a log entry is matched by both `filter` and one of `exclusion_filters` + * it will not be exported. + * + * Generated from protobuf field repeated .google.logging.v2.LogExclusion exclusions = 16 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Logging\V2\LogExclusion[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setExclusions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Logging\V2\LogExclusion::class); + $this->exclusions = $arr; + + return $this; + } + + /** + * Deprecated. This field is unused. * * Generated from protobuf field .google.logging.v2.LogSink.VersionFormat output_version_format = 6 [deprecated = true]; * @return int + * @deprecated */ public function getOutputVersionFormat() { + @trigger_error('output_version_format is deprecated.', E_USER_DEPRECATED); return $this->output_version_format; } /** - * 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. + * Deprecated. This field is unused. * * Generated from protobuf field .google.logging.v2.LogSink.VersionFormat output_version_format = 6 [deprecated = true]; * @param int $var * @return $this + * @deprecated */ public function setOutputVersionFormat($var) { - GPBUtil::checkEnum($var, \Google\Cloud\Logging\V2\LogSink_VersionFormat::class); + @trigger_error('output_version_format is deprecated.', E_USER_DEPRECATED); + GPBUtil::checkEnum($var, \Google\Cloud\Logging\V2\LogSink\VersionFormat::class); $this->output_version_format = $var; return $this; } /** - * 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. + * 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). + * Resource](https://cloud.google.com/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. * @@ -430,17 +459,15 @@ public function getWriterIdentity() } /** - * 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. + * 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). + * Resource](https://cloud.google.com/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. * @@ -470,7 +497,7 @@ public function setWriterIdentity($var) * logName:("projects/test-project1/" OR "projects/test-project2/") AND * resource.type=gce_instance * - * Generated from protobuf field bool include_children = 9; + * Generated from protobuf field bool include_children = 9 [(.google.api.field_behavior) = OPTIONAL]; * @return bool */ public function getIncludeChildren() @@ -492,7 +519,7 @@ public function getIncludeChildren() * logName:("projects/test-project1/" OR "projects/test-project2/") AND * resource.type=gce_instance * - * Generated from protobuf field bool include_children = 9; + * Generated from protobuf field bool include_children = 9 [(.google.api.field_behavior) = OPTIONAL]; * @param bool $var * @return $this */ @@ -507,18 +534,23 @@ public function setIncludeChildren($var) /** * Optional. Options that affect sinks exporting data to BigQuery. * - * Generated from protobuf field .google.logging.v2.BigQueryOptions bigquery_options = 12; - * @return \Google\Cloud\Logging\V2\BigQueryOptions + * Generated from protobuf field .google.logging.v2.BigQueryOptions bigquery_options = 12 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Logging\V2\BigQueryOptions|null */ public function getBigqueryOptions() { return $this->readOneof(12); } + public function hasBigqueryOptions() + { + return $this->hasOneof(12); + } + /** * Optional. Options that affect sinks exporting data to BigQuery. * - * Generated from protobuf field .google.logging.v2.BigQueryOptions bigquery_options = 12; + * Generated from protobuf field .google.logging.v2.BigQueryOptions bigquery_options = 12 [(.google.api.field_behavior) = OPTIONAL]; * @param \Google\Cloud\Logging\V2\BigQueryOptions $var * @return $this */ @@ -535,13 +567,23 @@ public function setBigqueryOptions($var) * This field may not be present for older sinks. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 13 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @return \Google\Protobuf\Timestamp + * @return \Google\Protobuf\Timestamp|null */ public function getCreateTime() { return $this->create_time; } + public function hasCreateTime() + { + return isset($this->create_time); + } + + public function clearCreateTime() + { + unset($this->create_time); + } + /** * Output only. The creation timestamp of the sink. * This field may not be present for older sinks. @@ -563,77 +605,35 @@ public function setCreateTime($var) * This field may not be present for older sinks. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @return \Google\Protobuf\Timestamp + * @return \Google\Protobuf\Timestamp|null */ public function getUpdateTime() { return $this->update_time; } - /** - * Output only. The last update timestamp of the sink. - * This field may not be present for older sinks. - * - * Generated from protobuf field .google.protobuf.Timestamp update_time = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @param \Google\Protobuf\Timestamp $var - * @return $this - */ - public function setUpdateTime($var) + public function hasUpdateTime() { - GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); - $this->update_time = $var; - - return $this; + return isset($this->update_time); } - /** - * Do not use. This field is ignored. - * - * Generated from protobuf field .google.protobuf.Timestamp start_time = 10 [deprecated = true]; - * @return \Google\Protobuf\Timestamp - */ - public function getStartTime() + public function clearUpdateTime() { - return $this->start_time; + unset($this->update_time); } /** - * Do not use. This field is ignored. - * - * Generated from protobuf field .google.protobuf.Timestamp start_time = 10 [deprecated = true]; - * @param \Google\Protobuf\Timestamp $var - * @return $this - */ - public function setStartTime($var) - { - GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); - $this->start_time = $var; - - return $this; - } - - /** - * Do not use. This field is ignored. - * - * Generated from protobuf field .google.protobuf.Timestamp end_time = 11 [deprecated = true]; - * @return \Google\Protobuf\Timestamp - */ - public function getEndTime() - { - return $this->end_time; - } - - /** - * Do not use. This field is ignored. + * Output only. The last update timestamp of the sink. + * This field may not be present for older sinks. * - * Generated from protobuf field .google.protobuf.Timestamp end_time = 11 [deprecated = true]; + * Generated from protobuf field .google.protobuf.Timestamp update_time = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @param \Google\Protobuf\Timestamp $var * @return $this */ - public function setEndTime($var) + public function setUpdateTime($var) { GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); - $this->end_time = $var; + $this->update_time = $var; return $this; } diff --git a/Logging/src/V2/LogSink/VersionFormat.php b/Logging/src/V2/LogSink/VersionFormat.php index 395e608f3fb8..4cdb89f2b82d 100644 --- a/Logging/src/V2/LogSink/VersionFormat.php +++ b/Logging/src/V2/LogSink/VersionFormat.php @@ -7,9 +7,7 @@ use UnexpectedValueException; /** - * 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. + * Deprecated. This is unused. * * Protobuf type google.logging.v2.LogSink.VersionFormat */ diff --git a/Logging/src/V2/LogView.php b/Logging/src/V2/LogView.php new file mode 100644 index 000000000000..6031c7c0da4b --- /dev/null +++ b/Logging/src/V2/LogView.php @@ -0,0 +1,259 @@ +google.logging.v2.LogView + */ +class LogView extends \Google\Protobuf\Internal\Message +{ + /** + * The resource name of the view. + * For example + * "projects/my-project-id/locations/my-location/buckets/my-bucket-id/views/my-view + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + /** + * Describes this view. + * + * Generated from protobuf field string description = 3; + */ + private $description = ''; + /** + * Output only. The creation timestamp of the view. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $create_time = null; + /** + * Output only. The last update timestamp of the view. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $update_time = null; + /** + * Filter that restricts which log entries in a bucket are visible in this + * view. Filters are restricted to be a logical AND of ==/!= of any of the + * following: + * originating project/folder/organization/billing account. + * resource type + * log id + * Example: SOURCE("projects/myproject") AND resource.type = "gce_instance" + * AND LOG_ID("stdout") + * + * Generated from protobuf field string filter = 7; + */ + private $filter = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * The resource name of the view. + * For example + * "projects/my-project-id/locations/my-location/buckets/my-bucket-id/views/my-view + * @type string $description + * Describes this view. + * @type \Google\Protobuf\Timestamp $create_time + * Output only. The creation timestamp of the view. + * @type \Google\Protobuf\Timestamp $update_time + * Output only. The last update timestamp of the view. + * @type string $filter + * Filter that restricts which log entries in a bucket are visible in this + * view. Filters are restricted to be a logical AND of ==/!= of any of the + * following: + * originating project/folder/organization/billing account. + * resource type + * log id + * Example: SOURCE("projects/myproject") AND resource.type = "gce_instance" + * AND LOG_ID("stdout") + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Logging\V2\LoggingConfig::initOnce(); + parent::__construct($data); + } + + /** + * The resource name of the view. + * For example + * "projects/my-project-id/locations/my-location/buckets/my-bucket-id/views/my-view + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * The resource name of the view. + * For example + * "projects/my-project-id/locations/my-location/buckets/my-bucket-id/views/my-view + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Describes this view. + * + * Generated from protobuf field string description = 3; + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Describes this view. + * + * Generated from protobuf field string description = 3; + * @param string $var + * @return $this + */ + public function setDescription($var) + { + GPBUtil::checkString($var, True); + $this->description = $var; + + return $this; + } + + /** + * Output only. The creation timestamp of the view. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCreateTime() + { + return $this->create_time; + } + + public function hasCreateTime() + { + return isset($this->create_time); + } + + public function clearCreateTime() + { + unset($this->create_time); + } + + /** + * Output only. The creation timestamp of the view. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Output only. The last update timestamp of the view. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getUpdateTime() + { + return $this->update_time; + } + + public function hasUpdateTime() + { + return isset($this->update_time); + } + + public function clearUpdateTime() + { + unset($this->update_time); + } + + /** + * Output only. The last update timestamp of the view. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setUpdateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->update_time = $var; + + return $this; + } + + /** + * Filter that restricts which log entries in a bucket are visible in this + * view. Filters are restricted to be a logical AND of ==/!= of any of the + * following: + * originating project/folder/organization/billing account. + * resource type + * log id + * Example: SOURCE("projects/myproject") AND resource.type = "gce_instance" + * AND LOG_ID("stdout") + * + * Generated from protobuf field string filter = 7; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * Filter that restricts which log entries in a bucket are visible in this + * view. Filters are restricted to be a logical AND of ==/!= of any of the + * following: + * originating project/folder/organization/billing account. + * resource type + * log id + * Example: SOURCE("projects/myproject") AND resource.type = "gce_instance" + * AND LOG_ID("stdout") + * + * Generated from protobuf field string filter = 7; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + +} + diff --git a/Logging/src/V2/LoggingServiceV2Client.php b/Logging/src/V2/LoggingServiceV2Client.php index 9b13ce5eede9..c8cea6a8175e 100644 --- a/Logging/src/V2/LoggingServiceV2Client.php +++ b/Logging/src/V2/LoggingServiceV2Client.php @@ -17,22 +17,18 @@ /* * GENERATED CODE WARNING - * This file was generated from the file - * https://github.com/google/googleapis/blob/master/google/logging/v2/logging.proto - * and updates to that file get reflected here through a refresh process. - * - * @experimental + * Generated by gapic-generator-php from the file + * https://github.com/googleapis/googleapis/blob/master/google/logging/v2/logging.proto + * Updates to the above are reflected here through a refresh process. */ namespace Google\Cloud\Logging\V2; use Google\Cloud\Logging\V2\Gapic\LoggingServiceV2GapicClient; -/** - * {@inheritdoc} - */ +/** {@inheritdoc} */ class LoggingServiceV2Client extends LoggingServiceV2GapicClient { - // This class is intentionally empty, and is intended to hold manual - // additions to the generated {@see LoggingServiceV2GapicClient} class. + // This class is intentionally empty, and is intended to hold manual additions to + // the generated {@see LoggingServiceV2GapicClient} class. } diff --git a/Logging/src/V2/LoggingServiceV2GrpcClient.php b/Logging/src/V2/LoggingServiceV2GrpcClient.php index 30e52c07566c..7717356aeb68 100644 --- a/Logging/src/V2/LoggingServiceV2GrpcClient.php +++ b/Logging/src/V2/LoggingServiceV2GrpcClient.php @@ -2,7 +2,7 @@ // GENERATED CODE -- DO NOT EDIT! // Original file comments: -// Copyright 2019 Google LLC. +// 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. @@ -16,7 +16,6 @@ // See the License for the specific language governing permissions and // limitations under the License. // -// namespace Google\Cloud\Logging\V2; /** @@ -41,6 +40,7 @@ public function __construct($hostname, $opts, $channel = null) { * @param \Google\Cloud\Logging\V2\DeleteLogRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function DeleteLog(\Google\Cloud\Logging\V2\DeleteLogRequest $argument, $metadata = [], $options = []) { @@ -61,6 +61,7 @@ public function DeleteLog(\Google\Cloud\Logging\V2\DeleteLogRequest $argument, * @param \Google\Cloud\Logging\V2\WriteLogEntriesRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function WriteLogEntries(\Google\Cloud\Logging\V2\WriteLogEntriesRequest $argument, $metadata = [], $options = []) { @@ -73,10 +74,12 @@ public function WriteLogEntries(\Google\Cloud\Logging\V2\WriteLogEntriesRequest /** * 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). + * entries, see [Exporting + * Logs](https://cloud.google.com/logging/docs/export). * @param \Google\Cloud\Logging\V2\ListLogEntriesRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function ListLogEntries(\Google\Cloud\Logging\V2\ListLogEntriesRequest $argument, $metadata = [], $options = []) { @@ -91,6 +94,7 @@ public function ListLogEntries(\Google\Cloud\Logging\V2\ListLogEntriesRequest $a * @param \Google\Cloud\Logging\V2\ListMonitoredResourceDescriptorsRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function ListMonitoredResourceDescriptors(\Google\Cloud\Logging\V2\ListMonitoredResourceDescriptorsRequest $argument, $metadata = [], $options = []) { @@ -106,6 +110,7 @@ public function ListMonitoredResourceDescriptors(\Google\Cloud\Logging\V2\ListMo * @param \Google\Cloud\Logging\V2\ListLogsRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function ListLogs(\Google\Cloud\Logging\V2\ListLogsRequest $argument, $metadata = [], $options = []) { @@ -115,4 +120,17 @@ public function ListLogs(\Google\Cloud\Logging\V2\ListLogsRequest $argument, $metadata, $options); } + /** + * Streaming read of log entries as they are ingested. Until the stream is + * terminated, it will continue reading logs. + * @param array $metadata metadata + * @param array $options call options + * @return \Grpc\BidiStreamingCall + */ + public function TailLogEntries($metadata = [], $options = []) { + return $this->_bidiRequest('/google.logging.v2.LoggingServiceV2/TailLogEntries', + ['\Google\Cloud\Logging\V2\TailLogEntriesResponse','decode'], + $metadata, $options); + } + } diff --git a/Logging/src/V2/MetricsServiceV2Client.php b/Logging/src/V2/MetricsServiceV2Client.php index b41bd904b238..62a99b5242a0 100644 --- a/Logging/src/V2/MetricsServiceV2Client.php +++ b/Logging/src/V2/MetricsServiceV2Client.php @@ -17,22 +17,18 @@ /* * GENERATED CODE WARNING - * This file was generated from the file - * https://github.com/google/googleapis/blob/master/google/logging/v2/logging_metrics.proto - * and updates to that file get reflected here through a refresh process. - * - * @experimental + * Generated by gapic-generator-php from the file + * https://github.com/googleapis/googleapis/blob/master/google/logging/v2/logging_metrics.proto + * Updates to the above are reflected here through a refresh process. */ namespace Google\Cloud\Logging\V2; use Google\Cloud\Logging\V2\Gapic\MetricsServiceV2GapicClient; -/** - * {@inheritdoc} - */ +/** {@inheritdoc} */ class MetricsServiceV2Client extends MetricsServiceV2GapicClient { - // This class is intentionally empty, and is intended to hold manual - // additions to the generated {@see MetricsServiceV2GapicClient} class. + // This class is intentionally empty, and is intended to hold manual additions to + // the generated {@see MetricsServiceV2GapicClient} class. } diff --git a/Logging/src/V2/MetricsServiceV2GrpcClient.php b/Logging/src/V2/MetricsServiceV2GrpcClient.php index 340159946a51..8e769461868e 100644 --- a/Logging/src/V2/MetricsServiceV2GrpcClient.php +++ b/Logging/src/V2/MetricsServiceV2GrpcClient.php @@ -2,7 +2,7 @@ // GENERATED CODE -- DO NOT EDIT! // Original file comments: -// Copyright 2019 Google LLC. +// 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. @@ -16,7 +16,6 @@ // See the License for the specific language governing permissions and // limitations under the License. // -// namespace Google\Cloud\Logging\V2; /** @@ -38,6 +37,7 @@ public function __construct($hostname, $opts, $channel = null) { * @param \Google\Cloud\Logging\V2\ListLogMetricsRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function ListLogMetrics(\Google\Cloud\Logging\V2\ListLogMetricsRequest $argument, $metadata = [], $options = []) { @@ -52,6 +52,7 @@ public function ListLogMetrics(\Google\Cloud\Logging\V2\ListLogMetricsRequest $a * @param \Google\Cloud\Logging\V2\GetLogMetricRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function GetLogMetric(\Google\Cloud\Logging\V2\GetLogMetricRequest $argument, $metadata = [], $options = []) { @@ -66,6 +67,7 @@ public function GetLogMetric(\Google\Cloud\Logging\V2\GetLogMetricRequest $argum * @param \Google\Cloud\Logging\V2\CreateLogMetricRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function CreateLogMetric(\Google\Cloud\Logging\V2\CreateLogMetricRequest $argument, $metadata = [], $options = []) { @@ -80,6 +82,7 @@ public function CreateLogMetric(\Google\Cloud\Logging\V2\CreateLogMetricRequest * @param \Google\Cloud\Logging\V2\UpdateLogMetricRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function UpdateLogMetric(\Google\Cloud\Logging\V2\UpdateLogMetricRequest $argument, $metadata = [], $options = []) { @@ -94,6 +97,7 @@ public function UpdateLogMetric(\Google\Cloud\Logging\V2\UpdateLogMetricRequest * @param \Google\Cloud\Logging\V2\DeleteLogMetricRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function DeleteLogMetric(\Google\Cloud\Logging\V2\DeleteLogMetricRequest $argument, $metadata = [], $options = []) { diff --git a/Logging/src/V2/TailLogEntriesRequest.php b/Logging/src/V2/TailLogEntriesRequest.php new file mode 100644 index 000000000000..527b22ff27ba --- /dev/null +++ b/Logging/src/V2/TailLogEntriesRequest.php @@ -0,0 +1,217 @@ +google.logging.v2.TailLogEntriesRequest + */ +class TailLogEntriesRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Name of a parent resource from which to retrieve log entries: + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * May alternatively be one or more views: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * "organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * + * Generated from protobuf field repeated string resource_names = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + private $resource_names; + /** + * Optional. A filter that chooses which log entries to return. See [Advanced + * Logs Filters](https://cloud.google.com/logging/docs/view/advanced_filters). + * 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 in `resource_names` will cause + * the filter to return no results. The maximum length of the filter is 20000 + * characters. + * + * Generated from protobuf field string filter = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $filter = ''; + /** + * Optional. The amount of time to buffer log entries at the server before + * being returned to prevent out of order results due to late arriving log + * entries. Valid values are between 0-60000 milliseconds. Defaults to 2000 + * milliseconds. + * + * Generated from protobuf field .google.protobuf.Duration buffer_window = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $buffer_window = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string[]|\Google\Protobuf\Internal\RepeatedField $resource_names + * Required. Name of a parent resource from which to retrieve log entries: + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * May alternatively be one or more views: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * "organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * @type string $filter + * Optional. A filter that chooses which log entries to return. See [Advanced + * Logs Filters](https://cloud.google.com/logging/docs/view/advanced_filters). + * 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 in `resource_names` will cause + * the filter to return no results. The maximum length of the filter is 20000 + * characters. + * @type \Google\Protobuf\Duration $buffer_window + * Optional. The amount of time to buffer log entries at the server before + * being returned to prevent out of order results due to late arriving log + * entries. Valid values are between 0-60000 milliseconds. Defaults to 2000 + * milliseconds. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Logging\V2\Logging::initOnce(); + parent::__construct($data); + } + + /** + * Required. Name of a parent resource from which to retrieve log entries: + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * May alternatively be one or more views: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * "organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * + * Generated from protobuf field repeated string resource_names = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getResourceNames() + { + return $this->resource_names; + } + + /** + * Required. Name of a parent resource from which to retrieve log entries: + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * May alternatively be one or more views: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * "organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * + * Generated from protobuf field repeated string resource_names = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setResourceNames($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->resource_names = $arr; + + return $this; + } + + /** + * Optional. A filter that chooses which log entries to return. See [Advanced + * Logs Filters](https://cloud.google.com/logging/docs/view/advanced_filters). + * 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 in `resource_names` will cause + * the filter to return no results. The maximum length of the filter is 20000 + * characters. + * + * Generated from protobuf field string filter = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * Optional. A filter that chooses which log entries to return. See [Advanced + * Logs Filters](https://cloud.google.com/logging/docs/view/advanced_filters). + * 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 in `resource_names` will cause + * the filter to return no results. The maximum length of the filter is 20000 + * characters. + * + * Generated from protobuf field string filter = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + + /** + * Optional. The amount of time to buffer log entries at the server before + * being returned to prevent out of order results due to late arriving log + * entries. Valid values are between 0-60000 milliseconds. Defaults to 2000 + * milliseconds. + * + * Generated from protobuf field .google.protobuf.Duration buffer_window = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Duration|null + */ + public function getBufferWindow() + { + return $this->buffer_window; + } + + public function hasBufferWindow() + { + return isset($this->buffer_window); + } + + public function clearBufferWindow() + { + unset($this->buffer_window); + } + + /** + * Optional. The amount of time to buffer log entries at the server before + * being returned to prevent out of order results due to late arriving log + * entries. Valid values are between 0-60000 milliseconds. Defaults to 2000 + * milliseconds. + * + * Generated from protobuf field .google.protobuf.Duration buffer_window = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Protobuf\Duration $var + * @return $this + */ + public function setBufferWindow($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class); + $this->buffer_window = $var; + + return $this; + } + +} + diff --git a/Logging/src/V2/TailLogEntriesResponse.php b/Logging/src/V2/TailLogEntriesResponse.php new file mode 100644 index 000000000000..518cb8b84ede --- /dev/null +++ b/Logging/src/V2/TailLogEntriesResponse.php @@ -0,0 +1,125 @@ +google.logging.v2.TailLogEntriesResponse + */ +class TailLogEntriesResponse extends \Google\Protobuf\Internal\Message +{ + /** + * A list of log entries. Each response in the stream will order entries with + * increasing values of `LogEntry.timestamp`. Ordering is not guaranteed + * between separate responses. + * + * Generated from protobuf field repeated .google.logging.v2.LogEntry entries = 1; + */ + private $entries; + /** + * If entries that otherwise would have been included in the session were not + * sent back to the client, counts of relevant entries omitted from the + * session with the reason that they were not included. There will be at most + * one of each reason per response. The counts represent the number of + * suppressed entries since the last streamed response. + * + * Generated from protobuf field repeated .google.logging.v2.TailLogEntriesResponse.SuppressionInfo suppression_info = 2; + */ + private $suppression_info; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Logging\V2\LogEntry[]|\Google\Protobuf\Internal\RepeatedField $entries + * A list of log entries. Each response in the stream will order entries with + * increasing values of `LogEntry.timestamp`. Ordering is not guaranteed + * between separate responses. + * @type \Google\Cloud\Logging\V2\TailLogEntriesResponse\SuppressionInfo[]|\Google\Protobuf\Internal\RepeatedField $suppression_info + * If entries that otherwise would have been included in the session were not + * sent back to the client, counts of relevant entries omitted from the + * session with the reason that they were not included. There will be at most + * one of each reason per response. The counts represent the number of + * suppressed entries since the last streamed response. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Logging\V2\Logging::initOnce(); + parent::__construct($data); + } + + /** + * A list of log entries. Each response in the stream will order entries with + * increasing values of `LogEntry.timestamp`. Ordering is not guaranteed + * between separate responses. + * + * Generated from protobuf field repeated .google.logging.v2.LogEntry entries = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getEntries() + { + return $this->entries; + } + + /** + * A list of log entries. Each response in the stream will order entries with + * increasing values of `LogEntry.timestamp`. Ordering is not guaranteed + * between separate responses. + * + * Generated from protobuf field repeated .google.logging.v2.LogEntry entries = 1; + * @param \Google\Cloud\Logging\V2\LogEntry[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setEntries($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Logging\V2\LogEntry::class); + $this->entries = $arr; + + return $this; + } + + /** + * If entries that otherwise would have been included in the session were not + * sent back to the client, counts of relevant entries omitted from the + * session with the reason that they were not included. There will be at most + * one of each reason per response. The counts represent the number of + * suppressed entries since the last streamed response. + * + * Generated from protobuf field repeated .google.logging.v2.TailLogEntriesResponse.SuppressionInfo suppression_info = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getSuppressionInfo() + { + return $this->suppression_info; + } + + /** + * If entries that otherwise would have been included in the session were not + * sent back to the client, counts of relevant entries omitted from the + * session with the reason that they were not included. There will be at most + * one of each reason per response. The counts represent the number of + * suppressed entries since the last streamed response. + * + * Generated from protobuf field repeated .google.logging.v2.TailLogEntriesResponse.SuppressionInfo suppression_info = 2; + * @param \Google\Cloud\Logging\V2\TailLogEntriesResponse\SuppressionInfo[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setSuppressionInfo($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Logging\V2\TailLogEntriesResponse\SuppressionInfo::class); + $this->suppression_info = $arr; + + return $this; + } + +} + diff --git a/Logging/src/V2/TailLogEntriesResponse/SuppressionInfo.php b/Logging/src/V2/TailLogEntriesResponse/SuppressionInfo.php new file mode 100644 index 000000000000..6f87cd26e7f2 --- /dev/null +++ b/Logging/src/V2/TailLogEntriesResponse/SuppressionInfo.php @@ -0,0 +1,104 @@ +google.logging.v2.TailLogEntriesResponse.SuppressionInfo + */ +class SuppressionInfo extends \Google\Protobuf\Internal\Message +{ + /** + * The reason that entries were omitted from the session. + * + * Generated from protobuf field .google.logging.v2.TailLogEntriesResponse.SuppressionInfo.Reason reason = 1; + */ + private $reason = 0; + /** + * A lower bound on the count of entries omitted due to `reason`. + * + * Generated from protobuf field int32 suppressed_count = 2; + */ + private $suppressed_count = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $reason + * The reason that entries were omitted from the session. + * @type int $suppressed_count + * A lower bound on the count of entries omitted due to `reason`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Logging\V2\Logging::initOnce(); + parent::__construct($data); + } + + /** + * The reason that entries were omitted from the session. + * + * Generated from protobuf field .google.logging.v2.TailLogEntriesResponse.SuppressionInfo.Reason reason = 1; + * @return int + */ + public function getReason() + { + return $this->reason; + } + + /** + * The reason that entries were omitted from the session. + * + * Generated from protobuf field .google.logging.v2.TailLogEntriesResponse.SuppressionInfo.Reason reason = 1; + * @param int $var + * @return $this + */ + public function setReason($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Logging\V2\TailLogEntriesResponse\SuppressionInfo\Reason::class); + $this->reason = $var; + + return $this; + } + + /** + * A lower bound on the count of entries omitted due to `reason`. + * + * Generated from protobuf field int32 suppressed_count = 2; + * @return int + */ + public function getSuppressedCount() + { + return $this->suppressed_count; + } + + /** + * A lower bound on the count of entries omitted due to `reason`. + * + * Generated from protobuf field int32 suppressed_count = 2; + * @param int $var + * @return $this + */ + public function setSuppressedCount($var) + { + GPBUtil::checkInt32($var); + $this->suppressed_count = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(SuppressionInfo::class, \Google\Cloud\Logging\V2\TailLogEntriesResponse_SuppressionInfo::class); + diff --git a/Logging/src/V2/TailLogEntriesResponse/SuppressionInfo/Reason.php b/Logging/src/V2/TailLogEntriesResponse/SuppressionInfo/Reason.php new file mode 100644 index 000000000000..a626cf2f1b84 --- /dev/null +++ b/Logging/src/V2/TailLogEntriesResponse/SuppressionInfo/Reason.php @@ -0,0 +1,68 @@ +google.logging.v2.TailLogEntriesResponse.SuppressionInfo.Reason + */ +class Reason +{ + /** + * Unexpected default. + * + * Generated from protobuf enum REASON_UNSPECIFIED = 0; + */ + const REASON_UNSPECIFIED = 0; + /** + * Indicates suppression occurred due to relevant entries being + * received in excess of rate limits. For quotas and limits, see + * [Logging API quotas and + * limits](https://cloud.google.com/logging/quotas#api-limits). + * + * Generated from protobuf enum RATE_LIMIT = 1; + */ + const RATE_LIMIT = 1; + /** + * Indicates suppression occurred due to the client not consuming + * responses quickly enough. + * + * Generated from protobuf enum NOT_CONSUMED = 2; + */ + const NOT_CONSUMED = 2; + + private static $valueToName = [ + self::REASON_UNSPECIFIED => 'REASON_UNSPECIFIED', + self::RATE_LIMIT => 'RATE_LIMIT', + self::NOT_CONSUMED => 'NOT_CONSUMED', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Reason::class, \Google\Cloud\Logging\V2\TailLogEntriesResponse_SuppressionInfo_Reason::class); + diff --git a/Logging/src/V2/TailLogEntriesResponse_SuppressionInfo.php b/Logging/src/V2/TailLogEntriesResponse_SuppressionInfo.php new file mode 100644 index 000000000000..d3e4b91ac857 --- /dev/null +++ b/Logging/src/V2/TailLogEntriesResponse_SuppressionInfo.php @@ -0,0 +1,16 @@ +google.logging.v2.UndeleteBucketRequest + */ +class UndeleteBucketRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The full resource name of the bucket to undelete. + * "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"`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The full resource name of the bucket to undelete. + * "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"`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Logging\V2\LoggingConfig::initOnce(); + parent::__construct($data); + } + + /** + * Required. The full resource name of the bucket to undelete. + * "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"`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. The full resource name of the bucket to undelete. + * "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"`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/Logging/src/V2/UpdateBucketRequest.php b/Logging/src/V2/UpdateBucketRequest.php new file mode 100644 index 000000000000..780c932fde1a --- /dev/null +++ b/Logging/src/V2/UpdateBucketRequest.php @@ -0,0 +1,207 @@ +google.logging.v2.UpdateBucketRequest + */ +class UpdateBucketRequest extends \Google\Protobuf\Internal\Message +{ + /** + * 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 + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + /** + * Required. The updated bucket. + * + * Generated from protobuf field .google.logging.v2.LogBucket bucket = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $bucket = null; + /** + * 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`. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 4 [(.google.api.field_behavior) = REQUIRED]; + */ + private $update_mask = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $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 + * @type \Google\Cloud\Logging\V2\LogBucket $bucket + * Required. The updated bucket. + * @type \Google\Protobuf\FieldMask $update_mask + * 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`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Logging\V2\LoggingConfig::initOnce(); + parent::__construct($data); + } + + /** + * 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 + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->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 + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Required. The updated bucket. + * + * Generated from protobuf field .google.logging.v2.LogBucket bucket = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Logging\V2\LogBucket|null + */ + public function getBucket() + { + return $this->bucket; + } + + public function hasBucket() + { + return isset($this->bucket); + } + + public function clearBucket() + { + unset($this->bucket); + } + + /** + * Required. The updated bucket. + * + * Generated from protobuf field .google.logging.v2.LogBucket bucket = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Logging\V2\LogBucket $var + * @return $this + */ + public function setBucket($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Logging\V2\LogBucket::class); + $this->bucket = $var; + + return $this; + } + + /** + * 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`. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 4 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Protobuf\FieldMask|null + */ + public function getUpdateMask() + { + return $this->update_mask; + } + + public function hasUpdateMask() + { + return isset($this->update_mask); + } + + public function clearUpdateMask() + { + unset($this->update_mask); + } + + /** + * 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`. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 4 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Protobuf\FieldMask $var + * @return $this + */ + public function setUpdateMask($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); + $this->update_mask = $var; + + return $this; + } + +} + diff --git a/Logging/src/V2/UpdateCmekSettingsRequest.php b/Logging/src/V2/UpdateCmekSettingsRequest.php index 7d69b2e4772e..21c760997c13 100644 --- a/Logging/src/V2/UpdateCmekSettingsRequest.php +++ b/Logging/src/V2/UpdateCmekSettingsRequest.php @@ -11,8 +11,9 @@ /** * The parameters to * [UpdateCmekSettings][google.logging.v2.ConfigServiceV2.UpdateCmekSettings]. - * See [Enabling CMEK for Logs Router](/logging/docs/routing/managed-encryption) - * for more information. + * See [Enabling CMEK for Logs + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) for + * more information. * * Generated from protobuf message google.logging.v2.UpdateCmekSettingsRequest */ @@ -29,15 +30,16 @@ class UpdateCmekSettingsRequest extends \Google\Protobuf\Internal\Message * organizations. Once configured, it applies to all projects and folders in * the GCP organization. * - * Generated from protobuf field string name = 1; + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ private $name = ''; /** * Required. The CMEK settings to update. * See [Enabling CMEK for Logs - * Router](/logging/docs/routing/managed-encryption) for more information. + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. * - * Generated from protobuf field .google.logging.v2.CmekSettings cmek_settings = 2; + * Generated from protobuf field .google.logging.v2.CmekSettings cmek_settings = 2 [(.google.api.field_behavior) = REQUIRED]; */ private $cmek_settings = null; /** @@ -47,7 +49,7 @@ class UpdateCmekSettingsRequest extends \Google\Protobuf\Internal\Message * See [FieldMask][google.protobuf.FieldMask] for more information. * Example: `"updateMask=kmsKeyName"` * - * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3; + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = OPTIONAL]; */ private $update_mask = null; @@ -70,7 +72,8 @@ class UpdateCmekSettingsRequest extends \Google\Protobuf\Internal\Message * @type \Google\Cloud\Logging\V2\CmekSettings $cmek_settings * Required. The CMEK settings to update. * See [Enabling CMEK for Logs - * Router](/logging/docs/routing/managed-encryption) for more information. + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. * @type \Google\Protobuf\FieldMask $update_mask * 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 @@ -95,7 +98,7 @@ public function __construct($data = NULL) { * organizations. Once configured, it applies to all projects and folders in * the GCP organization. * - * Generated from protobuf field string name = 1; + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; * @return string */ public function getName() @@ -114,7 +117,7 @@ public function getName() * organizations. Once configured, it applies to all projects and folders in * the GCP organization. * - * Generated from protobuf field string name = 1; + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; * @param string $var * @return $this */ @@ -129,22 +132,34 @@ public function setName($var) /** * Required. The CMEK settings to update. * See [Enabling CMEK for Logs - * Router](/logging/docs/routing/managed-encryption) for more information. + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. * - * Generated from protobuf field .google.logging.v2.CmekSettings cmek_settings = 2; - * @return \Google\Cloud\Logging\V2\CmekSettings + * Generated from protobuf field .google.logging.v2.CmekSettings cmek_settings = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Logging\V2\CmekSettings|null */ public function getCmekSettings() { return $this->cmek_settings; } + public function hasCmekSettings() + { + return isset($this->cmek_settings); + } + + public function clearCmekSettings() + { + unset($this->cmek_settings); + } + /** * Required. The CMEK settings to update. * See [Enabling CMEK for Logs - * Router](/logging/docs/routing/managed-encryption) for more information. + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. * - * Generated from protobuf field .google.logging.v2.CmekSettings cmek_settings = 2; + * Generated from protobuf field .google.logging.v2.CmekSettings cmek_settings = 2 [(.google.api.field_behavior) = REQUIRED]; * @param \Google\Cloud\Logging\V2\CmekSettings $var * @return $this */ @@ -163,14 +178,24 @@ public function setCmekSettings($var) * See [FieldMask][google.protobuf.FieldMask] for more information. * Example: `"updateMask=kmsKeyName"` * - * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3; - * @return \Google\Protobuf\FieldMask + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\FieldMask|null */ public function getUpdateMask() { return $this->update_mask; } + public function hasUpdateMask() + { + return isset($this->update_mask); + } + + public function clearUpdateMask() + { + unset($this->update_mask); + } + /** * 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 @@ -178,7 +203,7 @@ public function getUpdateMask() * See [FieldMask][google.protobuf.FieldMask] for more information. * Example: `"updateMask=kmsKeyName"` * - * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3; + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = OPTIONAL]; * @param \Google\Protobuf\FieldMask $var * @return $this */ diff --git a/Logging/src/V2/UpdateExclusionRequest.php b/Logging/src/V2/UpdateExclusionRequest.php index fc457494fefe..ddd90a73dc12 100644 --- a/Logging/src/V2/UpdateExclusionRequest.php +++ b/Logging/src/V2/UpdateExclusionRequest.php @@ -27,15 +27,15 @@ class UpdateExclusionRequest extends \Google\Protobuf\Internal\Message */ private $name = ''; /** - * Required. New values for the existing exclusion. Only the fields specified - * in `update_mask` are relevant. + * Required. New values for the existing exclusion. Only the fields specified in + * `update_mask` are relevant. * * Generated from protobuf field .google.logging.v2.LogExclusion exclusion = 2 [(.google.api.field_behavior) = REQUIRED]; */ private $exclusion = null; /** - * 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 + * 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 * [LogExclusion][google.logging.v2.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, @@ -59,11 +59,11 @@ class UpdateExclusionRequest extends \Google\Protobuf\Internal\Message * "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" * Example: `"projects/my-project-id/exclusions/my-exclusion-id"`. * @type \Google\Cloud\Logging\V2\LogExclusion $exclusion - * Required. New values for the existing exclusion. Only the fields specified - * in `update_mask` are relevant. + * Required. New values for the existing exclusion. Only the fields specified in + * `update_mask` are relevant. * @type \Google\Protobuf\FieldMask $update_mask - * 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 + * 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 * [LogExclusion][google.logging.v2.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, @@ -112,20 +112,30 @@ public function setName($var) } /** - * Required. New values for the existing exclusion. Only the fields specified - * in `update_mask` are relevant. + * Required. New values for the existing exclusion. Only the fields specified in + * `update_mask` are relevant. * * Generated from protobuf field .google.logging.v2.LogExclusion exclusion = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Logging\V2\LogExclusion + * @return \Google\Cloud\Logging\V2\LogExclusion|null */ public function getExclusion() { return $this->exclusion; } + public function hasExclusion() + { + return isset($this->exclusion); + } + + public function clearExclusion() + { + unset($this->exclusion); + } + /** - * Required. New values for the existing exclusion. Only the fields specified - * in `update_mask` are relevant. + * Required. New values for the existing exclusion. Only the fields specified in + * `update_mask` are relevant. * * Generated from protobuf field .google.logging.v2.LogExclusion exclusion = 2 [(.google.api.field_behavior) = REQUIRED]; * @param \Google\Cloud\Logging\V2\LogExclusion $var @@ -140,24 +150,34 @@ public function setExclusion($var) } /** - * 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 + * 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 * [LogExclusion][google.logging.v2.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"`. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Protobuf\FieldMask + * @return \Google\Protobuf\FieldMask|null */ public function getUpdateMask() { return $this->update_mask; } + public function hasUpdateMask() + { + return isset($this->update_mask); + } + + public function clearUpdateMask() + { + unset($this->update_mask); + } + /** - * 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 + * 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 * [LogExclusion][google.logging.v2.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, diff --git a/Logging/src/V2/UpdateLogMetricRequest.php b/Logging/src/V2/UpdateLogMetricRequest.php index 4c997876e97d..7b6d63edea5a 100644 --- a/Logging/src/V2/UpdateLogMetricRequest.php +++ b/Logging/src/V2/UpdateLogMetricRequest.php @@ -91,13 +91,23 @@ public function setMetricName($var) * Required. The updated metric. * * Generated from protobuf field .google.logging.v2.LogMetric metric = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Logging\V2\LogMetric + * @return \Google\Cloud\Logging\V2\LogMetric|null */ public function getMetric() { return $this->metric; } + public function hasMetric() + { + return isset($this->metric); + } + + public function clearMetric() + { + unset($this->metric); + } + /** * Required. The updated metric. * diff --git a/Logging/src/V2/UpdateSinkRequest.php b/Logging/src/V2/UpdateSinkRequest.php index 0b81d9555bf0..b054e7a68b04 100644 --- a/Logging/src/V2/UpdateSinkRequest.php +++ b/Logging/src/V2/UpdateSinkRequest.php @@ -16,8 +16,8 @@ class UpdateSinkRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The full resource name of the sink to update, including the - * parent resource and the sink identifier: + * 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]" @@ -28,8 +28,8 @@ class UpdateSinkRequest extends \Google\Protobuf\Internal\Message */ private $sink_name = ''; /** - * Required. The updated sink, whose name is the same identifier that appears - * as part of `sink_name`. + * Required. The updated sink, whose name is the same identifier that appears as part + * of `sink_name`. * * Generated from protobuf field .google.logging.v2.LogSink sink = 2 [(.google.api.field_behavior) = REQUIRED]; */ @@ -46,7 +46,7 @@ class UpdateSinkRequest extends \Google\Protobuf\Internal\Message * + It is an error if the old value is true and the new value is * set to false or defaulted to false. * - * Generated from protobuf field bool unique_writer_identity = 3; + * Generated from protobuf field bool unique_writer_identity = 3 [(.google.api.field_behavior) = OPTIONAL]; */ private $unique_writer_identity = false; /** @@ -62,7 +62,7 @@ class UpdateSinkRequest extends \Google\Protobuf\Internal\Message * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask * Example: `updateMask=filter`. * - * Generated from protobuf field .google.protobuf.FieldMask update_mask = 4; + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 4 [(.google.api.field_behavior) = OPTIONAL]; */ private $update_mask = null; @@ -73,16 +73,16 @@ class UpdateSinkRequest extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $sink_name - * Required. The full resource name of the sink to update, including the - * parent resource and the sink identifier: + * 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"`. * @type \Google\Cloud\Logging\V2\LogSink $sink - * Required. The updated sink, whose name is the same identifier that appears - * as part of `sink_name`. + * Required. The updated sink, whose name is the same identifier that appears as part + * of `sink_name`. * @type bool $unique_writer_identity * Optional. See [sinks.create][google.logging.v2.ConfigServiceV2.CreateSink] * for a description of this field. When updating a sink, the effect of this @@ -114,8 +114,8 @@ public function __construct($data = NULL) { } /** - * Required. The full resource name of the sink to update, including the - * parent resource and the sink identifier: + * 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]" @@ -131,8 +131,8 @@ public function getSinkName() } /** - * Required. The full resource name of the sink to update, including the - * parent resource and the sink identifier: + * 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]" @@ -152,20 +152,30 @@ public function setSinkName($var) } /** - * Required. The updated sink, whose name is the same identifier that appears - * as part of `sink_name`. + * Required. The updated sink, whose name is the same identifier that appears as part + * of `sink_name`. * * Generated from protobuf field .google.logging.v2.LogSink sink = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Logging\V2\LogSink + * @return \Google\Cloud\Logging\V2\LogSink|null */ public function getSink() { return $this->sink; } + public function hasSink() + { + return isset($this->sink); + } + + public function clearSink() + { + unset($this->sink); + } + /** - * Required. The updated sink, whose name is the same identifier that appears - * as part of `sink_name`. + * Required. The updated sink, whose name is the same identifier that appears as part + * of `sink_name`. * * Generated from protobuf field .google.logging.v2.LogSink sink = 2 [(.google.api.field_behavior) = REQUIRED]; * @param \Google\Cloud\Logging\V2\LogSink $var @@ -191,7 +201,7 @@ public function setSink($var) * + It is an error if the old value is true and the new value is * set to false or defaulted to false. * - * Generated from protobuf field bool unique_writer_identity = 3; + * Generated from protobuf field bool unique_writer_identity = 3 [(.google.api.field_behavior) = OPTIONAL]; * @return bool */ public function getUniqueWriterIdentity() @@ -211,7 +221,7 @@ public function getUniqueWriterIdentity() * + It is an error if the old value is true and the new value is * set to false or defaulted to false. * - * Generated from protobuf field bool unique_writer_identity = 3; + * Generated from protobuf field bool unique_writer_identity = 3 [(.google.api.field_behavior) = OPTIONAL]; * @param bool $var * @return $this */ @@ -236,14 +246,24 @@ public function setUniqueWriterIdentity($var) * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask * Example: `updateMask=filter`. * - * Generated from protobuf field .google.protobuf.FieldMask update_mask = 4; - * @return \Google\Protobuf\FieldMask + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\FieldMask|null */ public function getUpdateMask() { return $this->update_mask; } + public function hasUpdateMask() + { + return isset($this->update_mask); + } + + public function clearUpdateMask() + { + unset($this->update_mask); + } + /** * 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 @@ -257,7 +277,7 @@ public function getUpdateMask() * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask * Example: `updateMask=filter`. * - * Generated from protobuf field .google.protobuf.FieldMask update_mask = 4; + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 4 [(.google.api.field_behavior) = OPTIONAL]; * @param \Google\Protobuf\FieldMask $var * @return $this */ diff --git a/Logging/src/V2/UpdateViewRequest.php b/Logging/src/V2/UpdateViewRequest.php new file mode 100644 index 000000000000..bf6e95441e21 --- /dev/null +++ b/Logging/src/V2/UpdateViewRequest.php @@ -0,0 +1,187 @@ +google.logging.v2.UpdateViewRequest + */ +class UpdateViewRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The full resource name of the view to update + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * Example: + * `"projects/my-project-id/locations/my-location/buckets/my-bucket-id/views/my-view-id"`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + private $name = ''; + /** + * Required. The updated view. + * + * Generated from protobuf field .google.logging.v2.LogView view = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $view = null; + /** + * Optional. Field mask that specifies the fields in `view` that need + * an update. A 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=filter`. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 4 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $update_mask = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The full resource name of the view to update + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * Example: + * `"projects/my-project-id/locations/my-location/buckets/my-bucket-id/views/my-view-id"`. + * @type \Google\Cloud\Logging\V2\LogView $view + * Required. The updated view. + * @type \Google\Protobuf\FieldMask $update_mask + * Optional. Field mask that specifies the fields in `view` that need + * an update. A 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=filter`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Logging\V2\LoggingConfig::initOnce(); + parent::__construct($data); + } + + /** + * Required. The full resource name of the view to update + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * Example: + * `"projects/my-project-id/locations/my-location/buckets/my-bucket-id/views/my-view-id"`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. The full resource name of the view to update + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * Example: + * `"projects/my-project-id/locations/my-location/buckets/my-bucket-id/views/my-view-id"`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Required. The updated view. + * + * Generated from protobuf field .google.logging.v2.LogView view = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Logging\V2\LogView|null + */ + public function getView() + { + return $this->view; + } + + public function hasView() + { + return isset($this->view); + } + + public function clearView() + { + unset($this->view); + } + + /** + * Required. The updated view. + * + * Generated from protobuf field .google.logging.v2.LogView view = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Logging\V2\LogView $var + * @return $this + */ + public function setView($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Logging\V2\LogView::class); + $this->view = $var; + + return $this; + } + + /** + * Optional. Field mask that specifies the fields in `view` that need + * an update. A 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=filter`. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\FieldMask|null + */ + public function getUpdateMask() + { + return $this->update_mask; + } + + public function hasUpdateMask() + { + return isset($this->update_mask); + } + + public function clearUpdateMask() + { + unset($this->update_mask); + } + + /** + * Optional. Field mask that specifies the fields in `view` that need + * an update. A 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=filter`. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Protobuf\FieldMask $var + * @return $this + */ + public function setUpdateMask($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); + $this->update_mask = $var; + + return $this; + } + +} + diff --git a/Logging/src/V2/WriteLogEntriesRequest.php b/Logging/src/V2/WriteLogEntriesRequest.php index b1ef13630447..5114d61ddfae 100644 --- a/Logging/src/V2/WriteLogEntriesRequest.php +++ b/Logging/src/V2/WriteLogEntriesRequest.php @@ -25,12 +25,12 @@ class WriteLogEntriesRequest extends \Google\Protobuf\Internal\Message * `[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. + * 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. * - * Generated from protobuf field string log_name = 1 [(.google.api.resource_reference) = { + * Generated from protobuf field string log_name = 1 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { */ private $log_name = ''; /** @@ -41,7 +41,7 @@ class WriteLogEntriesRequest extends \Google\Protobuf\Internal\Message * "zone": "us-central1-a", "instance_id": "00000000000000000000" }} * See [LogEntry][google.logging.v2.LogEntry]. * - * Generated from protobuf field .google.api.MonitoredResource resource = 2; + * Generated from protobuf field .google.api.MonitoredResource resource = 2 [(.google.api.field_behavior) = OPTIONAL]; */ private $resource = null; /** @@ -50,7 +50,7 @@ class WriteLogEntriesRequest extends \Google\Protobuf\Internal\Message * as a label in this parameter, then the log entry's label is not changed. * See [LogEntry][google.logging.v2.LogEntry]. * - * Generated from protobuf field map labels = 3; + * Generated from protobuf field map labels = 3 [(.google.api.field_behavior) = OPTIONAL]; */ private $labels; /** @@ -66,14 +66,15 @@ class WriteLogEntriesRequest extends \Google\Protobuf\Internal\Message * 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). + * [logs retention period](https://cloud.google.com/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](https://cloud.google.com/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. + * [quota limit](https://cloud.google.com/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. * * Generated from protobuf field repeated .google.logging.v2.LogEntry entries = 4 [(.google.api.field_behavior) = REQUIRED]; */ @@ -85,7 +86,7 @@ class WriteLogEntriesRequest extends \Google\Protobuf\Internal\Message * with one of the failed entries and the response includes error details * keyed by the entries' zero-based index in the `entries.write` method. * - * Generated from protobuf field bool partial_success = 5; + * Generated from protobuf field bool partial_success = 5 [(.google.api.field_behavior) = OPTIONAL]; */ private $partial_success = false; /** @@ -93,7 +94,7 @@ class WriteLogEntriesRequest extends \Google\Protobuf\Internal\Message * entries won't be persisted nor exported. Useful for checking whether the * logging API endpoints are working properly before sending valuable data. * - * Generated from protobuf field bool dry_run = 6; + * Generated from protobuf field bool dry_run = 6 [(.google.api.field_behavior) = OPTIONAL]; */ private $dry_run = false; @@ -113,10 +114,10 @@ class WriteLogEntriesRequest extends \Google\Protobuf\Internal\Message * `[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. + * 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. * @type \Google\Api\MonitoredResource $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: @@ -142,14 +143,15 @@ class WriteLogEntriesRequest extends \Google\Protobuf\Internal\Message * 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). + * [logs retention period](https://cloud.google.com/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](https://cloud.google.com/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. + * [quota limit](https://cloud.google.com/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. * @type bool $partial_success * Optional. Whether valid entries should be written even if some other * entries fail due to INVALID_ARGUMENT or PERMISSION_DENIED errors. If any @@ -177,12 +179,12 @@ public function __construct($data = NULL) { * `[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. + * 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. * - * Generated from protobuf field string log_name = 1 [(.google.api.resource_reference) = { + * Generated from protobuf field string log_name = 1 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { * @return string */ public function getLogName() @@ -200,12 +202,12 @@ public function getLogName() * `[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. + * 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. * - * Generated from protobuf field string log_name = 1 [(.google.api.resource_reference) = { + * Generated from protobuf field string log_name = 1 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { * @param string $var * @return $this */ @@ -225,14 +227,24 @@ public function setLogName($var) * "zone": "us-central1-a", "instance_id": "00000000000000000000" }} * See [LogEntry][google.logging.v2.LogEntry]. * - * Generated from protobuf field .google.api.MonitoredResource resource = 2; - * @return \Google\Api\MonitoredResource + * Generated from protobuf field .google.api.MonitoredResource resource = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Api\MonitoredResource|null */ public function getResource() { return $this->resource; } + public function hasResource() + { + return isset($this->resource); + } + + public function clearResource() + { + unset($this->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: @@ -241,7 +253,7 @@ public function getResource() * "zone": "us-central1-a", "instance_id": "00000000000000000000" }} * See [LogEntry][google.logging.v2.LogEntry]. * - * Generated from protobuf field .google.api.MonitoredResource resource = 2; + * Generated from protobuf field .google.api.MonitoredResource resource = 2 [(.google.api.field_behavior) = OPTIONAL]; * @param \Google\Api\MonitoredResource $var * @return $this */ @@ -259,7 +271,7 @@ public function setResource($var) * as a label in this parameter, then the log entry's label is not changed. * See [LogEntry][google.logging.v2.LogEntry]. * - * Generated from protobuf field map labels = 3; + * Generated from protobuf field map labels = 3 [(.google.api.field_behavior) = OPTIONAL]; * @return \Google\Protobuf\Internal\MapField */ public function getLabels() @@ -273,7 +285,7 @@ public function getLabels() * as a label in this parameter, then the log entry's label is not changed. * See [LogEntry][google.logging.v2.LogEntry]. * - * Generated from protobuf field map labels = 3; + * Generated from protobuf field map labels = 3 [(.google.api.field_behavior) = OPTIONAL]; * @param array|\Google\Protobuf\Internal\MapField $var * @return $this */ @@ -298,14 +310,15 @@ public function setLabels($var) * 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). + * [logs retention period](https://cloud.google.com/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](https://cloud.google.com/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. + * [quota limit](https://cloud.google.com/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. * * Generated from protobuf field repeated .google.logging.v2.LogEntry entries = 4 [(.google.api.field_behavior) = REQUIRED]; * @return \Google\Protobuf\Internal\RepeatedField @@ -328,14 +341,15 @@ public function getEntries() * 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). + * [logs retention period](https://cloud.google.com/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](https://cloud.google.com/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. + * [quota limit](https://cloud.google.com/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. * * Generated from protobuf field repeated .google.logging.v2.LogEntry entries = 4 [(.google.api.field_behavior) = REQUIRED]; * @param \Google\Cloud\Logging\V2\LogEntry[]|\Google\Protobuf\Internal\RepeatedField $var @@ -356,7 +370,7 @@ public function setEntries($var) * with one of the failed entries and the response includes error details * keyed by the entries' zero-based index in the `entries.write` method. * - * Generated from protobuf field bool partial_success = 5; + * Generated from protobuf field bool partial_success = 5 [(.google.api.field_behavior) = OPTIONAL]; * @return bool */ public function getPartialSuccess() @@ -371,7 +385,7 @@ public function getPartialSuccess() * with one of the failed entries and the response includes error details * keyed by the entries' zero-based index in the `entries.write` method. * - * Generated from protobuf field bool partial_success = 5; + * Generated from protobuf field bool partial_success = 5 [(.google.api.field_behavior) = OPTIONAL]; * @param bool $var * @return $this */ @@ -388,7 +402,7 @@ public function setPartialSuccess($var) * entries won't be persisted nor exported. Useful for checking whether the * logging API endpoints are working properly before sending valuable data. * - * Generated from protobuf field bool dry_run = 6; + * Generated from protobuf field bool dry_run = 6 [(.google.api.field_behavior) = OPTIONAL]; * @return bool */ public function getDryRun() @@ -401,7 +415,7 @@ public function getDryRun() * entries won't be persisted nor exported. Useful for checking whether the * logging API endpoints are working properly before sending valuable data. * - * Generated from protobuf field bool dry_run = 6; + * Generated from protobuf field bool dry_run = 6 [(.google.api.field_behavior) = OPTIONAL]; * @param bool $var * @return $this */ diff --git a/Logging/src/V2/WriteLogEntriesResponse.php b/Logging/src/V2/WriteLogEntriesResponse.php index 1d8931c59a67..006dcaf82055 100644 --- a/Logging/src/V2/WriteLogEntriesResponse.php +++ b/Logging/src/V2/WriteLogEntriesResponse.php @@ -10,7 +10,6 @@ /** * Result returned from WriteLogEntries. - * empty * * Generated from protobuf message google.logging.v2.WriteLogEntriesResponse */ diff --git a/Logging/src/V2/gapic_metadata.json b/Logging/src/V2/gapic_metadata.json new file mode 100644 index 000000000000..d8b1144e08ca --- /dev/null +++ b/Logging/src/V2/gapic_metadata.json @@ -0,0 +1,206 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services\/RPCs to the corresponding library clients\/methods", + "language": "php", + "protoPackage": "google.logging.v2", + "libraryPackage": "Google\\Cloud\\Logging\\V2", + "services": { + "ConfigServiceV2": { + "clients": { + "grpc": { + "libraryClient": "ConfigServiceV2GapicClient", + "rpcs": { + "CreateBucket": { + "methods": [ + "createBucket" + ] + }, + "CreateExclusion": { + "methods": [ + "createExclusion" + ] + }, + "CreateSink": { + "methods": [ + "createSink" + ] + }, + "CreateView": { + "methods": [ + "createView" + ] + }, + "DeleteBucket": { + "methods": [ + "deleteBucket" + ] + }, + "DeleteExclusion": { + "methods": [ + "deleteExclusion" + ] + }, + "DeleteSink": { + "methods": [ + "deleteSink" + ] + }, + "DeleteView": { + "methods": [ + "deleteView" + ] + }, + "GetBucket": { + "methods": [ + "getBucket" + ] + }, + "GetCmekSettings": { + "methods": [ + "getCmekSettings" + ] + }, + "GetExclusion": { + "methods": [ + "getExclusion" + ] + }, + "GetSink": { + "methods": [ + "getSink" + ] + }, + "GetView": { + "methods": [ + "getView" + ] + }, + "ListBuckets": { + "methods": [ + "listBuckets" + ] + }, + "ListExclusions": { + "methods": [ + "listExclusions" + ] + }, + "ListSinks": { + "methods": [ + "listSinks" + ] + }, + "ListViews": { + "methods": [ + "listViews" + ] + }, + "UndeleteBucket": { + "methods": [ + "undeleteBucket" + ] + }, + "UpdateBucket": { + "methods": [ + "updateBucket" + ] + }, + "UpdateCmekSettings": { + "methods": [ + "updateCmekSettings" + ] + }, + "UpdateExclusion": { + "methods": [ + "updateExclusion" + ] + }, + "UpdateSink": { + "methods": [ + "updateSink" + ] + }, + "UpdateView": { + "methods": [ + "updateView" + ] + } + } + } + } + }, + "LoggingServiceV2": { + "clients": { + "grpc": { + "libraryClient": "LoggingServiceV2GapicClient", + "rpcs": { + "DeleteLog": { + "methods": [ + "deleteLog" + ] + }, + "ListLogEntries": { + "methods": [ + "listLogEntries" + ] + }, + "ListLogs": { + "methods": [ + "listLogs" + ] + }, + "ListMonitoredResourceDescriptors": { + "methods": [ + "listMonitoredResourceDescriptors" + ] + }, + "TailLogEntries": { + "methods": [ + "tailLogEntries" + ] + }, + "WriteLogEntries": { + "methods": [ + "writeLogEntries" + ] + } + } + } + } + }, + "MetricsServiceV2": { + "clients": { + "grpc": { + "libraryClient": "MetricsServiceV2GapicClient", + "rpcs": { + "CreateLogMetric": { + "methods": [ + "createLogMetric" + ] + }, + "DeleteLogMetric": { + "methods": [ + "deleteLogMetric" + ] + }, + "GetLogMetric": { + "methods": [ + "getLogMetric" + ] + }, + "ListLogMetrics": { + "methods": [ + "listLogMetrics" + ] + }, + "UpdateLogMetric": { + "methods": [ + "updateLogMetric" + ] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/Logging/src/V2/resources/config_service_v2_client_config.json b/Logging/src/V2/resources/config_service_v2_client_config.json index 00582c9d6cbc..d66d2c58ac77 100644 --- a/Logging/src/V2/resources/config_service_v2_client_config.json +++ b/Logging/src/V2/resources/config_service_v2_client_config.json @@ -1,100 +1,161 @@ { - "interfaces": { - "google.logging.v2.ConfigServiceV2": { - "retry_codes": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "INTERNAL", - "UNAVAILABLE" - ], - "non_idempotent": [], - "idempotent2": [ - "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": 20000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 20000, - "total_timeout_millis": 600000 - }, - "write_sink": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 20000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 20000, - "total_timeout_millis": 600000 + "interfaces": { + "google.logging.v2.ConfigServiceV2": { + "retry_codes": { + "no_retry_codes": [], + "retry_policy_3_codes": [ + "DEADLINE_EXCEEDED", + "INTERNAL", + "UNAVAILABLE" + ], + "no_retry_2_codes": [] + }, + "retry_params": { + "no_retry_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 0, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 0, + "total_timeout_millis": 0 + }, + "retry_policy_3_params": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 60000 + }, + "no_retry_2_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 120000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 120000, + "total_timeout_millis": 120000 + } + }, + "methods": { + "CreateBucket": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "CreateExclusion": { + "timeout_millis": 120000, + "retry_codes_name": "no_retry_2_codes", + "retry_params_name": "no_retry_2_params" + }, + "CreateSink": { + "timeout_millis": 120000, + "retry_codes_name": "no_retry_2_codes", + "retry_params_name": "no_retry_2_params" + }, + "CreateView": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "DeleteBucket": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "DeleteExclusion": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_3_codes", + "retry_params_name": "retry_policy_3_params" + }, + "DeleteSink": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_3_codes", + "retry_params_name": "retry_policy_3_params" + }, + "DeleteView": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "GetBucket": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "GetCmekSettings": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "GetExclusion": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_3_codes", + "retry_params_name": "retry_policy_3_params" + }, + "GetSink": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_3_codes", + "retry_params_name": "retry_policy_3_params" + }, + "GetView": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "ListBuckets": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "ListExclusions": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_3_codes", + "retry_params_name": "retry_policy_3_params" + }, + "ListSinks": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_3_codes", + "retry_params_name": "retry_policy_3_params" + }, + "ListViews": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "UndeleteBucket": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "UpdateBucket": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "UpdateCmekSettings": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "UpdateExclusion": { + "timeout_millis": 120000, + "retry_codes_name": "no_retry_2_codes", + "retry_params_name": "no_retry_2_params" + }, + "UpdateSink": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_3_codes", + "retry_params_name": "retry_policy_3_params" + }, + "UpdateView": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + } + } } - }, - "methods": { - "ListSinks": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetSink": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateSink": { - "timeout_millis": 120000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateSink": { - "timeout_millis": 120000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "DeleteSink": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListExclusions": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetExclusion": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateExclusion": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateExclusion": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteExclusion": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetCmekSettings": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent2", - "retry_params_name": "default" - }, - "UpdateCmekSettings": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } } - } } diff --git a/Logging/src/V2/resources/config_service_v2_descriptor_config.php b/Logging/src/V2/resources/config_service_v2_descriptor_config.php index 50d373e7da02..31f1041f23e6 100644 --- a/Logging/src/V2/resources/config_service_v2_descriptor_config.php +++ b/Logging/src/V2/resources/config_service_v2_descriptor_config.php @@ -3,14 +3,14 @@ return [ 'interfaces' => [ 'google.logging.v2.ConfigServiceV2' => [ - 'ListSinks' => [ + 'ListBuckets' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', 'requestPageSizeGetMethod' => 'getPageSize', 'requestPageSizeSetMethod' => 'setPageSize', 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getSinks', + 'resourcesGetMethod' => 'getBuckets', ], ], 'ListExclusions' => [ @@ -23,6 +23,26 @@ 'resourcesGetMethod' => 'getExclusions', ], ], + 'ListSinks' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getSinks', + ], + ], + 'ListViews' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getViews', + ], + ], ], ], ]; diff --git a/Logging/src/V2/resources/config_service_v2_rest_client_config.php b/Logging/src/V2/resources/config_service_v2_rest_client_config.php index 93286d1dccc4..1324d4486115 100644 --- a/Logging/src/V2/resources/config_service_v2_rest_client_config.php +++ b/Logging/src/V2/resources/config_service_v2_rest_client_config.php @@ -3,25 +3,42 @@ return [ 'interfaces' => [ 'google.logging.v2.ConfigServiceV2' => [ - 'ListSinks' => [ - 'method' => 'get', - 'uriTemplate' => '/v2/{parent=*/*}/sinks', + 'CreateBucket' => [ + 'method' => 'post', + 'uriTemplate' => '/v2/{parent=*/*/locations/*}/buckets', + 'body' => 'bucket', 'additionalBindings' => [ [ - 'method' => 'get', - 'uriTemplate' => '/v2/{parent=projects/*}/sinks', + 'method' => 'post', + 'uriTemplate' => '/v2/{parent=projects/*/locations/*}/buckets', + 'body' => 'bucket', + 'queryParams' => [ + 'bucket_id', + ], ], [ - 'method' => 'get', - 'uriTemplate' => '/v2/{parent=organizations/*}/sinks', + 'method' => 'post', + 'uriTemplate' => '/v2/{parent=organizations/*/locations/*}/buckets', + 'body' => 'bucket', + 'queryParams' => [ + 'bucket_id', + ], ], [ - 'method' => 'get', - 'uriTemplate' => '/v2/{parent=folders/*}/sinks', + 'method' => 'post', + 'uriTemplate' => '/v2/{parent=folders/*/locations/*}/buckets', + 'body' => 'bucket', + 'queryParams' => [ + 'bucket_id', + ], ], [ - 'method' => 'get', - 'uriTemplate' => '/v2/{parent=billingAccounts/*}/sinks', + 'method' => 'post', + 'uriTemplate' => '/v2/{parent=billingAccounts/*/locations/*}/buckets', + 'body' => 'bucket', + 'queryParams' => [ + 'bucket_id', + ], ], ], 'placeholders' => [ @@ -31,32 +48,40 @@ ], ], ], + 'queryParams' => [ + 'bucket_id', + ], ], - 'GetSink' => [ - 'method' => 'get', - 'uriTemplate' => '/v2/{sink_name=*/*/sinks/*}', + 'CreateExclusion' => [ + 'method' => 'post', + 'uriTemplate' => '/v2/{parent=*/*}/exclusions', + 'body' => 'exclusion', 'additionalBindings' => [ [ - 'method' => 'get', - 'uriTemplate' => '/v2/{sink_name=projects/*/sinks/*}', + 'method' => 'post', + 'uriTemplate' => '/v2/{parent=projects/*}/exclusions', + 'body' => 'exclusion', ], [ - 'method' => 'get', - 'uriTemplate' => '/v2/{sink_name=organizations/*/sinks/*}', + 'method' => 'post', + 'uriTemplate' => '/v2/{parent=organizations/*}/exclusions', + 'body' => 'exclusion', ], [ - 'method' => 'get', - 'uriTemplate' => '/v2/{sink_name=folders/*/sinks/*}', + 'method' => 'post', + 'uriTemplate' => '/v2/{parent=folders/*}/exclusions', + 'body' => 'exclusion', ], [ - 'method' => 'get', - 'uriTemplate' => '/v2/{sink_name=billingAccounts/*/sinks/*}', + 'method' => 'post', + 'uriTemplate' => '/v2/{parent=billingAccounts/*}/exclusions', + 'body' => 'exclusion', ], ], 'placeholders' => [ - 'sink_name' => [ + 'parent' => [ 'getters' => [ - 'getSinkName', + 'getParent', ], ], ], @@ -95,56 +120,109 @@ ], ], ], - 'UpdateSink' => [ - 'method' => 'put', - 'uriTemplate' => '/v2/{sink_name=*/*/sinks/*}', - 'body' => 'sink', + 'CreateView' => [ + 'method' => 'post', + 'uriTemplate' => '/v2/{parent=*/*/locations/*/buckets/*}/views', + 'body' => 'view', 'additionalBindings' => [ [ - 'method' => 'put', - 'uriTemplate' => '/v2/{sink_name=projects/*/sinks/*}', - 'body' => 'sink', + 'method' => 'post', + 'uriTemplate' => '/v2/{parent=projects/*/locations/*/buckets/*}/views', + 'body' => 'view', + 'queryParams' => [ + 'view_id', + ], ], [ - 'method' => 'put', - 'uriTemplate' => '/v2/{sink_name=organizations/*/sinks/*}', - 'body' => 'sink', + 'method' => 'post', + 'uriTemplate' => '/v2/{parent=organizations/*/locations/*/buckets/*}/views', + 'body' => 'view', + 'queryParams' => [ + 'view_id', + ], ], [ - 'method' => 'put', - 'uriTemplate' => '/v2/{sink_name=folders/*/sinks/*}', - 'body' => 'sink', + 'method' => 'post', + 'uriTemplate' => '/v2/{parent=folders/*/locations/*/buckets/*}/views', + 'body' => 'view', + 'queryParams' => [ + 'view_id', + ], ], [ - 'method' => 'put', - 'uriTemplate' => '/v2/{sink_name=billingAccounts/*/sinks/*}', - 'body' => 'sink', + 'method' => 'post', + 'uriTemplate' => '/v2/{parent=billingAccounts/*/locations/*/buckets/*}/views', + 'body' => 'view', + 'queryParams' => [ + 'view_id', + ], ], + ], + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + 'queryParams' => [ + 'view_id', + ], + ], + 'DeleteBucket' => [ + 'method' => 'delete', + 'uriTemplate' => '/v2/{name=*/*/locations/*/buckets/*}', + 'additionalBindings' => [ [ - 'method' => 'put', - 'uriTemplate' => '/v2/{sink_name=projects/*/sinks/*}', - 'body' => 'sink', + 'method' => 'delete', + 'uriTemplate' => '/v2/{name=projects/*/locations/*/buckets/*}', ], [ - 'method' => 'put', - 'uriTemplate' => '/v2/{sink_name=organizations/*/sinks/*}', - 'body' => 'sink', + 'method' => 'delete', + 'uriTemplate' => '/v2/{name=organizations/*/locations/*/buckets/*}', ], [ - 'method' => 'put', - 'uriTemplate' => '/v2/{sink_name=folders/*/sinks/*}', - 'body' => 'sink', + 'method' => 'delete', + 'uriTemplate' => '/v2/{name=folders/*/locations/*/buckets/*}', ], [ - 'method' => 'put', - 'uriTemplate' => '/v2/{sink_name=billingAccounts/*/sinks/*}', - 'body' => 'sink', + 'method' => 'delete', + 'uriTemplate' => '/v2/{name=billingAccounts/*/locations/*/buckets/*}', ], ], 'placeholders' => [ - 'sink_name' => [ + 'name' => [ 'getters' => [ - 'getSinkName', + 'getName', + ], + ], + ], + ], + 'DeleteExclusion' => [ + 'method' => 'delete', + 'uriTemplate' => '/v2/{name=*/*/exclusions/*}', + 'additionalBindings' => [ + [ + 'method' => 'delete', + 'uriTemplate' => '/v2/{name=projects/*/exclusions/*}', + ], + [ + 'method' => 'delete', + 'uriTemplate' => '/v2/{name=organizations/*/exclusions/*}', + ], + [ + 'method' => 'delete', + 'uriTemplate' => '/v2/{name=folders/*/exclusions/*}', + ], + [ + 'method' => 'delete', + 'uriTemplate' => '/v2/{name=billingAccounts/*/exclusions/*}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', ], ], ], @@ -178,31 +256,77 @@ ], ], ], - 'ListExclusions' => [ + 'DeleteView' => [ + 'method' => 'delete', + 'uriTemplate' => '/v2/{name=*/*/locations/*/buckets/*/views/*}', + 'additionalBindings' => [ + [ + 'method' => 'delete', + 'uriTemplate' => '/v2/{name=projects/*/locations/*/buckets/*/views/*}', + ], + [ + 'method' => 'delete', + 'uriTemplate' => '/v2/{name=organizations/*/locations/*/buckets/*/views/*}', + ], + [ + 'method' => 'delete', + 'uriTemplate' => '/v2/{name=folders/*/locations/*/buckets/*/views/*}', + ], + [ + 'method' => 'delete', + 'uriTemplate' => '/v2/{name=billingAccounts/*/locations/*/buckets/*/views/*}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetBucket' => [ 'method' => 'get', - 'uriTemplate' => '/v2/{parent=*/*}/exclusions', + 'uriTemplate' => '/v2/{name=*/*/locations/*/buckets/*}', 'additionalBindings' => [ [ 'method' => 'get', - 'uriTemplate' => '/v2/{parent=projects/*}/exclusions', + 'uriTemplate' => '/v2/{name=projects/*/locations/*/buckets/*}', ], [ 'method' => 'get', - 'uriTemplate' => '/v2/{parent=organizations/*}/exclusions', + 'uriTemplate' => '/v2/{name=organizations/*/locations/*/buckets/*}', ], [ 'method' => 'get', - 'uriTemplate' => '/v2/{parent=folders/*}/exclusions', + 'uriTemplate' => '/v2/{name=folders/*/locations/*/buckets/*}', ], [ 'method' => 'get', - 'uriTemplate' => '/v2/{parent=billingAccounts/*}/exclusions', + 'uriTemplate' => '/v2/{name=billingAccounts/*/buckets/*}', ], ], 'placeholders' => [ - 'parent' => [ + 'name' => [ 'getters' => [ - 'getParent', + 'getName', + ], + ], + ], + ], + 'GetCmekSettings' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/{name=*/*}/cmekSettings', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v2/{name=organizations/*}/cmekSettings', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', ], ], ], @@ -236,30 +360,112 @@ ], ], ], - 'CreateExclusion' => [ - 'method' => 'post', + 'GetSink' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/{sink_name=*/*/sinks/*}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v2/{sink_name=projects/*/sinks/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v2/{sink_name=organizations/*/sinks/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v2/{sink_name=folders/*/sinks/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v2/{sink_name=billingAccounts/*/sinks/*}', + ], + ], + 'placeholders' => [ + 'sink_name' => [ + 'getters' => [ + 'getSinkName', + ], + ], + ], + ], + 'GetView' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/{name=*/*/locations/*/buckets/*/views/*}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v2/{name=projects/*/locations/*/buckets/*/views/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v2/{name=organizations/*/locations/*/buckets/*/views/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v2/{name=folders/*/locations/*/buckets/*/views/*}', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v2/{name=billingAccounts/*/buckets/*/views/*}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListBuckets' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/{parent=*/*/locations/*}/buckets', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v2/{parent=projects/*/locations/*}/buckets', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v2/{parent=organizations/*/locations/*}/buckets', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v2/{parent=folders/*/locations/*}/buckets', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v2/{parent=billingAccounts/*/locations/*}/buckets', + ], + ], + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'ListExclusions' => [ + 'method' => 'get', 'uriTemplate' => '/v2/{parent=*/*}/exclusions', - 'body' => 'exclusion', 'additionalBindings' => [ [ - 'method' => 'post', + 'method' => 'get', 'uriTemplate' => '/v2/{parent=projects/*}/exclusions', - 'body' => 'exclusion', ], [ - 'method' => 'post', + 'method' => 'get', 'uriTemplate' => '/v2/{parent=organizations/*}/exclusions', - 'body' => 'exclusion', ], [ - 'method' => 'post', + 'method' => 'get', 'uriTemplate' => '/v2/{parent=folders/*}/exclusions', - 'body' => 'exclusion', ], [ - 'method' => 'post', + 'method' => 'get', 'uriTemplate' => '/v2/{parent=billingAccounts/*}/exclusions', - 'body' => 'exclusion', ], ], 'placeholders' => [ @@ -270,30 +476,134 @@ ], ], ], - 'UpdateExclusion' => [ + 'ListSinks' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/{parent=*/*}/sinks', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v2/{parent=projects/*}/sinks', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v2/{parent=organizations/*}/sinks', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v2/{parent=folders/*}/sinks', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v2/{parent=billingAccounts/*}/sinks', + ], + ], + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'ListViews' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/{parent=*/*/locations/*/buckets/*}/views', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v2/{parent=projects/*/locations/*/buckets/*}/views', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v2/{parent=organizations/*/locations/*/buckets/*}/views', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v2/{parent=folders/*/locations/*/buckets/*}/views', + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v2/{parent=billingAccounts/*/locations/*/buckets/*}/views', + ], + ], + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'UndeleteBucket' => [ + 'method' => 'post', + 'uriTemplate' => '/v2/{name=*/*/locations/*/buckets/*}:undelete', + 'body' => '*', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v2/{name=projects/*/locations/*/buckets/*}:undelete', + 'body' => '*', + ], + [ + 'method' => 'post', + 'uriTemplate' => '/v2/{name=organizations/*/locations/*/buckets/*}:undelete', + 'body' => '*', + ], + [ + 'method' => 'post', + 'uriTemplate' => '/v2/{name=folders/*/locations/*/buckets/*}:undelete', + 'body' => '*', + ], + [ + 'method' => 'post', + 'uriTemplate' => '/v2/{name=billingAccounts/*/locations/*/buckets/*}:undelete', + 'body' => '*', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'UpdateBucket' => [ 'method' => 'patch', - 'uriTemplate' => '/v2/{name=*/*/exclusions/*}', - 'body' => 'exclusion', + 'uriTemplate' => '/v2/{name=*/*/locations/*/buckets/*}', + 'body' => 'bucket', 'additionalBindings' => [ [ 'method' => 'patch', - 'uriTemplate' => '/v2/{name=projects/*/exclusions/*}', - 'body' => 'exclusion', + 'uriTemplate' => '/v2/{name=projects/*/locations/*/buckets/*}', + 'body' => 'bucket', + 'queryParams' => [ + 'update_mask', + ], ], [ 'method' => 'patch', - 'uriTemplate' => '/v2/{name=organizations/*/exclusions/*}', - 'body' => 'exclusion', + 'uriTemplate' => '/v2/{name=organizations/*/locations/*/buckets/*}', + 'body' => 'bucket', + 'queryParams' => [ + 'update_mask', + ], ], [ 'method' => 'patch', - 'uriTemplate' => '/v2/{name=folders/*/exclusions/*}', - 'body' => 'exclusion', + 'uriTemplate' => '/v2/{name=folders/*/locations/*/buckets/*}', + 'body' => 'bucket', + 'queryParams' => [ + 'update_mask', + ], ], [ 'method' => 'patch', - 'uriTemplate' => '/v2/{name=billingAccounts/*/exclusions/*}', - 'body' => 'exclusion', + 'uriTemplate' => '/v2/{name=billingAccounts/*/locations/*/buckets/*}', + 'body' => 'bucket', + 'queryParams' => [ + 'update_mask', + ], ], ], 'placeholders' => [ @@ -303,26 +613,65 @@ ], ], ], + 'queryParams' => [ + 'update_mask', + ], ], - 'DeleteExclusion' => [ - 'method' => 'delete', + 'UpdateCmekSettings' => [ + 'method' => 'patch', + 'uriTemplate' => '/v2/{name=*/*}/cmekSettings', + 'body' => 'cmek_settings', + 'additionalBindings' => [ + [ + 'method' => 'patch', + 'uriTemplate' => '/v2/{name=organizations/*}/cmekSettings', + 'body' => 'cmek_settings', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'UpdateExclusion' => [ + 'method' => 'patch', 'uriTemplate' => '/v2/{name=*/*/exclusions/*}', + 'body' => 'exclusion', 'additionalBindings' => [ [ - 'method' => 'delete', + 'method' => 'patch', 'uriTemplate' => '/v2/{name=projects/*/exclusions/*}', + 'body' => 'exclusion', + 'queryParams' => [ + 'update_mask', + ], ], [ - 'method' => 'delete', + 'method' => 'patch', 'uriTemplate' => '/v2/{name=organizations/*/exclusions/*}', + 'body' => 'exclusion', + 'queryParams' => [ + 'update_mask', + ], ], [ - 'method' => 'delete', + 'method' => 'patch', 'uriTemplate' => '/v2/{name=folders/*/exclusions/*}', + 'body' => 'exclusion', + 'queryParams' => [ + 'update_mask', + ], ], [ - 'method' => 'delete', + 'method' => 'patch', 'uriTemplate' => '/v2/{name=billingAccounts/*/exclusions/*}', + 'body' => 'exclusion', + 'queryParams' => [ + 'update_mask', + ], ], ], 'placeholders' => [ @@ -332,33 +681,88 @@ ], ], ], + 'queryParams' => [ + 'update_mask', + ], ], - 'GetCmekSettings' => [ - 'method' => 'get', - 'uriTemplate' => '/v2/{name=*/*}/cmekSettings', + 'UpdateSink' => [ + 'method' => 'put', + 'uriTemplate' => '/v2/{sink_name=*/*/sinks/*}', + 'body' => 'sink', 'additionalBindings' => [ [ - 'method' => 'get', - 'uriTemplate' => '/v2/{name=organizations/*}/cmekSettings', + 'method' => 'put', + 'uriTemplate' => '/v2/{sink_name=projects/*/sinks/*}', + 'body' => 'sink', + ], + [ + 'method' => 'put', + 'uriTemplate' => '/v2/{sink_name=organizations/*/sinks/*}', + 'body' => 'sink', + ], + [ + 'method' => 'put', + 'uriTemplate' => '/v2/{sink_name=folders/*/sinks/*}', + 'body' => 'sink', + ], + [ + 'method' => 'put', + 'uriTemplate' => '/v2/{sink_name=billingAccounts/*/sinks/*}', + 'body' => 'sink', + ], + [ + 'method' => 'patch', + 'uriTemplate' => '/v2/{sink_name=projects/*/sinks/*}', + 'body' => 'sink', + ], + [ + 'method' => 'patch', + 'uriTemplate' => '/v2/{sink_name=organizations/*/sinks/*}', + 'body' => 'sink', + ], + [ + 'method' => 'patch', + 'uriTemplate' => '/v2/{sink_name=folders/*/sinks/*}', + 'body' => 'sink', + ], + [ + 'method' => 'patch', + 'uriTemplate' => '/v2/{sink_name=billingAccounts/*/sinks/*}', + 'body' => 'sink', ], ], 'placeholders' => [ - 'name' => [ + 'sink_name' => [ 'getters' => [ - 'getName', + 'getSinkName', ], ], ], ], - 'UpdateCmekSettings' => [ + 'UpdateView' => [ 'method' => 'patch', - 'uriTemplate' => '/v2/{name=*/*}/cmekSettings', - 'body' => 'cmek_settings', + 'uriTemplate' => '/v2/{name=*/*/locations/*/buckets/*/views/*}', + 'body' => 'view', 'additionalBindings' => [ [ 'method' => 'patch', - 'uriTemplate' => '/v2/{name=organizations/*}/cmekSettings', - 'body' => 'cmek_settings', + 'uriTemplate' => '/v2/{name=projects/*/locations/*/buckets/*/views/*}', + 'body' => 'view', + ], + [ + 'method' => 'patch', + 'uriTemplate' => '/v2/{name=organizations/*/locations/*/buckets/*/views/*}', + 'body' => 'view', + ], + [ + 'method' => 'patch', + 'uriTemplate' => '/v2/{name=folders/*/locations/*/buckets/*/views/*}', + 'body' => 'view', + ], + [ + 'method' => 'patch', + 'uriTemplate' => '/v2/{name=billingAccounts/*/locations/*/buckets/*/views/*}', + 'body' => 'view', ], ], 'placeholders' => [ diff --git a/Logging/src/V2/resources/logging_service_v2_client_config.json b/Logging/src/V2/resources/logging_service_v2_client_config.json index e93f205572eb..f5ac1a4d058e 100644 --- a/Logging/src/V2/resources/logging_service_v2_client_config.json +++ b/Logging/src/V2/resources/logging_service_v2_client_config.json @@ -1,66 +1,83 @@ { - "interfaces": { - "google.logging.v2.LoggingServiceV2": { - "retry_codes": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "INTERNAL", - "UNAVAILABLE" - ], - "non_idempotent": [] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 20000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 20000, - "total_timeout_millis": 600000 - }, - "list": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 20000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 20000, - "total_timeout_millis": 600000 + "interfaces": { + "google.logging.v2.LoggingServiceV2": { + "retry_codes": { + "no_retry_codes": [], + "retry_policy_1_codes": [ + "DEADLINE_EXCEEDED", + "INTERNAL", + "UNAVAILABLE" + ], + "retry_policy_2_codes": [ + "DEADLINE_EXCEEDED", + "INTERNAL", + "UNAVAILABLE" + ] + }, + "retry_params": { + "no_retry_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 0, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 0, + "total_timeout_millis": 0 + }, + "retry_policy_1_params": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 60000 + }, + "retry_policy_2_params": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 3600000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 3600000, + "total_timeout_millis": 3600000 + } + }, + "methods": { + "DeleteLog": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "ListLogEntries": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "ListLogs": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "ListMonitoredResourceDescriptors": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "TailLogEntries": { + "timeout_millis": 3600000 + }, + "WriteLogEntries": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params", + "bundling": { + "delay_threshold_millis": 50, + "element_count_threshold": 1000, + "request_byte_threshold": 1048576 + } + } + } } - }, - "methods": { - "DeleteLog": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "WriteLogEntries": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", - "bundling": { - "element_count_threshold": 1000, - "request_byte_threshold": 1048576, - "delay_threshold_millis": 50 - } - }, - "ListLogEntries": { - "timeout_millis": 10000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListMonitoredResourceDescriptors": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListLogs": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } } - } } diff --git a/Logging/src/V2/resources/logging_service_v2_descriptor_config.php b/Logging/src/V2/resources/logging_service_v2_descriptor_config.php index 76c4eb0e8f01..dccb09092992 100644 --- a/Logging/src/V2/resources/logging_service_v2_descriptor_config.php +++ b/Logging/src/V2/resources/logging_service_v2_descriptor_config.php @@ -13,24 +13,29 @@ 'resourcesGetMethod' => 'getEntries', ], ], - 'ListMonitoredResourceDescriptors' => [ + 'ListLogs' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', 'requestPageSizeGetMethod' => 'getPageSize', 'requestPageSizeSetMethod' => 'setPageSize', 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getResourceDescriptors', + 'resourcesGetMethod' => 'getLogNames', ], ], - 'ListLogs' => [ + 'ListMonitoredResourceDescriptors' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', 'requestPageSizeGetMethod' => 'getPageSize', 'requestPageSizeSetMethod' => 'setPageSize', 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getLogNames', + 'resourcesGetMethod' => 'getResourceDescriptors', + ], + ], + 'TailLogEntries' => [ + 'grpcStreaming' => [ + 'grpcStreamingType' => 'BidiStreaming', ], ], ], diff --git a/Logging/src/V2/resources/logging_service_v2_rest_client_config.php b/Logging/src/V2/resources/logging_service_v2_rest_client_config.php index 4a4980162dee..84d8dbaf91e8 100644 --- a/Logging/src/V2/resources/logging_service_v2_rest_client_config.php +++ b/Logging/src/V2/resources/logging_service_v2_rest_client_config.php @@ -32,20 +32,11 @@ ], ], ], - 'WriteLogEntries' => [ - 'method' => 'post', - 'uriTemplate' => '/v2/entries:write', - 'body' => '*', - ], 'ListLogEntries' => [ 'method' => 'post', 'uriTemplate' => '/v2/entries:list', 'body' => '*', ], - 'ListMonitoredResourceDescriptors' => [ - 'method' => 'get', - 'uriTemplate' => '/v2/monitoredResourceDescriptors', - ], 'ListLogs' => [ 'method' => 'get', 'uriTemplate' => '/v2/{parent=*/*}/logs', @@ -75,6 +66,15 @@ ], ], ], + 'ListMonitoredResourceDescriptors' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/monitoredResourceDescriptors', + ], + 'WriteLogEntries' => [ + 'method' => 'post', + 'uriTemplate' => '/v2/entries:write', + 'body' => '*', + ], ], ], ]; diff --git a/Logging/src/V2/resources/metrics_service_v2_client_config.json b/Logging/src/V2/resources/metrics_service_v2_client_config.json index 671ed471b51c..8d1153764e81 100644 --- a/Logging/src/V2/resources/metrics_service_v2_client_config.json +++ b/Logging/src/V2/resources/metrics_service_v2_client_config.json @@ -1,52 +1,71 @@ { - "interfaces": { - "google.logging.v2.MetricsServiceV2": { - "retry_codes": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "INTERNAL", - "UNAVAILABLE" - ], - "non_idempotent": [] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 20000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 20000, - "total_timeout_millis": 600000 + "interfaces": { + "google.logging.v2.MetricsServiceV2": { + "retry_codes": { + "no_retry_codes": [], + "no_retry_1_codes": [], + "retry_policy_4_codes": [ + "DEADLINE_EXCEEDED", + "INTERNAL", + "UNAVAILABLE" + ] + }, + "retry_params": { + "no_retry_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 0, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 0, + "total_timeout_millis": 0 + }, + "no_retry_1_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 60000 + }, + "retry_policy_4_params": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 60000 + } + }, + "methods": { + "CreateLogMetric": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + }, + "DeleteLogMetric": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_4_codes", + "retry_params_name": "retry_policy_4_params" + }, + "GetLogMetric": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_4_codes", + "retry_params_name": "retry_policy_4_params" + }, + "ListLogMetrics": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_4_codes", + "retry_params_name": "retry_policy_4_params" + }, + "UpdateLogMetric": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_4_codes", + "retry_params_name": "retry_policy_4_params" + } + } } - }, - "methods": { - "ListLogMetrics": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetLogMetric": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateLogMetric": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateLogMetric": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "DeleteLogMetric": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } } - } } diff --git a/Logging/src/V2/resources/metrics_service_v2_rest_client_config.php b/Logging/src/V2/resources/metrics_service_v2_rest_client_config.php index 58887f7467e3..549680fd8b08 100644 --- a/Logging/src/V2/resources/metrics_service_v2_rest_client_config.php +++ b/Logging/src/V2/resources/metrics_service_v2_rest_client_config.php @@ -3,9 +3,10 @@ return [ 'interfaces' => [ 'google.logging.v2.MetricsServiceV2' => [ - 'ListLogMetrics' => [ - 'method' => 'get', + 'CreateLogMetric' => [ + 'method' => 'post', 'uriTemplate' => '/v2/{parent=projects/*}/metrics', + 'body' => 'metric', 'placeholders' => [ 'parent' => [ 'getters' => [ @@ -14,6 +15,17 @@ ], ], ], + 'DeleteLogMetric' => [ + 'method' => 'delete', + 'uriTemplate' => '/v2/{metric_name=projects/*/metrics/*}', + 'placeholders' => [ + 'metric_name' => [ + 'getters' => [ + 'getMetricName', + ], + ], + ], + ], 'GetLogMetric' => [ 'method' => 'get', 'uriTemplate' => '/v2/{metric_name=projects/*/metrics/*}', @@ -25,10 +37,9 @@ ], ], ], - 'CreateLogMetric' => [ - 'method' => 'post', + 'ListLogMetrics' => [ + 'method' => 'get', 'uriTemplate' => '/v2/{parent=projects/*}/metrics', - 'body' => 'metric', 'placeholders' => [ 'parent' => [ 'getters' => [ @@ -49,17 +60,6 @@ ], ], ], - 'DeleteLogMetric' => [ - 'method' => 'delete', - 'uriTemplate' => '/v2/{metric_name=projects/*/metrics/*}', - 'placeholders' => [ - 'metric_name' => [ - 'getters' => [ - 'getMetricName', - ], - ], - ], - ], ], ], ]; diff --git a/Logging/tests/Unit/V2/ConfigServiceV2ClientTest.php b/Logging/tests/Unit/V2/ConfigServiceV2ClientTest.php index 2eea7195597c..2f7d331bb294 100644 --- a/Logging/tests/Unit/V2/ConfigServiceV2ClientTest.php +++ b/Logging/tests/Unit/V2/ConfigServiceV2ClientTest.php @@ -22,17 +22,22 @@ namespace Google\Cloud\Logging\Tests\Unit\V2; -use Google\Cloud\Logging\V2\ConfigServiceV2Client; use Google\ApiCore\ApiException; + use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; + use Google\Cloud\Logging\V2\CmekSettings; +use Google\Cloud\Logging\V2\ConfigServiceV2Client; +use Google\Cloud\Logging\V2\ListBucketsResponse; use Google\Cloud\Logging\V2\ListExclusionsResponse; use Google\Cloud\Logging\V2\ListSinksResponse; +use Google\Cloud\Logging\V2\ListViewsResponse; +use Google\Cloud\Logging\V2\LogBucket; use Google\Cloud\Logging\V2\LogExclusion; use Google\Cloud\Logging\V2\LogSink; -use Google\Protobuf\Any; +use Google\Cloud\Logging\V2\LogView; use Google\Protobuf\FieldMask; use Google\Protobuf\GPBEmpty; use Google\Rpc\Code; @@ -40,6 +45,7 @@ /** * @group logging + * * @group gapic */ class ConfigServiceV2ClientTest extends GeneratedTest @@ -57,9 +63,7 @@ private function createTransport($deserialize = null) */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class) - ->disableOriginalConstructor() - ->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); } /** @@ -70,84 +74,82 @@ private function createClient(array $options = []) $options += [ 'credentials' => $this->createCredentials(), ]; - return new ConfigServiceV2Client($options); } /** * @test */ - public function listSinksTest() + public function createBucketTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $sinksElement = new LogSink(); - $sinks = [$sinksElement]; - $expectedResponse = new ListSinksResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setSinks($sinks); + $name = 'name3373707'; + $description = 'description-1724546052'; + $retentionDays = 1544391896; + $locked = true; + $expectedResponse = new LogBucket(); + $expectedResponse->setName($name); + $expectedResponse->setDescription($description); + $expectedResponse->setRetentionDays($retentionDays); + $expectedResponse->setLocked($locked); $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $client->projectName('[PROJECT]'); - - $response = $client->listSinks($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getSinks()[0], $resources[0]); - + $formattedParent = $client->organizationLocationName('[ORGANIZATION]', '[LOCATION]'); + $bucketId = 'bucketId1837164432'; + $bucket = new LogBucket(); + $response = $client->createBucket($formattedParent, $bucketId, $bucket); + $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.logging.v2.ConfigServiceV2/ListSinks', $actualFuncCall); - + $this->assertSame('/google.logging.v2.ConfigServiceV2/CreateBucket', $actualFuncCall); $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getBucketId(); + $this->assertProtobufEquals($bucketId, $actualValue); + $actualValue = $actualRequestObject->getBucket(); + $this->assertProtobufEquals($bucket, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function listSinksExceptionTest() + public function createBucketExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedParent = $client->projectName('[PROJECT]'); - + $formattedParent = $client->organizationLocationName('[ORGANIZATION]', '[LOCATION]'); + $bucketId = 'bucketId1837164432'; + $bucket = new LogBucket(); try { - $client->listSinks($formattedParent); + $client->createBucket($formattedParent, $bucketId, $bucket); // If the $client method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { $this->assertEquals($status->code, $ex->getCode()); $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); } - // Call popReceivedCalls to ensure the stub is exhausted $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); @@ -156,83 +158,80 @@ public function listSinksExceptionTest() /** * @test */ - public function getSinkTest() + public function createExclusionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response $name = 'name3373707'; - $destination = 'destination-1429847026'; - $filter = 'filter-1274492040'; $description = 'description-1724546052'; + $filter = 'filter-1274492040'; $disabled = true; - $writerIdentity = 'writerIdentity775638794'; - $includeChildren = true; - $expectedResponse = new LogSink(); + $expectedResponse = new LogExclusion(); $expectedResponse->setName($name); - $expectedResponse->setDestination($destination); - $expectedResponse->setFilter($filter); $expectedResponse->setDescription($description); + $expectedResponse->setFilter($filter); $expectedResponse->setDisabled($disabled); - $expectedResponse->setWriterIdentity($writerIdentity); - $expectedResponse->setIncludeChildren($includeChildren); $transport->addResponse($expectedResponse); - // Mock request - $formattedSinkName = $client->sinkName('[PROJECT]', '[SINK]'); - - $response = $client->getSink($formattedSinkName); + $formattedParent = $client->projectName('[PROJECT]'); + $exclusion = new LogExclusion(); + $exclusionName = 'exclusionName1004344697'; + $exclusion->setName($exclusionName); + $exclusionFilter = 'exclusionFilter-1414044954'; + $exclusion->setFilter($exclusionFilter); + $response = $client->createExclusion($formattedParent, $exclusion); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.logging.v2.ConfigServiceV2/GetSink', $actualFuncCall); - - $actualValue = $actualRequestObject->getSinkName(); - - $this->assertProtobufEquals($formattedSinkName, $actualValue); - + $this->assertSame('/google.logging.v2.ConfigServiceV2/CreateExclusion', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getExclusion(); + $this->assertProtobufEquals($exclusion, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function getSinkExceptionTest() + public function createExclusionExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedSinkName = $client->sinkName('[PROJECT]', '[SINK]'); - + $formattedParent = $client->projectName('[PROJECT]'); + $exclusion = new LogExclusion(); + $exclusionName = 'exclusionName1004344697'; + $exclusion->setName($exclusionName); + $exclusionFilter = 'exclusionFilter-1414044954'; + $exclusion->setFilter($exclusionFilter); try { - $client->getSink($formattedSinkName); + $client->createExclusion($formattedParent, $exclusion); // If the $client method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { $this->assertEquals($status->code, $ex->getCode()); $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); } - // Call popReceivedCalls to ensure the stub is exhausted $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); @@ -244,10 +243,10 @@ public function getSinkExceptionTest() public function createSinkTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response $name = 'name3373707'; $destination = 'destination-1429847026'; @@ -265,11 +264,13 @@ public function createSinkTest() $expectedResponse->setWriterIdentity($writerIdentity); $expectedResponse->setIncludeChildren($includeChildren); $transport->addResponse($expectedResponse); - // Mock request $formattedParent = $client->projectName('[PROJECT]'); $sink = new LogSink(); - + $sinkName = 'sinkName508775358'; + $sink->setName($sinkName); + $sinkDestination = 'sinkDestination-1018870917'; + $sink->setDestination($sinkDestination); $response = $client->createSink($formattedParent, $sink); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -277,14 +278,10 @@ public function createSinkTest() $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); $this->assertSame('/google.logging.v2.ConfigServiceV2/CreateSink', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualRequestObject->getSink(); - $this->assertProtobufEquals($sink, $actualValue); - $this->assertTrue($transport->isExhausted()); } @@ -294,26 +291,27 @@ public function createSinkTest() public function createSinkExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request $formattedParent = $client->projectName('[PROJECT]'); $sink = new LogSink(); - + $sinkName = 'sinkName508775358'; + $sink->setName($sinkName); + $sinkDestination = 'sinkDestination-1018870917'; + $sink->setDestination($sinkDestination); try { $client->createSink($formattedParent, $sink); // If the $client method call did not throw, fail the test @@ -322,7 +320,6 @@ public function createSinkExceptionTest() $this->assertEquals($status->code, $ex->getCode()); $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); } - // Call popReceivedCalls to ensure the stub is exhausted $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); @@ -331,88 +328,74 @@ public function createSinkExceptionTest() /** * @test */ - public function updateSinkTest() + public function createViewTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response $name = 'name3373707'; - $destination = 'destination-1429847026'; - $filter = 'filter-1274492040'; $description = 'description-1724546052'; - $disabled = true; - $writerIdentity = 'writerIdentity775638794'; - $includeChildren = true; - $expectedResponse = new LogSink(); + $filter = 'filter-1274492040'; + $expectedResponse = new LogView(); $expectedResponse->setName($name); - $expectedResponse->setDestination($destination); - $expectedResponse->setFilter($filter); $expectedResponse->setDescription($description); - $expectedResponse->setDisabled($disabled); - $expectedResponse->setWriterIdentity($writerIdentity); - $expectedResponse->setIncludeChildren($includeChildren); + $expectedResponse->setFilter($filter); $transport->addResponse($expectedResponse); - // Mock request - $formattedSinkName = $client->sinkName('[PROJECT]', '[SINK]'); - $sink = new LogSink(); - - $response = $client->updateSink($formattedSinkName, $sink); + $parent = 'parent-995424086'; + $viewId = 'viewId454228213'; + $view = new LogView(); + $response = $client->createView($parent, $viewId, $view); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.logging.v2.ConfigServiceV2/UpdateSink', $actualFuncCall); - - $actualValue = $actualRequestObject->getSinkName(); - - $this->assertProtobufEquals($formattedSinkName, $actualValue); - $actualValue = $actualRequestObject->getSink(); - - $this->assertProtobufEquals($sink, $actualValue); - + $this->assertSame('/google.logging.v2.ConfigServiceV2/CreateView', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($parent, $actualValue); + $actualValue = $actualRequestObject->getViewId(); + $this->assertProtobufEquals($viewId, $actualValue); + $actualValue = $actualRequestObject->getView(); + $this->assertProtobufEquals($view, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function updateSinkExceptionTest() + public function createViewExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedSinkName = $client->sinkName('[PROJECT]', '[SINK]'); - $sink = new LogSink(); - + $parent = 'parent-995424086'; + $viewId = 'viewId454228213'; + $view = new LogView(); try { - $client->updateSink($formattedSinkName, $sink); + $client->createView($parent, $viewId, $view); // If the $client method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { $this->assertEquals($status->code, $ex->getCode()); $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); } - // Call popReceivedCalls to ensure the stub is exhausted $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); @@ -421,68 +404,59 @@ public function updateSinkExceptionTest() /** * @test */ - public function deleteSinkTest() + public function deleteBucketTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response $expectedResponse = new GPBEmpty(); $transport->addResponse($expectedResponse); - // Mock request - $formattedSinkName = $client->sinkName('[PROJECT]', '[SINK]'); - - $client->deleteSink($formattedSinkName); + $formattedName = $client->logBucketName('[PROJECT]', '[LOCATION]', '[BUCKET]'); + $client->deleteBucket($formattedName); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.logging.v2.ConfigServiceV2/DeleteSink', $actualFuncCall); - - $actualValue = $actualRequestObject->getSinkName(); - - $this->assertProtobufEquals($formattedSinkName, $actualValue); - + $this->assertSame('/google.logging.v2.ConfigServiceV2/DeleteBucket', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function deleteSinkExceptionTest() + public function deleteBucketExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedSinkName = $client->sinkName('[PROJECT]', '[SINK]'); - + $formattedName = $client->logBucketName('[PROJECT]', '[LOCATION]', '[BUCKET]'); try { - $client->deleteSink($formattedSinkName); + $client->deleteBucket($formattedName); // If the $client method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { $this->assertEquals($status->code, $ex->getCode()); $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); } - // Call popReceivedCalls to ensure the stub is exhausted $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); @@ -491,77 +465,59 @@ public function deleteSinkExceptionTest() /** * @test */ - public function listExclusionsTest() + public function deleteExclusionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $exclusionsElement = new LogExclusion(); - $exclusions = [$exclusionsElement]; - $expectedResponse = new ListExclusionsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setExclusions($exclusions); + $expectedResponse = new GPBEmpty(); $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $client->projectName('[PROJECT]'); - - $response = $client->listExclusions($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getExclusions()[0], $resources[0]); - + $formattedName = $client->logExclusionName('[PROJECT]', '[EXCLUSION]'); + $client->deleteExclusion($formattedName); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.logging.v2.ConfigServiceV2/ListExclusions', $actualFuncCall); - - $actualValue = $actualRequestObject->getParent(); - - $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertSame('/google.logging.v2.ConfigServiceV2/DeleteExclusion', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function listExclusionsExceptionTest() + public function deleteExclusionExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedParent = $client->projectName('[PROJECT]'); - + $formattedName = $client->logExclusionName('[PROJECT]', '[EXCLUSION]'); try { - $client->listExclusions($formattedParent); + $client->deleteExclusion($formattedName); // If the $client method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { $this->assertEquals($status->code, $ex->getCode()); $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); } - // Call popReceivedCalls to ensure the stub is exhausted $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); @@ -570,77 +526,59 @@ public function listExclusionsExceptionTest() /** * @test */ - public function getExclusionTest() + public function deleteSinkTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $description = 'description-1724546052'; - $filter = 'filter-1274492040'; - $disabled = true; - $expectedResponse = new LogExclusion(); - $expectedResponse->setName($name2); - $expectedResponse->setDescription($description); - $expectedResponse->setFilter($filter); - $expectedResponse->setDisabled($disabled); + $expectedResponse = new GPBEmpty(); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->exclusionName('[PROJECT]', '[EXCLUSION]'); - - $response = $client->getExclusion($formattedName); - $this->assertEquals($expectedResponse, $response); + $formattedSinkName = $client->logSinkName('[PROJECT]', '[SINK]'); + $client->deleteSink($formattedSinkName); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.logging.v2.ConfigServiceV2/GetExclusion', $actualFuncCall); - - $actualValue = $actualRequestObject->getName(); - - $this->assertProtobufEquals($formattedName, $actualValue); - + $this->assertSame('/google.logging.v2.ConfigServiceV2/DeleteSink', $actualFuncCall); + $actualValue = $actualRequestObject->getSinkName(); + $this->assertProtobufEquals($formattedSinkName, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function getExclusionExceptionTest() + public function deleteSinkExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->exclusionName('[PROJECT]', '[EXCLUSION]'); - + $formattedSinkName = $client->logSinkName('[PROJECT]', '[SINK]'); try { - $client->getExclusion($formattedName); + $client->deleteSink($formattedSinkName); // If the $client method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { $this->assertEquals($status->code, $ex->getCode()); $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); } - // Call popReceivedCalls to ensure the stub is exhausted $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); @@ -649,82 +587,693 @@ public function getExclusionExceptionTest() /** * @test */ - public function createExclusionTest() + public function deleteViewTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $description = 'description-1724546052'; - $filter = 'filter-1274492040'; - $disabled = true; - $expectedResponse = new LogExclusion(); - $expectedResponse->setName($name); - $expectedResponse->setDescription($description); - $expectedResponse->setFilter($filter); - $expectedResponse->setDisabled($disabled); + $expectedResponse = new GPBEmpty(); $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $client->projectName('[PROJECT]'); - $exclusion = new LogExclusion(); - - $response = $client->createExclusion($formattedParent, $exclusion); - $this->assertEquals($expectedResponse, $response); + $formattedName = $client->logViewName('[PROJECT]', '[LOCATION]', '[BUCKET]', '[VIEW]'); + $client->deleteView($formattedName); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.logging.v2.ConfigServiceV2/CreateExclusion', $actualFuncCall); + $this->assertSame('/google.logging.v2.ConfigServiceV2/DeleteView', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function deleteViewExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $client->logViewName('[PROJECT]', '[LOCATION]', '[BUCKET]', '[VIEW]'); + try { + $client->deleteView($formattedName); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function getBucketTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $description = 'description-1724546052'; + $retentionDays = 1544391896; + $locked = true; + $expectedResponse = new LogBucket(); + $expectedResponse->setName($name2); + $expectedResponse->setDescription($description); + $expectedResponse->setRetentionDays($retentionDays); + $expectedResponse->setLocked($locked); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $client->logBucketName('[PROJECT]', '[LOCATION]', '[BUCKET]'); + $response = $client->getBucket($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.logging.v2.ConfigServiceV2/GetBucket', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function getBucketExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $client->logBucketName('[PROJECT]', '[LOCATION]', '[BUCKET]'); + try { + $client->getBucket($formattedName); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function getCmekSettingsTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $kmsKeyName = 'kmsKeyName2094986649'; + $serviceAccountId = 'serviceAccountId-111486921'; + $expectedResponse = new CmekSettings(); + $expectedResponse->setName($name2); + $expectedResponse->setKmsKeyName($kmsKeyName); + $expectedResponse->setServiceAccountId($serviceAccountId); + $transport->addResponse($expectedResponse); + $response = $client->getCmekSettings(); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.logging.v2.ConfigServiceV2/GetCmekSettings', $actualFuncCall); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function getCmekSettingsExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + try { + $client->getCmekSettings(); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function getExclusionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $description = 'description-1724546052'; + $filter = 'filter-1274492040'; + $disabled = true; + $expectedResponse = new LogExclusion(); + $expectedResponse->setName($name2); + $expectedResponse->setDescription($description); + $expectedResponse->setFilter($filter); + $expectedResponse->setDisabled($disabled); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $client->logExclusionName('[PROJECT]', '[EXCLUSION]'); + $response = $client->getExclusion($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.logging.v2.ConfigServiceV2/GetExclusion', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + /** + * @test + */ + public function getExclusionExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $client->logExclusionName('[PROJECT]', '[EXCLUSION]'); + try { + $client->getExclusion($formattedName); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function getSinkTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $destination = 'destination-1429847026'; + $filter = 'filter-1274492040'; + $description = 'description-1724546052'; + $disabled = true; + $writerIdentity = 'writerIdentity775638794'; + $includeChildren = true; + $expectedResponse = new LogSink(); + $expectedResponse->setName($name); + $expectedResponse->setDestination($destination); + $expectedResponse->setFilter($filter); + $expectedResponse->setDescription($description); + $expectedResponse->setDisabled($disabled); + $expectedResponse->setWriterIdentity($writerIdentity); + $expectedResponse->setIncludeChildren($includeChildren); + $transport->addResponse($expectedResponse); + // Mock request + $formattedSinkName = $client->logSinkName('[PROJECT]', '[SINK]'); + $response = $client->getSink($formattedSinkName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.logging.v2.ConfigServiceV2/GetSink', $actualFuncCall); + $actualValue = $actualRequestObject->getSinkName(); + $this->assertProtobufEquals($formattedSinkName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function getSinkExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedSinkName = $client->logSinkName('[PROJECT]', '[SINK]'); + try { + $client->getSink($formattedSinkName); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function getViewTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $description = 'description-1724546052'; + $filter = 'filter-1274492040'; + $expectedResponse = new LogView(); + $expectedResponse->setName($name2); + $expectedResponse->setDescription($description); + $expectedResponse->setFilter($filter); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $client->logViewName('[PROJECT]', '[LOCATION]', '[BUCKET]', '[VIEW]'); + $response = $client->getView($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.logging.v2.ConfigServiceV2/GetView', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function getViewExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $client->logViewName('[PROJECT]', '[LOCATION]', '[BUCKET]', '[VIEW]'); + try { + $client->getView($formattedName); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function listBucketsTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $bucketsElement = new LogBucket(); + $buckets = [ + $bucketsElement, + ]; + $expectedResponse = new ListBucketsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setBuckets($buckets); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $client->organizationLocationName('[ORGANIZATION]', '[LOCATION]'); + $response = $client->listBuckets($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getBuckets()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.logging.v2.ConfigServiceV2/ListBuckets', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function listBucketsExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $client->organizationLocationName('[ORGANIZATION]', '[LOCATION]'); + try { + $client->listBuckets($formattedParent); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function listExclusionsTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $exclusionsElement = new LogExclusion(); + $exclusions = [ + $exclusionsElement, + ]; + $expectedResponse = new ListExclusionsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setExclusions($exclusions); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $client->projectName('[PROJECT]'); + $response = $client->listExclusions($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getExclusions()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.logging.v2.ConfigServiceV2/ListExclusions', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function listExclusionsExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $client->projectName('[PROJECT]'); + try { + $client->listExclusions($formattedParent); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function listSinksTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $sinksElement = new LogSink(); + $sinks = [ + $sinksElement, + ]; + $expectedResponse = new ListSinksResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setSinks($sinks); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $client->projectName('[PROJECT]'); + $response = $client->listSinks($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getSinks()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.logging.v2.ConfigServiceV2/ListSinks', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function listSinksExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $client->projectName('[PROJECT]'); + try { + $client->listSinks($formattedParent); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function listViewsTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $viewsElement = new LogView(); + $views = [ + $viewsElement, + ]; + $expectedResponse = new ListViewsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setViews($views); + $transport->addResponse($expectedResponse); + // Mock request + $parent = 'parent-995424086'; + $response = $client->listViews($parent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getViews()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.logging.v2.ConfigServiceV2/ListViews', $actualFuncCall); $actualValue = $actualRequestObject->getParent(); - - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getExclusion(); - - $this->assertProtobufEquals($exclusion, $actualValue); - + $this->assertProtobufEquals($parent, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function createExclusionExceptionTest() + public function listViewsExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedParent = $client->projectName('[PROJECT]'); - $exclusion = new LogExclusion(); - + $parent = 'parent-995424086'; try { - $client->createExclusion($formattedParent, $exclusion); + $client->listViews($parent); // If the $client method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { $this->assertEquals($status->code, $ex->getCode()); $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); } - // Call popReceivedCalls to ensure the stub is exhausted $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); @@ -733,87 +1282,137 @@ public function createExclusionExceptionTest() /** * @test */ - public function updateExclusionTest() + public function undeleteBucketTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $client->logBucketName('[PROJECT]', '[LOCATION]', '[BUCKET]'); + $client->undeleteBucket($formattedName); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.logging.v2.ConfigServiceV2/UndeleteBucket', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + /** + * @test + */ + public function undeleteBucketExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $client->logBucketName('[PROJECT]', '[LOCATION]', '[BUCKET]'); + try { + $client->undeleteBucket($formattedName); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); + } + /** + * @test + */ + public function updateBucketTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); // Mock response $name2 = 'name2-1052831874'; $description = 'description-1724546052'; - $filter = 'filter-1274492040'; - $disabled = true; - $expectedResponse = new LogExclusion(); + $retentionDays = 1544391896; + $locked = true; + $expectedResponse = new LogBucket(); $expectedResponse->setName($name2); $expectedResponse->setDescription($description); - $expectedResponse->setFilter($filter); - $expectedResponse->setDisabled($disabled); + $expectedResponse->setRetentionDays($retentionDays); + $expectedResponse->setLocked($locked); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->exclusionName('[PROJECT]', '[EXCLUSION]'); - $exclusion = new LogExclusion(); + $formattedName = $client->logBucketName('[PROJECT]', '[LOCATION]', '[BUCKET]'); + $bucket = new LogBucket(); $updateMask = new FieldMask(); - - $response = $client->updateExclusion($formattedName, $exclusion, $updateMask); + $response = $client->updateBucket($formattedName, $bucket, $updateMask); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.logging.v2.ConfigServiceV2/UpdateExclusion', $actualFuncCall); - + $this->assertSame('/google.logging.v2.ConfigServiceV2/UpdateBucket', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getExclusion(); - - $this->assertProtobufEquals($exclusion, $actualValue); + $actualValue = $actualRequestObject->getBucket(); + $this->assertProtobufEquals($bucket, $actualValue); $actualValue = $actualRequestObject->getUpdateMask(); - $this->assertProtobufEquals($updateMask, $actualValue); - $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function updateExclusionExceptionTest() + public function updateBucketExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->exclusionName('[PROJECT]', '[EXCLUSION]'); - $exclusion = new LogExclusion(); + $formattedName = $client->logBucketName('[PROJECT]', '[LOCATION]', '[BUCKET]'); + $bucket = new LogBucket(); $updateMask = new FieldMask(); - try { - $client->updateExclusion($formattedName, $exclusion, $updateMask); + $client->updateBucket($formattedName, $bucket, $updateMask); // If the $client method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { $this->assertEquals($status->code, $ex->getCode()); $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); } - // Call popReceivedCalls to ensure the stub is exhausted $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); @@ -822,68 +1421,146 @@ public function updateExclusionExceptionTest() /** * @test */ - public function deleteExclusionTest() + public function updateCmekSettingsTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $kmsKeyName = 'kmsKeyName2094986649'; + $serviceAccountId = 'serviceAccountId-111486921'; + $expectedResponse = new CmekSettings(); + $expectedResponse->setName($name2); + $expectedResponse->setKmsKeyName($kmsKeyName); + $expectedResponse->setServiceAccountId($serviceAccountId); + $transport->addResponse($expectedResponse); + $response = $client->updateCmekSettings(); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.logging.v2.ConfigServiceV2/UpdateCmekSettings', $actualFuncCall); + $this->assertTrue($transport->isExhausted()); + } + /** + * @test + */ + public function updateCmekSettingsExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + try { + $client->updateCmekSettings(); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); + } + /** + * @test + */ + public function updateExclusionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); // Mock response - $expectedResponse = new GPBEmpty(); + $name2 = 'name2-1052831874'; + $description = 'description-1724546052'; + $filter = 'filter-1274492040'; + $disabled = true; + $expectedResponse = new LogExclusion(); + $expectedResponse->setName($name2); + $expectedResponse->setDescription($description); + $expectedResponse->setFilter($filter); + $expectedResponse->setDisabled($disabled); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->exclusionName('[PROJECT]', '[EXCLUSION]'); - - $client->deleteExclusion($formattedName); + $formattedName = $client->logExclusionName('[PROJECT]', '[EXCLUSION]'); + $exclusion = new LogExclusion(); + $exclusionName = 'exclusionName1004344697'; + $exclusion->setName($exclusionName); + $exclusionFilter = 'exclusionFilter-1414044954'; + $exclusion->setFilter($exclusionFilter); + $updateMask = new FieldMask(); + $response = $client->updateExclusion($formattedName, $exclusion, $updateMask); + $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.logging.v2.ConfigServiceV2/DeleteExclusion', $actualFuncCall); - + $this->assertSame('/google.logging.v2.ConfigServiceV2/UpdateExclusion', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - + $actualValue = $actualRequestObject->getExclusion(); + $this->assertProtobufEquals($exclusion, $actualValue); + $actualValue = $actualRequestObject->getUpdateMask(); + $this->assertProtobufEquals($updateMask, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function deleteExclusionExceptionTest() + public function updateExclusionExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->exclusionName('[PROJECT]', '[EXCLUSION]'); - + $formattedName = $client->logExclusionName('[PROJECT]', '[EXCLUSION]'); + $exclusion = new LogExclusion(); + $exclusionName = 'exclusionName1004344697'; + $exclusion->setName($exclusionName); + $exclusionFilter = 'exclusionFilter-1414044954'; + $exclusion->setFilter($exclusionFilter); + $updateMask = new FieldMask(); try { - $client->deleteExclusion($formattedName); + $client->updateExclusion($formattedName, $exclusion, $updateMask); // If the $client method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { $this->assertEquals($status->code, $ex->getCode()); $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); } - // Call popReceivedCalls to ensure the stub is exhausted $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); @@ -892,65 +1569,86 @@ public function deleteExclusionExceptionTest() /** * @test */ - public function getCmekSettingsTest() + public function updateSinkTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response $name = 'name3373707'; - $kmsKeyName = 'kmsKeyName2094986649'; - $serviceAccountId = 'serviceAccountId-111486921'; - $expectedResponse = new CmekSettings(); + $destination = 'destination-1429847026'; + $filter = 'filter-1274492040'; + $description = 'description-1724546052'; + $disabled = true; + $writerIdentity = 'writerIdentity775638794'; + $includeChildren = true; + $expectedResponse = new LogSink(); $expectedResponse->setName($name); - $expectedResponse->setKmsKeyName($kmsKeyName); - $expectedResponse->setServiceAccountId($serviceAccountId); + $expectedResponse->setDestination($destination); + $expectedResponse->setFilter($filter); + $expectedResponse->setDescription($description); + $expectedResponse->setDisabled($disabled); + $expectedResponse->setWriterIdentity($writerIdentity); + $expectedResponse->setIncludeChildren($includeChildren); $transport->addResponse($expectedResponse); - - $response = $client->getCmekSettings(); + // Mock request + $formattedSinkName = $client->logSinkName('[PROJECT]', '[SINK]'); + $sink = new LogSink(); + $sinkName = 'sinkName508775358'; + $sink->setName($sinkName); + $sinkDestination = 'sinkDestination-1018870917'; + $sink->setDestination($sinkDestination); + $response = $client->updateSink($formattedSinkName, $sink); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.logging.v2.ConfigServiceV2/GetCmekSettings', $actualFuncCall); - + $this->assertSame('/google.logging.v2.ConfigServiceV2/UpdateSink', $actualFuncCall); + $actualValue = $actualRequestObject->getSinkName(); + $this->assertProtobufEquals($formattedSinkName, $actualValue); + $actualValue = $actualRequestObject->getSink(); + $this->assertProtobufEquals($sink, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function getCmekSettingsExceptionTest() + public function updateSinkExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - + // Mock request + $formattedSinkName = $client->logSinkName('[PROJECT]', '[SINK]'); + $sink = new LogSink(); + $sinkName = 'sinkName508775358'; + $sink->setName($sinkName); + $sinkDestination = 'sinkDestination-1018870917'; + $sink->setDestination($sinkDestination); try { - $client->getCmekSettings(); + $client->updateSink($formattedSinkName, $sink); // If the $client method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { $this->assertEquals($status->code, $ex->getCode()); $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); } - // Call popReceivedCalls to ensure the stub is exhausted $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); @@ -959,65 +1657,70 @@ public function getCmekSettingsExceptionTest() /** * @test */ - public function updateCmekSettingsTest() + public function updateViewTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $kmsKeyName = 'kmsKeyName2094986649'; - $serviceAccountId = 'serviceAccountId-111486921'; - $expectedResponse = new CmekSettings(); - $expectedResponse->setName($name); - $expectedResponse->setKmsKeyName($kmsKeyName); - $expectedResponse->setServiceAccountId($serviceAccountId); + $name2 = 'name2-1052831874'; + $description = 'description-1724546052'; + $filter = 'filter-1274492040'; + $expectedResponse = new LogView(); + $expectedResponse->setName($name2); + $expectedResponse->setDescription($description); + $expectedResponse->setFilter($filter); $transport->addResponse($expectedResponse); - - $response = $client->updateCmekSettings(); + // Mock request + $name = 'name3373707'; + $view = new LogView(); + $response = $client->updateView($name, $view); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.logging.v2.ConfigServiceV2/UpdateCmekSettings', $actualFuncCall); - + $this->assertSame('/google.logging.v2.ConfigServiceV2/UpdateView', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($name, $actualValue); + $actualValue = $actualRequestObject->getView(); + $this->assertProtobufEquals($view, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function updateCmekSettingsExceptionTest() + public function updateViewExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - + // Mock request + $name = 'name3373707'; + $view = new LogView(); try { - $client->updateCmekSettings(); + $client->updateView($name, $view); // If the $client method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { $this->assertEquals($status->code, $ex->getCode()); $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); } - // Call popReceivedCalls to ensure the stub is exhausted $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); diff --git a/Logging/tests/Unit/V2/LoggingServiceV2ClientTest.php b/Logging/tests/Unit/V2/LoggingServiceV2ClientTest.php index 83f6c49140e2..93e309d07bc8 100644 --- a/Logging/tests/Unit/V2/LoggingServiceV2ClientTest.php +++ b/Logging/tests/Unit/V2/LoggingServiceV2ClientTest.php @@ -22,24 +22,31 @@ namespace Google\Cloud\Logging\Tests\Unit\V2; -use Google\Cloud\Logging\V2\LoggingServiceV2Client; +use Google\Api\MonitoredResourceDescriptor; + use Google\ApiCore\ApiException; + +use Google\ApiCore\BidiStream; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\Testing\GeneratedTest; + use Google\ApiCore\Testing\MockTransport; -use Google\Api\MonitoredResourceDescriptor; + use Google\Cloud\Logging\V2\ListLogEntriesResponse; use Google\Cloud\Logging\V2\ListLogsResponse; use Google\Cloud\Logging\V2\ListMonitoredResourceDescriptorsResponse; use Google\Cloud\Logging\V2\LogEntry; +use Google\Cloud\Logging\V2\LoggingServiceV2Client; +use Google\Cloud\Logging\V2\TailLogEntriesRequest; +use Google\Cloud\Logging\V2\TailLogEntriesResponse; use Google\Cloud\Logging\V2\WriteLogEntriesResponse; -use Google\Protobuf\Any; use Google\Protobuf\GPBEmpty; use Google\Rpc\Code; use stdClass; /** * @group logging + * * @group gapic */ class LoggingServiceV2ClientTest extends GeneratedTest @@ -57,9 +64,7 @@ private function createTransport($deserialize = null) */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class) - ->disableOriginalConstructor() - ->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); } /** @@ -70,7 +75,6 @@ private function createClient(array $options = []) $options += [ 'credentials' => $this->createCredentials(), ]; - return new LoggingServiceV2Client($options); } @@ -80,28 +84,23 @@ private function createClient(array $options = []) public function deleteLogTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response $expectedResponse = new GPBEmpty(); $transport->addResponse($expectedResponse); - // Mock request $formattedLogName = $client->logName('[PROJECT]', '[LOG]'); - $client->deleteLog($formattedLogName); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); $this->assertSame('/google.logging.v2.LoggingServiceV2/DeleteLog', $actualFuncCall); - $actualValue = $actualRequestObject->getLogName(); - $this->assertProtobufEquals($formattedLogName, $actualValue); - $this->assertTrue($transport->isExhausted()); } @@ -111,25 +110,22 @@ public function deleteLogTest() public function deleteLogExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request $formattedLogName = $client->logName('[PROJECT]', '[LOG]'); - try { $client->deleteLog($formattedLogName); // If the $client method call did not throw, fail the test @@ -138,7 +134,6 @@ public function deleteLogExceptionTest() $this->assertEquals($status->code, $ex->getCode()); $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); } - // Call popReceivedCalls to ensure the stub is exhausted $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); @@ -147,69 +142,74 @@ public function deleteLogExceptionTest() /** * @test */ - public function writeLogEntriesTest() + public function listLogEntriesTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new WriteLogEntriesResponse(); + $nextPageToken = ''; + $entriesElement = new LogEntry(); + $entries = [ + $entriesElement, + ]; + $expectedResponse = new ListLogEntriesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setEntries($entries); $transport->addResponse($expectedResponse); - // Mock request - $entries = []; - - $response = $client->writeLogEntries($entries); - $this->assertEquals($expectedResponse, $response); + $formattedResourceNames = [ + $client->projectName('[PROJECT]'), + ]; + $response = $client->listLogEntries($formattedResourceNames); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getEntries()[0], $resources[0]); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.logging.v2.LoggingServiceV2/WriteLogEntries', $actualFuncCall); - - $actualValue = $actualRequestObject->getEntries(); - - $this->assertProtobufEquals($entries, $actualValue); - + $this->assertSame('/google.logging.v2.LoggingServiceV2/ListLogEntries', $actualFuncCall); + $actualValue = $actualRequestObject->getResourceNames(); + $this->assertProtobufEquals($formattedResourceNames, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function writeLogEntriesExceptionTest() + public function listLogEntriesExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $entries = []; - + $formattedResourceNames = [ + $client->projectName('[PROJECT]'), + ]; try { - $client->writeLogEntries($entries); + $client->listLogEntries($formattedResourceNames); // If the $client method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { $this->assertEquals($status->code, $ex->getCode()); $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); } - // Call popReceivedCalls to ensure the stub is exhausted $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); @@ -218,77 +218,70 @@ public function writeLogEntriesExceptionTest() /** * @test */ - public function listLogEntriesTest() + public function listLogsTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response $nextPageToken = ''; - $entriesElement = new LogEntry(); - $entries = [$entriesElement]; - $expectedResponse = new ListLogEntriesResponse(); + $logNamesElement = 'logNamesElement-1079688374'; + $logNames = [ + $logNamesElement, + ]; + $expectedResponse = new ListLogsResponse(); $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setEntries($entries); + $expectedResponse->setLogNames($logNames); $transport->addResponse($expectedResponse); - // Mock request - $formattedResourceNames = []; - - $response = $client->listLogEntries($formattedResourceNames); + $formattedParent = $client->projectName('[PROJECT]'); + $response = $client->listLogs($formattedParent); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getEntries()[0], $resources[0]); - + $this->assertEquals($expectedResponse->getLogNames()[0], $resources[0]); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.logging.v2.LoggingServiceV2/ListLogEntries', $actualFuncCall); - - $actualValue = $actualRequestObject->getResourceNames(); - - $this->assertProtobufEquals($formattedResourceNames, $actualValue); + $this->assertSame('/google.logging.v2.LoggingServiceV2/ListLogs', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function listLogEntriesExceptionTest() + public function listLogsExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedResourceNames = []; - + $formattedParent = $client->projectName('[PROJECT]'); try { - $client->listLogEntries($formattedResourceNames); + $client->listLogs($formattedParent); // If the $client method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { $this->assertEquals($status->code, $ex->getCode()); $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); } - // Call popReceivedCalls to ensure the stub is exhausted $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); @@ -300,31 +293,30 @@ public function listLogEntriesExceptionTest() public function listMonitoredResourceDescriptorsTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response $nextPageToken = ''; $resourceDescriptorsElement = new MonitoredResourceDescriptor(); - $resourceDescriptors = [$resourceDescriptorsElement]; + $resourceDescriptors = [ + $resourceDescriptorsElement, + ]; $expectedResponse = new ListMonitoredResourceDescriptorsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setResourceDescriptors($resourceDescriptors); $transport->addResponse($expectedResponse); - $response = $client->listMonitoredResourceDescriptors(); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); $this->assertEquals($expectedResponse->getResourceDescriptors()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); $this->assertSame('/google.logging.v2.LoggingServiceV2/ListMonitoredResourceDescriptors', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); } @@ -334,22 +326,20 @@ public function listMonitoredResourceDescriptorsTest() public function listMonitoredResourceDescriptorsExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - try { $client->listMonitoredResourceDescriptors(); // If the $client method call did not throw, fail the test @@ -358,7 +348,6 @@ public function listMonitoredResourceDescriptorsExceptionTest() $this->assertEquals($status->code, $ex->getCode()); $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); } - // Call popReceivedCalls to ensure the stub is exhausted $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); @@ -367,77 +356,158 @@ public function listMonitoredResourceDescriptorsExceptionTest() /** * @test */ - public function listLogsTest() + public function tailLogEntriesTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $logNamesElement = 'logNamesElement-1079688374'; - $logNames = [$logNamesElement]; - $expectedResponse = new ListLogsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setLogNames($logNames); + $expectedResponse = new TailLogEntriesResponse(); $transport->addResponse($expectedResponse); - + $expectedResponse2 = new TailLogEntriesResponse(); + $transport->addResponse($expectedResponse2); + $expectedResponse3 = new TailLogEntriesResponse(); + $transport->addResponse($expectedResponse3); // Mock request - $formattedParent = $client->projectName('[PROJECT]'); + $resourceNames = []; + $request = new TailLogEntriesRequest(); + $request->setResourceNames($resourceNames); + $resourceNames2 = []; + $request2 = new TailLogEntriesRequest(); + $request2->setResourceNames($resourceNames2); + $resourceNames3 = []; + $request3 = new TailLogEntriesRequest(); + $request3->setResourceNames($resourceNames3); + $bidi = $client->tailLogEntries(); + $this->assertInstanceOf(BidiStream::class, $bidi); + $bidi->write($request); + $responses = []; + $responses[] = $bidi->read(); + $bidi->writeAll([ + $request2, + $request3, + ]); + foreach ($bidi->closeWriteAndReadAll() as $response) { + $responses[] = $response; + } - $response = $client->listLogs($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getLogNames()[0], $resources[0]); + $expectedResponses = []; + $expectedResponses[] = $expectedResponse; + $expectedResponses[] = $expectedResponse2; + $expectedResponses[] = $expectedResponse3; + $this->assertEquals($expectedResponses, $responses); + $createStreamRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($createStreamRequests)); + $streamFuncCall = $createStreamRequests[0]->getFuncCall(); + $streamRequestObject = $createStreamRequests[0]->getRequestObject(); + $this->assertSame('/google.logging.v2.LoggingServiceV2/TailLogEntries', $streamFuncCall); + $this->assertNull($streamRequestObject); + $callObjects = $transport->popCallObjects(); + $this->assertSame(1, count($callObjects)); + $bidiCall = $callObjects[0]; + $writeRequests = $bidiCall->popReceivedCalls(); + $expectedRequests = []; + $expectedRequests[] = $request; + $expectedRequests[] = $request2; + $expectedRequests[] = $request3; + $this->assertEquals($expectedRequests, $writeRequests); + $this->assertTrue($transport->isExhausted()); + } + /** + * @test + */ + public function tailLogEntriesExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->setStreamingStatus($status); + $this->assertTrue($transport->isExhausted()); + $bidi = $client->tailLogEntries(); + $results = $bidi->closeWriteAndReadAll(); + try { + iterator_to_array($results); + // If the close stream method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function writeLogEntriesTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new WriteLogEntriesResponse(); + $transport->addResponse($expectedResponse); + // Mock request + $entries = []; + $response = $client->writeLogEntries($entries); + $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.logging.v2.LoggingServiceV2/ListLogs', $actualFuncCall); - - $actualValue = $actualRequestObject->getParent(); - - $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertSame('/google.logging.v2.LoggingServiceV2/WriteLogEntries', $actualFuncCall); + $actualValue = $actualRequestObject->getEntries(); + $this->assertProtobufEquals($entries, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function listLogsExceptionTest() + public function writeLogEntriesExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedParent = $client->projectName('[PROJECT]'); - + $entries = []; try { - $client->listLogs($formattedParent); + $client->writeLogEntries($entries); // If the $client method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { $this->assertEquals($status->code, $ex->getCode()); $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); } - // Call popReceivedCalls to ensure the stub is exhausted $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); diff --git a/Logging/tests/Unit/V2/MetricsServiceV2ClientTest.php b/Logging/tests/Unit/V2/MetricsServiceV2ClientTest.php index e941a1cd7e43..c61eaf4483f8 100644 --- a/Logging/tests/Unit/V2/MetricsServiceV2ClientTest.php +++ b/Logging/tests/Unit/V2/MetricsServiceV2ClientTest.php @@ -22,20 +22,22 @@ namespace Google\Cloud\Logging\Tests\Unit\V2; -use Google\Cloud\Logging\V2\MetricsServiceV2Client; use Google\ApiCore\ApiException; + use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; + use Google\Cloud\Logging\V2\ListLogMetricsResponse; use Google\Cloud\Logging\V2\LogMetric; -use Google\Protobuf\Any; +use Google\Cloud\Logging\V2\MetricsServiceV2Client; use Google\Protobuf\GPBEmpty; use Google\Rpc\Code; use stdClass; /** * @group logging + * * @group gapic */ class MetricsServiceV2ClientTest extends GeneratedTest @@ -53,9 +55,7 @@ private function createTransport($deserialize = null) */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class) - ->disableOriginalConstructor() - ->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); } /** @@ -66,84 +66,86 @@ private function createClient(array $options = []) $options += [ 'credentials' => $this->createCredentials(), ]; - return new MetricsServiceV2Client($options); } /** * @test */ - public function listLogMetricsTest() + public function createLogMetricTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $metricsElement = new LogMetric(); - $metrics = [$metricsElement]; - $expectedResponse = new ListLogMetricsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setMetrics($metrics); + $name = 'name3373707'; + $description = 'description-1724546052'; + $filter = 'filter-1274492040'; + $valueExtractor = 'valueExtractor2047672534'; + $expectedResponse = new LogMetric(); + $expectedResponse->setName($name); + $expectedResponse->setDescription($description); + $expectedResponse->setFilter($filter); + $expectedResponse->setValueExtractor($valueExtractor); $transport->addResponse($expectedResponse); - // Mock request $formattedParent = $client->projectName('[PROJECT]'); - - $response = $client->listLogMetrics($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getMetrics()[0], $resources[0]); - + $metric = new LogMetric(); + $metricName = 'metricName-610759589'; + $metric->setName($metricName); + $metricFilter = 'metricFilter1248897352'; + $metric->setFilter($metricFilter); + $response = $client->createLogMetric($formattedParent, $metric); + $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.logging.v2.MetricsServiceV2/ListLogMetrics', $actualFuncCall); - + $this->assertSame('/google.logging.v2.MetricsServiceV2/CreateLogMetric', $actualFuncCall); $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getMetric(); + $this->assertProtobufEquals($metric, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function listLogMetricsExceptionTest() + public function createLogMetricExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request $formattedParent = $client->projectName('[PROJECT]'); - + $metric = new LogMetric(); + $metricName = 'metricName-610759589'; + $metric->setName($metricName); + $metricFilter = 'metricFilter1248897352'; + $metric->setFilter($metricFilter); try { - $client->listLogMetrics($formattedParent); + $client->createLogMetric($formattedParent, $metric); // If the $client method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { $this->assertEquals($status->code, $ex->getCode()); $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); } - // Call popReceivedCalls to ensure the stub is exhausted $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); @@ -152,77 +154,59 @@ public function listLogMetricsExceptionTest() /** * @test */ - public function getLogMetricTest() + public function deleteLogMetricTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $description = 'description-1724546052'; - $filter = 'filter-1274492040'; - $valueExtractor = 'valueExtractor2047672534'; - $expectedResponse = new LogMetric(); - $expectedResponse->setName($name); - $expectedResponse->setDescription($description); - $expectedResponse->setFilter($filter); - $expectedResponse->setValueExtractor($valueExtractor); + $expectedResponse = new GPBEmpty(); $transport->addResponse($expectedResponse); - // Mock request - $formattedMetricName = $client->metricName('[PROJECT]', '[METRIC]'); - - $response = $client->getLogMetric($formattedMetricName); - $this->assertEquals($expectedResponse, $response); + $formattedMetricName = $client->logMetricName('[PROJECT]', '[METRIC]'); + $client->deleteLogMetric($formattedMetricName); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.logging.v2.MetricsServiceV2/GetLogMetric', $actualFuncCall); - + $this->assertSame('/google.logging.v2.MetricsServiceV2/DeleteLogMetric', $actualFuncCall); $actualValue = $actualRequestObject->getMetricName(); - $this->assertProtobufEquals($formattedMetricName, $actualValue); - $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function getLogMetricExceptionTest() + public function deleteLogMetricExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedMetricName = $client->metricName('[PROJECT]', '[METRIC]'); - + $formattedMetricName = $client->logMetricName('[PROJECT]', '[METRIC]'); try { - $client->getLogMetric($formattedMetricName); + $client->deleteLogMetric($formattedMetricName); // If the $client method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { $this->assertEquals($status->code, $ex->getCode()); $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); } - // Call popReceivedCalls to ensure the stub is exhausted $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); @@ -231,13 +215,13 @@ public function getLogMetricExceptionTest() /** * @test */ - public function createLogMetricTest() + public function getLogMetricTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response $name = 'name3373707'; $description = 'description-1724546052'; @@ -249,64 +233,50 @@ public function createLogMetricTest() $expectedResponse->setFilter($filter); $expectedResponse->setValueExtractor($valueExtractor); $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $client->projectName('[PROJECT]'); - $metric = new LogMetric(); - - $response = $client->createLogMetric($formattedParent, $metric); + $formattedMetricName = $client->logMetricName('[PROJECT]', '[METRIC]'); + $response = $client->getLogMetric($formattedMetricName); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.logging.v2.MetricsServiceV2/CreateLogMetric', $actualFuncCall); - - $actualValue = $actualRequestObject->getParent(); - - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getMetric(); - - $this->assertProtobufEquals($metric, $actualValue); - + $this->assertSame('/google.logging.v2.MetricsServiceV2/GetLogMetric', $actualFuncCall); + $actualValue = $actualRequestObject->getMetricName(); + $this->assertProtobufEquals($formattedMetricName, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function createLogMetricExceptionTest() + public function getLogMetricExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedParent = $client->projectName('[PROJECT]'); - $metric = new LogMetric(); - + $formattedMetricName = $client->logMetricName('[PROJECT]', '[METRIC]'); try { - $client->createLogMetric($formattedParent, $metric); + $client->getLogMetric($formattedMetricName); // If the $client method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { $this->assertEquals($status->code, $ex->getCode()); $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); } - // Call popReceivedCalls to ensure the stub is exhausted $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); @@ -315,82 +285,70 @@ public function createLogMetricExceptionTest() /** * @test */ - public function updateLogMetricTest() + public function listLogMetricsTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $description = 'description-1724546052'; - $filter = 'filter-1274492040'; - $valueExtractor = 'valueExtractor2047672534'; - $expectedResponse = new LogMetric(); - $expectedResponse->setName($name); - $expectedResponse->setDescription($description); - $expectedResponse->setFilter($filter); - $expectedResponse->setValueExtractor($valueExtractor); + $nextPageToken = ''; + $metricsElement = new LogMetric(); + $metrics = [ + $metricsElement, + ]; + $expectedResponse = new ListLogMetricsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setMetrics($metrics); $transport->addResponse($expectedResponse); - // Mock request - $formattedMetricName = $client->metricName('[PROJECT]', '[METRIC]'); - $metric = new LogMetric(); - - $response = $client->updateLogMetric($formattedMetricName, $metric); - $this->assertEquals($expectedResponse, $response); + $formattedParent = $client->projectName('[PROJECT]'); + $response = $client->listLogMetrics($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getMetrics()[0], $resources[0]); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.logging.v2.MetricsServiceV2/UpdateLogMetric', $actualFuncCall); - - $actualValue = $actualRequestObject->getMetricName(); - - $this->assertProtobufEquals($formattedMetricName, $actualValue); - $actualValue = $actualRequestObject->getMetric(); - - $this->assertProtobufEquals($metric, $actualValue); - + $this->assertSame('/google.logging.v2.MetricsServiceV2/ListLogMetrics', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function updateLogMetricExceptionTest() + public function listLogMetricsExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedMetricName = $client->metricName('[PROJECT]', '[METRIC]'); - $metric = new LogMetric(); - + $formattedParent = $client->projectName('[PROJECT]'); try { - $client->updateLogMetric($formattedMetricName, $metric); + $client->listLogMetrics($formattedParent); // If the $client method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { $this->assertEquals($status->code, $ex->getCode()); $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); } - // Call popReceivedCalls to ensure the stub is exhausted $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); @@ -399,68 +357,80 @@ public function updateLogMetricExceptionTest() /** * @test */ - public function deleteLogMetricTest() + public function updateLogMetricTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); + $name = 'name3373707'; + $description = 'description-1724546052'; + $filter = 'filter-1274492040'; + $valueExtractor = 'valueExtractor2047672534'; + $expectedResponse = new LogMetric(); + $expectedResponse->setName($name); + $expectedResponse->setDescription($description); + $expectedResponse->setFilter($filter); + $expectedResponse->setValueExtractor($valueExtractor); $transport->addResponse($expectedResponse); - // Mock request - $formattedMetricName = $client->metricName('[PROJECT]', '[METRIC]'); - - $client->deleteLogMetric($formattedMetricName); + $formattedMetricName = $client->logMetricName('[PROJECT]', '[METRIC]'); + $metric = new LogMetric(); + $metricName = 'metricName-610759589'; + $metric->setName($metricName); + $metricFilter = 'metricFilter1248897352'; + $metric->setFilter($metricFilter); + $response = $client->updateLogMetric($formattedMetricName, $metric); + $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.logging.v2.MetricsServiceV2/DeleteLogMetric', $actualFuncCall); - + $this->assertSame('/google.logging.v2.MetricsServiceV2/UpdateLogMetric', $actualFuncCall); $actualValue = $actualRequestObject->getMetricName(); - $this->assertProtobufEquals($formattedMetricName, $actualValue); - + $actualValue = $actualRequestObject->getMetric(); + $this->assertProtobufEquals($metric, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function deleteLogMetricExceptionTest() + public function updateLogMetricExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedMetricName = $client->metricName('[PROJECT]', '[METRIC]'); - + $formattedMetricName = $client->logMetricName('[PROJECT]', '[METRIC]'); + $metric = new LogMetric(); + $metricName = 'metricName-610759589'; + $metric->setName($metricName); + $metricFilter = 'metricFilter1248897352'; + $metric->setFilter($metricFilter); try { - $client->deleteLogMetric($formattedMetricName); + $client->updateLogMetric($formattedMetricName, $metric); // If the $client method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { $this->assertEquals($status->code, $ex->getCode()); $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); } - // Call popReceivedCalls to ensure the stub is exhausted $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted());