From 6e8b76b5399b1692f8d4d01404e1d4eebd039846 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Mon, 23 Mar 2026 16:09:51 -0700 Subject: [PATCH 1/2] chore!: [ErrorReporting] remove deprecated GAPICs (#9015) chore!(ErrorReporting): remove deprecated GAPICs --- .../ErrorGroupServiceClient/get_group.php | 2 +- .../ErrorGroupServiceClient/update_group.php | 2 +- .../ErrorStatsServiceClient/delete_events.php | 2 +- .../ErrorStatsServiceClient/list_events.php | 2 +- .../list_group_stats.php | 2 +- .../report_error_event.php | 2 +- .../Client/ErrorGroupServiceClient.php | 2 +- .../Client/ErrorStatsServiceClient.php | 2 +- .../Client/ReportErrorsServiceClient.php | 2 +- src/V1beta1/ErrorGroupServiceClient.php | 36 -- src/V1beta1/ErrorGroupServiceGrpcClient.php | 66 -- src/V1beta1/ErrorStatsServiceClient.php | 36 -- src/V1beta1/ErrorStatsServiceGrpcClient.php | 81 --- .../Gapic/ErrorGroupServiceGapicClient.php | 362 ----------- .../Gapic/ErrorStatsServiceGapicClient.php | 581 ------------------ .../Gapic/ReportErrorsServiceGapicClient.php | 328 ---------- src/V1beta1/QueryTimeRange_Period.php | 16 - src/V1beta1/README.md | 20 - src/V1beta1/ReportErrorsServiceClient.php | 36 -- src/V1beta1/ReportErrorsServiceGrpcClient.php | 63 -- .../error_group_service_descriptor_config.php | 2 +- ...error_group_service_rest_client_config.php | 2 +- .../error_stats_service_descriptor_config.php | 2 +- ...error_stats_service_rest_client_config.php | 2 +- ...eport_errors_service_descriptor_config.php | 2 +- ...port_errors_service_rest_client_config.php | 2 +- .../Client/ErrorGroupServiceClientTest.php | 2 +- .../Client/ErrorStatsServiceClientTest.php | 2 +- .../Client/ReportErrorsServiceClientTest.php | 2 +- .../V1beta1/ErrorGroupServiceClientTest.php | 185 ------ .../V1beta1/ErrorStatsServiceClientTest.php | 263 -------- .../V1beta1/ReportErrorsServiceClientTest.php | 133 ---- 32 files changed, 18 insertions(+), 2224 deletions(-) delete mode 100644 src/V1beta1/ErrorGroupServiceClient.php delete mode 100644 src/V1beta1/ErrorGroupServiceGrpcClient.php delete mode 100644 src/V1beta1/ErrorStatsServiceClient.php delete mode 100644 src/V1beta1/ErrorStatsServiceGrpcClient.php delete mode 100644 src/V1beta1/Gapic/ErrorGroupServiceGapicClient.php delete mode 100644 src/V1beta1/Gapic/ErrorStatsServiceGapicClient.php delete mode 100644 src/V1beta1/Gapic/ReportErrorsServiceGapicClient.php delete mode 100644 src/V1beta1/QueryTimeRange_Period.php delete mode 100644 src/V1beta1/README.md delete mode 100644 src/V1beta1/ReportErrorsServiceClient.php delete mode 100644 src/V1beta1/ReportErrorsServiceGrpcClient.php delete mode 100644 tests/Unit/V1beta1/ErrorGroupServiceClientTest.php delete mode 100644 tests/Unit/V1beta1/ErrorStatsServiceClientTest.php delete mode 100644 tests/Unit/V1beta1/ReportErrorsServiceClientTest.php diff --git a/samples/V1beta1/ErrorGroupServiceClient/get_group.php b/samples/V1beta1/ErrorGroupServiceClient/get_group.php index 6631d4d..2b9ce3b 100644 --- a/samples/V1beta1/ErrorGroupServiceClient/get_group.php +++ b/samples/V1beta1/ErrorGroupServiceClient/get_group.php @@ -1,6 +1,6 @@ _simpleRequest('/google.devtools.clouderrorreporting.v1beta1.ErrorGroupService/GetGroup', - $argument, - ['\Google\Cloud\ErrorReporting\V1beta1\ErrorGroup', 'decode'], - $metadata, $options); - } - - /** - * Replace the data for the specified group. - * Fails if the group does not exist. - * @param \Google\Cloud\ErrorReporting\V1beta1\UpdateGroupRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateGroup(\Google\Cloud\ErrorReporting\V1beta1\UpdateGroupRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.devtools.clouderrorreporting.v1beta1.ErrorGroupService/UpdateGroup', - $argument, - ['\Google\Cloud\ErrorReporting\V1beta1\ErrorGroup', 'decode'], - $metadata, $options); - } - -} diff --git a/src/V1beta1/ErrorStatsServiceClient.php b/src/V1beta1/ErrorStatsServiceClient.php deleted file mode 100644 index 8960d20..0000000 --- a/src/V1beta1/ErrorStatsServiceClient.php +++ /dev/null @@ -1,36 +0,0 @@ -_simpleRequest('/google.devtools.clouderrorreporting.v1beta1.ErrorStatsService/ListGroupStats', - $argument, - ['\Google\Cloud\ErrorReporting\V1beta1\ListGroupStatsResponse', 'decode'], - $metadata, $options); - } - - /** - * Lists the specified events. - * @param \Google\Cloud\ErrorReporting\V1beta1\ListEventsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListEvents(\Google\Cloud\ErrorReporting\V1beta1\ListEventsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.devtools.clouderrorreporting.v1beta1.ErrorStatsService/ListEvents', - $argument, - ['\Google\Cloud\ErrorReporting\V1beta1\ListEventsResponse', 'decode'], - $metadata, $options); - } - - /** - * Deletes all error events of a given project. - * @param \Google\Cloud\ErrorReporting\V1beta1\DeleteEventsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteEvents(\Google\Cloud\ErrorReporting\V1beta1\DeleteEventsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.devtools.clouderrorreporting.v1beta1.ErrorStatsService/DeleteEvents', - $argument, - ['\Google\Cloud\ErrorReporting\V1beta1\DeleteEventsResponse', 'decode'], - $metadata, $options); - } - -} diff --git a/src/V1beta1/Gapic/ErrorGroupServiceGapicClient.php b/src/V1beta1/Gapic/ErrorGroupServiceGapicClient.php deleted file mode 100644 index ba69b96..0000000 --- a/src/V1beta1/Gapic/ErrorGroupServiceGapicClient.php +++ /dev/null @@ -1,362 +0,0 @@ -errorGroupName('[PROJECT]', '[GROUP]'); - * $response = $errorGroupServiceClient->getGroup($formattedGroupName); - * } finally { - * $errorGroupServiceClient->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 - * - * @deprecated Please use the new service client {@see \Google\Cloud\ErrorReporting\V1beta1\Client\ErrorGroupServiceClient}. - */ -class ErrorGroupServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.devtools.clouderrorreporting.v1beta1.ErrorGroupService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'clouderrorreporting.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'clouderrorreporting.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static $errorGroupNameTemplate; - - private static $pathTemplateMap; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/error_group_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/error_group_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/error_group_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/error_group_service_rest_client_config.php', - ], - ], - ]; - } - - private static function getErrorGroupNameTemplate() - { - if (self::$errorGroupNameTemplate == null) { - self::$errorGroupNameTemplate = new PathTemplate('projects/{project}/groups/{group}'); - } - - return self::$errorGroupNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'errorGroup' => self::getErrorGroupNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * Formats a string containing the fully-qualified path to represent a error_group - * resource. - * - * @param string $project - * @param string $group - * - * @return string The formatted error_group resource. - * - * @experimental - */ - public static function errorGroupName($project, $group) - { - return self::getErrorGroupNameTemplate()->render([ - 'project' => $project, - 'group' => $group, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - errorGroup: projects/{project}/groups/{group} - * - * 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. - * - * @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"); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException("Input did not match any known format. Input: $formattedName"); - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default 'clouderrorreporting.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@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()} . - * @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. - * @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. - * @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' => [...], - * ]; - * 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 = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** - * Get the specified group. - * - * Sample code: - * ``` - * $errorGroupServiceClient = new ErrorGroupServiceClient(); - * try { - * $formattedGroupName = $errorGroupServiceClient->errorGroupName('[PROJECT]', '[GROUP]'); - * $response = $errorGroupServiceClient->getGroup($formattedGroupName); - * } finally { - * $errorGroupServiceClient->close(); - * } - * ``` - * - * @param string $groupName Required. The group resource name. Written as either - * `projects/{projectID}/groups/{group_id}` or - * `projects/{projectID}/locations/{location}/groups/{group_id}`. Call - * [groupStats.list] - * [google.devtools.clouderrorreporting.v1beta1.ErrorStatsService.ListGroupStats] - * to return a list of groups belonging to this project. - * - * Examples: `projects/my-project-123/groups/my-group`, - * `projects/my-project-123/locations/global/groups/my-group` - * - * In the group resource name, the `group_id` is a unique identifier for a - * particular error group. The identifier is derived from key parts of the - * error-log content and is treated as Service Data. For information about - * how Service Data is handled, see [Google Cloud Privacy - * Notice](https://cloud.google.com/terms/cloud-privacy-notice). - * - * For a list of supported locations, see [Supported - * Regions](https://cloud.google.com/logging/docs/region-support). `global` is - * the default when unspecified. - * @param array $optionalArgs { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\ErrorReporting\V1beta1\ErrorGroup - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function getGroup($groupName, array $optionalArgs = []) - { - $request = new GetGroupRequest(); - $requestParamHeaders = []; - $request->setGroupName($groupName); - $requestParamHeaders['group_name'] = $groupName; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetGroup', ErrorGroup::class, $optionalArgs, $request)->wait(); - } - - /** - * Replace the data for the specified group. - * Fails if the group does not exist. - * - * Sample code: - * ``` - * $errorGroupServiceClient = new ErrorGroupServiceClient(); - * try { - * $group = new ErrorGroup(); - * $response = $errorGroupServiceClient->updateGroup($group); - * } finally { - * $errorGroupServiceClient->close(); - * } - * ``` - * - * @param ErrorGroup $group Required. The group which replaces the resource on the server. - * @param array $optionalArgs { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\ErrorReporting\V1beta1\ErrorGroup - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function updateGroup($group, array $optionalArgs = []) - { - $request = new UpdateGroupRequest(); - $requestParamHeaders = []; - $request->setGroup($group); - $requestParamHeaders['group.name'] = $group->getName(); - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('UpdateGroup', ErrorGroup::class, $optionalArgs, $request)->wait(); - } -} diff --git a/src/V1beta1/Gapic/ErrorStatsServiceGapicClient.php b/src/V1beta1/Gapic/ErrorStatsServiceGapicClient.php deleted file mode 100644 index 8ba234a..0000000 --- a/src/V1beta1/Gapic/ErrorStatsServiceGapicClient.php +++ /dev/null @@ -1,581 +0,0 @@ -projectName('[PROJECT]'); - * $response = $errorStatsServiceClient->deleteEvents($formattedProjectName); - * } finally { - * $errorStatsServiceClient->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 - * - * @deprecated Please use the new service client {@see \Google\Cloud\ErrorReporting\V1beta1\Client\ErrorStatsServiceClient}. - */ -class ErrorStatsServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.devtools.clouderrorreporting.v1beta1.ErrorStatsService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'clouderrorreporting.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'clouderrorreporting.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - 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/error_stats_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/error_stats_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/error_stats_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/error_stats_service_rest_client_config.php', - ], - ], - ]; - } - - private static function getProjectNameTemplate() - { - if (self::$projectNameTemplate == null) { - self::$projectNameTemplate = new PathTemplate('projects/{project}'); - } - - return self::$projectNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'project' => self::getProjectNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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) - { - return self::getProjectNameTemplate()->render([ - 'project' => $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 - * - 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. - * - * @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. - * - * @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"); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException("Input did not match any known format. Input: $formattedName"); - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default 'clouderrorreporting.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@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()} . - * @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. - * @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. - * @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' => [...], - * ]; - * 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 = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** - * Deletes all error events of a given project. - * - * Sample code: - * ``` - * $errorStatsServiceClient = new ErrorStatsServiceClient(); - * try { - * $formattedProjectName = $errorStatsServiceClient->projectName('[PROJECT]'); - * $response = $errorStatsServiceClient->deleteEvents($formattedProjectName); - * } finally { - * $errorStatsServiceClient->close(); - * } - * ``` - * - * @param string $projectName Required. The resource name of the Google Cloud Platform project. Written - * as `projects/{projectID}` or `projects/{projectID}/locations/{location}`, - * where `{projectID}` is the [Google Cloud Platform project - * ID](https://support.google.com/cloud/answer/6158840) and `{location}` is - * a Cloud region. - * - * Examples: `projects/my-project-123`, - * `projects/my-project-123/locations/global`. - * - * For a list of supported locations, see [Supported - * Regions](https://cloud.google.com/logging/docs/region-support). `global` is - * the default when unspecified. - * @param array $optionalArgs { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\ErrorReporting\V1beta1\DeleteEventsResponse - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function deleteEvents($projectName, array $optionalArgs = []) - { - $request = new DeleteEventsRequest(); - $requestParamHeaders = []; - $request->setProjectName($projectName); - $requestParamHeaders['project_name'] = $projectName; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DeleteEvents', DeleteEventsResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Lists the specified events. - * - * Sample code: - * ``` - * $errorStatsServiceClient = new ErrorStatsServiceClient(); - * try { - * $formattedProjectName = $errorStatsServiceClient->projectName('[PROJECT]'); - * $groupId = 'group_id'; - * // Iterate over pages of elements - * $pagedResponse = $errorStatsServiceClient->listEvents($formattedProjectName, $groupId); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $errorStatsServiceClient->listEvents($formattedProjectName, $groupId); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $errorStatsServiceClient->close(); - * } - * ``` - * - * @param string $projectName Required. The resource name of the Google Cloud Platform project. Written - * as `projects/{projectID}` or `projects/{projectID}/locations/{location}`, - * where `{projectID}` is the [Google Cloud Platform project - * ID](https://support.google.com/cloud/answer/6158840) and `{location}` is - * a Cloud region. - * - * Examples: `projects/my-project-123`, - * `projects/my-project-123/locations/global`. - * - * For a list of supported locations, see [Supported - * Regions](https://cloud.google.com/logging/docs/region-support). `global` is - * the default when unspecified. - * @param string $groupId Required. The group for which events shall be returned. - * The `group_id` is a unique identifier for a particular error group. The - * identifier is derived from key parts of the error-log content and is - * treated as Service Data. For information about how Service Data - * is handled, see [Google Cloud Privacy - * Notice](https://cloud.google.com/terms/cloud-privacy-notice). - * @param array $optionalArgs { - * Optional. - * - * @type ServiceContextFilter $serviceFilter - * Optional. List only ErrorGroups which belong to a service context that - * matches the filter. - * Data for all service contexts is returned if this field is not specified. - * @type QueryTimeRange $timeRange - * Optional. List only data for the given time range. - * If not set a default time range is used. The field time_range_begin - * in the response will specify the beginning of this time range. - * @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 RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\ApiCore\PagedListResponse - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function listEvents($projectName, $groupId, array $optionalArgs = []) - { - $request = new ListEventsRequest(); - $requestParamHeaders = []; - $request->setProjectName($projectName); - $request->setGroupId($groupId); - $requestParamHeaders['project_name'] = $projectName; - if (isset($optionalArgs['serviceFilter'])) { - $request->setServiceFilter($optionalArgs['serviceFilter']); - } - - if (isset($optionalArgs['timeRange'])) { - $request->setTimeRange($optionalArgs['timeRange']); - } - - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->getPagedListResponse('ListEvents', $optionalArgs, ListEventsResponse::class, $request); - } - - /** - * Lists the specified groups. - * - * Sample code: - * ``` - * $errorStatsServiceClient = new ErrorStatsServiceClient(); - * try { - * $formattedProjectName = $errorStatsServiceClient->projectName('[PROJECT]'); - * // Iterate over pages of elements - * $pagedResponse = $errorStatsServiceClient->listGroupStats($formattedProjectName); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $errorStatsServiceClient->listGroupStats($formattedProjectName); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $errorStatsServiceClient->close(); - * } - * ``` - * - * @param string $projectName Required. The resource name of the Google Cloud Platform project. Written - * as `projects/{projectID}` or `projects/{projectNumber}`, where - * `{projectID}` and `{projectNumber}` can be found in the - * [Google Cloud console](https://support.google.com/cloud/answer/6158840). - * It may also include a location, such as - * `projects/{projectID}/locations/{location}` where `{location}` is a cloud - * region. - * - * Examples: `projects/my-project-123`, `projects/5551234`, - * `projects/my-project-123/locations/us-central1`, - * `projects/5551234/locations/us-central1`. - * - * For a list of supported locations, see [Supported - * Regions](https://cloud.google.com/logging/docs/region-support). `global` is - * the default when unspecified. Use `-` as a wildcard to request group stats - * from all regions. - * @param array $optionalArgs { - * Optional. - * - * @type string[] $groupId - * Optional. List all [ErrorGroupStats] - * [google.devtools.clouderrorreporting.v1beta1.ErrorGroupStats] with these - * IDs. The `group_id` is a unique identifier for a particular error group. - * The identifier is derived from key parts of the error-log content and is - * treated as Service Data. For information about how Service Data - * is handled, see [Google Cloud Privacy Notice] - * (https://cloud.google.com/terms/cloud-privacy-notice). - * @type ServiceContextFilter $serviceFilter - * Optional. List only [ErrorGroupStats] - * [google.devtools.clouderrorreporting.v1beta1.ErrorGroupStats] which belong - * to a service context that matches the filter. Data for all service contexts - * is returned if this field is not specified. - * @type QueryTimeRange $timeRange - * Optional. List data for the given time range. - * If not set, a default time range is used. The field - * [time_range_begin] - * [google.devtools.clouderrorreporting.v1beta1.ListGroupStatsResponse.time_range_begin] - * in the response will specify the beginning of this time range. Only - * [ErrorGroupStats] - * [google.devtools.clouderrorreporting.v1beta1.ErrorGroupStats] with a - * non-zero count in the given time range are returned, unless the request - * contains an explicit [group_id] - * [google.devtools.clouderrorreporting.v1beta1.ListGroupStatsRequest.group_id] - * list. If a [group_id] - * [google.devtools.clouderrorreporting.v1beta1.ListGroupStatsRequest.group_id] - * list is given, also [ErrorGroupStats] - * [google.devtools.clouderrorreporting.v1beta1.ErrorGroupStats] with zero - * occurrences are returned. - * @type Duration $timedCountDuration - * Optional. The preferred duration for a single returned [TimedCount] - * [google.devtools.clouderrorreporting.v1beta1.TimedCount]. If not set, no - * timed counts are returned. - * @type int $alignment - * Optional. The alignment of the timed counts to be returned. - * Default is `ALIGNMENT_EQUAL_AT_END`. - * For allowed values, use constants defined on {@see \Google\Cloud\ErrorReporting\V1beta1\TimedCountAlignment} - * @type Timestamp $alignmentTime - * Optional. Time where the timed counts shall be aligned if rounded - * alignment is chosen. Default is 00:00 UTC. - * @type int $order - * Optional. The sort order in which the results are returned. - * Default is `COUNT_DESC`. - * For allowed values, use constants defined on {@see \Google\Cloud\ErrorReporting\V1beta1\ErrorGroupOrder} - * @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 RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\ApiCore\PagedListResponse - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function listGroupStats($projectName, array $optionalArgs = []) - { - $request = new ListGroupStatsRequest(); - $requestParamHeaders = []; - $request->setProjectName($projectName); - $requestParamHeaders['project_name'] = $projectName; - if (isset($optionalArgs['groupId'])) { - $request->setGroupId($optionalArgs['groupId']); - } - - if (isset($optionalArgs['serviceFilter'])) { - $request->setServiceFilter($optionalArgs['serviceFilter']); - } - - if (isset($optionalArgs['timeRange'])) { - $request->setTimeRange($optionalArgs['timeRange']); - } - - if (isset($optionalArgs['timedCountDuration'])) { - $request->setTimedCountDuration($optionalArgs['timedCountDuration']); - } - - if (isset($optionalArgs['alignment'])) { - $request->setAlignment($optionalArgs['alignment']); - } - - if (isset($optionalArgs['alignmentTime'])) { - $request->setAlignmentTime($optionalArgs['alignmentTime']); - } - - if (isset($optionalArgs['order'])) { - $request->setOrder($optionalArgs['order']); - } - - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->getPagedListResponse('ListGroupStats', $optionalArgs, ListGroupStatsResponse::class, $request); - } -} diff --git a/src/V1beta1/Gapic/ReportErrorsServiceGapicClient.php b/src/V1beta1/Gapic/ReportErrorsServiceGapicClient.php deleted file mode 100644 index 250a3dd..0000000 --- a/src/V1beta1/Gapic/ReportErrorsServiceGapicClient.php +++ /dev/null @@ -1,328 +0,0 @@ -projectName('[PROJECT]'); - * $event = new ReportedErrorEvent(); - * $response = $reportErrorsServiceClient->reportErrorEvent($formattedProjectName, $event); - * } finally { - * $reportErrorsServiceClient->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 - * - * @deprecated Please use the new service client {@see \Google\Cloud\ErrorReporting\V1beta1\Client\ReportErrorsServiceClient}. - */ -class ReportErrorsServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.devtools.clouderrorreporting.v1beta1.ReportErrorsService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'clouderrorreporting.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'clouderrorreporting.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - 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/report_errors_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/report_errors_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/report_errors_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/report_errors_service_rest_client_config.php', - ], - ], - ]; - } - - private static function getProjectNameTemplate() - { - if (self::$projectNameTemplate == null) { - self::$projectNameTemplate = new PathTemplate('projects/{project}'); - } - - return self::$projectNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'project' => self::getProjectNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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) - { - return self::getProjectNameTemplate()->render([ - 'project' => $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 - * - 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. - * - * @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. - * - * @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"); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException("Input did not match any known format. Input: $formattedName"); - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default 'clouderrorreporting.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@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()} . - * @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. - * @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. - * @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' => [...], - * ]; - * 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 = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** - * Report an individual error event and record the event to a log. - * - * This endpoint accepts **either** an OAuth token, - * **or** an [API key](https://support.google.com/cloud/answer/6158862) - * for authentication. To use an API key, append it to the URL as the value of - * a `key` parameter. For example: - * - * `POST - * https://clouderrorreporting.googleapis.com/v1beta1/{projectName}/events:report?key=123ABC456` - * - * **Note:** [Error Reporting] (https://cloud.google.com/error-reporting) - * is a service built on Cloud Logging and can analyze log entries when all of - * the following are true: - * - * * Customer-managed encryption keys (CMEK) are disabled on the log bucket. - * * The log bucket satisfies one of the following: - * * The log bucket is stored in the same project where the logs - * originated. - * * The logs were routed to a project, and then that project stored those - * logs in a log bucket that it owns. - * - * Sample code: - * ``` - * $reportErrorsServiceClient = new ReportErrorsServiceClient(); - * try { - * $formattedProjectName = $reportErrorsServiceClient->projectName('[PROJECT]'); - * $event = new ReportedErrorEvent(); - * $response = $reportErrorsServiceClient->reportErrorEvent($formattedProjectName, $event); - * } finally { - * $reportErrorsServiceClient->close(); - * } - * ``` - * - * @param string $projectName Required. The resource name of the Google Cloud Platform project. Written - * as `projects/{projectId}`, where `{projectId}` is the - * [Google Cloud Platform project - * ID](https://support.google.com/cloud/answer/6158840). - * - * Example: // `projects/my-project-123`. - * @param ReportedErrorEvent $event Required. The error event to be reported. - * @param array $optionalArgs { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\ErrorReporting\V1beta1\ReportErrorEventResponse - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function reportErrorEvent($projectName, $event, array $optionalArgs = []) - { - $request = new ReportErrorEventRequest(); - $requestParamHeaders = []; - $request->setProjectName($projectName); - $request->setEvent($event); - $requestParamHeaders['project_name'] = $projectName; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('ReportErrorEvent', ReportErrorEventResponse::class, $optionalArgs, $request)->wait(); - } -} diff --git a/src/V1beta1/QueryTimeRange_Period.php b/src/V1beta1/QueryTimeRange_Period.php deleted file mode 100644 index 1ab3a0a..0000000 --- a/src/V1beta1/QueryTimeRange_Period.php +++ /dev/null @@ -1,16 +0,0 @@ -projectName('[PROJECT]'); -$event = new ReportedErrorEvent(); - -try { - $response = $reportErrorsServiceClient->reportErrorEvent($formattedProjectName, $event); -} finally { - $reportErrorsServiceClient->close(); -} -``` diff --git a/src/V1beta1/ReportErrorsServiceClient.php b/src/V1beta1/ReportErrorsServiceClient.php deleted file mode 100644 index 9b3a675..0000000 --- a/src/V1beta1/ReportErrorsServiceClient.php +++ /dev/null @@ -1,36 +0,0 @@ -_simpleRequest('/google.devtools.clouderrorreporting.v1beta1.ReportErrorsService/ReportErrorEvent', - $argument, - ['\Google\Cloud\ErrorReporting\V1beta1\ReportErrorEventResponse', 'decode'], - $metadata, $options); - } - -} diff --git a/src/V1beta1/resources/error_group_service_descriptor_config.php b/src/V1beta1/resources/error_group_service_descriptor_config.php index 75cdf96..b4513d5 100644 --- a/src/V1beta1/resources/error_group_service_descriptor_config.php +++ b/src/V1beta1/resources/error_group_service_descriptor_config.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return ErrorGroupServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new ErrorGroupServiceClient($options); - } - - /** @test */ - public function getGroupTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $groupId = 'groupId506361563'; - $expectedResponse = new ErrorGroup(); - $expectedResponse->setName($name); - $expectedResponse->setGroupId($groupId); - $transport->addResponse($expectedResponse); - // Mock request - $formattedGroupName = $gapicClient->errorGroupName('[PROJECT]', '[GROUP]'); - $response = $gapicClient->getGroup($formattedGroupName); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.devtools.clouderrorreporting.v1beta1.ErrorGroupService/GetGroup', $actualFuncCall); - $actualValue = $actualRequestObject->getGroupName(); - $this->assertProtobufEquals($formattedGroupName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getGroupExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $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 - $formattedGroupName = $gapicClient->errorGroupName('[PROJECT]', '[GROUP]'); - try { - $gapicClient->getGroup($formattedGroupName); - // If the $gapicClient 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 updateGroupTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $groupId = 'groupId506361563'; - $expectedResponse = new ErrorGroup(); - $expectedResponse->setName($name); - $expectedResponse->setGroupId($groupId); - $transport->addResponse($expectedResponse); - // Mock request - $group = new ErrorGroup(); - $response = $gapicClient->updateGroup($group); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.devtools.clouderrorreporting.v1beta1.ErrorGroupService/UpdateGroup', $actualFuncCall); - $actualValue = $actualRequestObject->getGroup(); - $this->assertProtobufEquals($group, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateGroupExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $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 - $group = new ErrorGroup(); - try { - $gapicClient->updateGroup($group); - // If the $gapicClient 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/tests/Unit/V1beta1/ErrorStatsServiceClientTest.php b/tests/Unit/V1beta1/ErrorStatsServiceClientTest.php deleted file mode 100644 index 20d458e..0000000 --- a/tests/Unit/V1beta1/ErrorStatsServiceClientTest.php +++ /dev/null @@ -1,263 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return ErrorStatsServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new ErrorStatsServiceClient($options); - } - - /** @test */ - public function deleteEventsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new DeleteEventsResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedProjectName = $gapicClient->projectName('[PROJECT]'); - $response = $gapicClient->deleteEvents($formattedProjectName); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.devtools.clouderrorreporting.v1beta1.ErrorStatsService/DeleteEvents', $actualFuncCall); - $actualValue = $actualRequestObject->getProjectName(); - $this->assertProtobufEquals($formattedProjectName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteEventsExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $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 - $formattedProjectName = $gapicClient->projectName('[PROJECT]'); - try { - $gapicClient->deleteEvents($formattedProjectName); - // If the $gapicClient 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 listEventsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $errorEventsElement = new ErrorEvent(); - $errorEvents = [ - $errorEventsElement, - ]; - $expectedResponse = new ListEventsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setErrorEvents($errorEvents); - $transport->addResponse($expectedResponse); - // Mock request - $formattedProjectName = $gapicClient->projectName('[PROJECT]'); - $groupId = 'groupId506361563'; - $response = $gapicClient->listEvents($formattedProjectName, $groupId); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getErrorEvents()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.devtools.clouderrorreporting.v1beta1.ErrorStatsService/ListEvents', $actualFuncCall); - $actualValue = $actualRequestObject->getProjectName(); - $this->assertProtobufEquals($formattedProjectName, $actualValue); - $actualValue = $actualRequestObject->getGroupId(); - $this->assertProtobufEquals($groupId, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listEventsExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $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 - $formattedProjectName = $gapicClient->projectName('[PROJECT]'); - $groupId = 'groupId506361563'; - try { - $gapicClient->listEvents($formattedProjectName, $groupId); - // If the $gapicClient 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 listGroupStatsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $errorGroupStatsElement = new ErrorGroupStats(); - $errorGroupStats = [ - $errorGroupStatsElement, - ]; - $expectedResponse = new ListGroupStatsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setErrorGroupStats($errorGroupStats); - $transport->addResponse($expectedResponse); - // Mock request - $formattedProjectName = $gapicClient->projectName('[PROJECT]'); - $response = $gapicClient->listGroupStats($formattedProjectName); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getErrorGroupStats()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.devtools.clouderrorreporting.v1beta1.ErrorStatsService/ListGroupStats', $actualFuncCall); - $actualValue = $actualRequestObject->getProjectName(); - $this->assertProtobufEquals($formattedProjectName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listGroupStatsExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $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 - $formattedProjectName = $gapicClient->projectName('[PROJECT]'); - try { - $gapicClient->listGroupStats($formattedProjectName); - // If the $gapicClient 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/tests/Unit/V1beta1/ReportErrorsServiceClientTest.php b/tests/Unit/V1beta1/ReportErrorsServiceClientTest.php deleted file mode 100644 index f427d89..0000000 --- a/tests/Unit/V1beta1/ReportErrorsServiceClientTest.php +++ /dev/null @@ -1,133 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return ReportErrorsServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new ReportErrorsServiceClient($options); - } - - /** @test */ - public function reportErrorEventTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new ReportErrorEventResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedProjectName = $gapicClient->projectName('[PROJECT]'); - $event = new ReportedErrorEvent(); - $eventServiceContext = new ServiceContext(); - $event->setServiceContext($eventServiceContext); - $eventMessage = 'eventMessage1863181325'; - $event->setMessage($eventMessage); - $response = $gapicClient->reportErrorEvent($formattedProjectName, $event); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.devtools.clouderrorreporting.v1beta1.ReportErrorsService/ReportErrorEvent', $actualFuncCall); - $actualValue = $actualRequestObject->getProjectName(); - $this->assertProtobufEquals($formattedProjectName, $actualValue); - $actualValue = $actualRequestObject->getEvent(); - $this->assertProtobufEquals($event, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function reportErrorEventExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $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 - $formattedProjectName = $gapicClient->projectName('[PROJECT]'); - $event = new ReportedErrorEvent(); - $eventServiceContext = new ServiceContext(); - $event->setServiceContext($eventServiceContext); - $eventMessage = 'eventMessage1863181325'; - $event->setMessage($eventMessage); - try { - $gapicClient->reportErrorEvent($formattedProjectName, $event); - // If the $gapicClient 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()); - } -} From cd886ad7844ce931aa56a2de239e6a61c7bd6cbe Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Mon, 23 Mar 2026 19:35:56 -0400 Subject: [PATCH 2/2] chore(main): release 0.324.0 (#9027) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 3d9dcb1..4e8f395 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.25.3 +0.26.0